1/* 2 * FancyBox Plus - jQuery Plugin 3 * Simple and fancy lightbox alternative 4 * 5 * Examples and documentation at: http://igorlino.github.io/fancybox-plus/ 6 * 7 * Version: 1.3.5 (20.06.2015) 8 * Requires: jQuery v1.3+ 9 * 10 * Licensed under the MIT license: 11 * http://www.opensource.org/licenses/mit-license.php 12 */ 13 14; 15(function ($) { 16 var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right, 17 18 selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [], 19 20 ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i, 21 22 loadingTimer, loadingFrame = 1, 23 24 titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], {prop: 0}), 25 26 isIE6 = navigator.userAgent.match(/msie [6]/i) && !window.XMLHttpRequest, 27 28 /* 29 * Private methods 30 */ 31 32 _abort = function () { 33 loading.hide(); 34 35 imgPreloader.onerror = imgPreloader.onload = null; 36 37 if (ajaxLoader) { 38 ajaxLoader.abort(); 39 } 40 41 tmp.empty(); 42 }, 43 44 _error = function () { 45 if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) { 46 loading.hide(); 47 busy = false; 48 return; 49 } 50 51 selectedOpts.titleShow = false; 52 53 selectedOpts.width = 'auto'; 54 selectedOpts.height = 'auto'; 55 56 tmp.html('<p id="fbplus-error">The requested content cannot be loaded.<br />Please try again later.</p>'); 57 58 _process_inline(); 59 }, 60 61 _start = function () { 62 var obj = selectedArray[selectedIndex], 63 href, 64 type, 65 title, 66 str, 67 emb, 68 ret; 69 70 _abort(); 71 72 selectedOpts = $.extend({}, $.fn.fancyboxPlus.defaults, (typeof $(obj).data('fancyboxPlus') == 'undefined' ? selectedOpts : $(obj).data('fancyboxPlus'))); 73 74 ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts); 75 76 if (ret === false) { 77 busy = false; 78 return; 79 } else if (typeof ret == 'object') { 80 selectedOpts = $.extend(selectedOpts, ret); 81 } 82 83 title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || ''; 84 85 if (obj.nodeName && !selectedOpts.orig) { 86 selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj); 87 } 88 89 if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) { 90 title = selectedOpts.orig.attr('alt'); 91 } 92 93 href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null; 94 95 if ((/^(?:javascript)/i).test(href) || href == '#') { 96 href = null; 97 } 98 99 if (selectedOpts.type) { 100 type = selectedOpts.type; 101 102 if (!href) { 103 href = selectedOpts.content; 104 } 105 106 } else if (selectedOpts.content) { 107 type = 'html'; 108 109 } else if (href) { 110 if (href.match(imgRegExp)) { 111 type = 'image'; 112 113 } else if (href.match(swfRegExp)) { 114 type = 'swf'; 115 116 } else if ($(obj).hasClass("iframe")) { 117 type = 'iframe'; 118 119 } else if (href.indexOf("#") === 0) { 120 type = 'inline'; 121 122 } else { 123 type = 'ajax'; 124 } 125 } 126 127 if (!type) { 128 _error(); 129 return; 130 } 131 132 if (type == 'inline') { 133 obj = href.substr(href.indexOf("#")); 134 type = $(obj).length > 0 ? 'inline' : 'ajax'; 135 } 136 137 selectedOpts.type = type; 138 selectedOpts.href = href; 139 selectedOpts.title = title; 140 141 if (selectedOpts.autoDimensions) { 142 if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') { 143 selectedOpts.width = 'auto'; 144 selectedOpts.height = 'auto'; 145 } else { 146 selectedOpts.autoDimensions = false;
147 } 148 } 149 150 if (selectedOpts.modal) { 151 selectedOpts.overlayShow = true; 152 selectedOpts.hideOnOverlayClick = false; 153 selectedOpts.hideOnContentClick = false; 154 selectedOpts.enableEscapeButton = false; 155 selectedOpts.showCloseButton = false; 156 } 157 158 selectedOpts.padding = parseInt(selectedOpts.padding, 10); 159 selectedOpts.margin = parseInt(selectedOpts.margin, 10); 160 161 tmp.css('padding', (selectedOpts.padding + selectedOpts.margin)); 162 163 $('.fbplus-inline-tmp').unbind('fbplus-cancel').bind('fbplus-change', function () { 164 $(this).replaceWith(content.children()); 165 }); 166 167 switch (type) { 168 case 'html' : 169 tmp.html(selectedOpts.content); 170 _process_inline(); 171 break; 172 173 case 'inline' : 174 if ($(obj).parent().is('#fbplus-content') === true) { 175 busy = false; 176 return; 177 } 178 179 $('<div class="fbplus-inline-tmp" />') 180 .hide() 181 .insertBefore($(obj)) 182 .bind('fbplus-cleanup', function () { 183 $(this).replaceWith(content.children()); 184 }).bind('fbplus-cancel', function () { 185 $(this).replaceWith(tmp.children()); 186 }); 187 188 $(obj).appendTo(tmp); 189 190 _process_inline(); 191 break; 192 193 case 'image': 194 busy = false; 195 196 $.fancyboxPlus.showActivity(); 197 198 imgPreloader = new Image(); 199 200 imgPreloader.onerror = function () { 201 _error(); 202 }; 203 204 imgPreloader.onload = function () { 205 busy = true; 206 207 imgPreloader.onerror = imgPreloader.onload = null; 208 209 _process_image(); 210 }; 211 212 imgPreloader.src = href; 213 break; 214 215 case 'swf': 216 selectedOpts.scrolling = 'no'; 217 218 str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>'; 219 emb = ''; 220 221 $.each(selectedOpts.swf, function (name, val) { 222 str += '<param name="' + name + '" value="' + val + '"></param>'; 223 emb += ' ' + name + '="' + val + '"'; 224 }); 225 226 str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>'; 227 228 tmp.html(str); 229 230 _process_inline(); 231 break; 232 233 case 'ajax': 234 busy = false; 235 236 $.fancyboxPlus.showActivity(); 237 238 selectedOpts.ajax.win = selectedOpts.ajax.success; 239 240 ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, { 241 url: href, 242 data: selectedOpts.ajax.data || {}, 243 error: function (XMLHttpRequest, textStatus, errorThrown) { 244 if (XMLHttpRequest.status > 0) { 245 _error(); 246 } 247 }, 248 success: function (data, textStatus, XMLHttpRequest) { 249 var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader; 250 if (o.status == 200) { 251 if (typeof selectedOpts.ajax.win == 'function') { 252 ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest); 253 254 if (ret === false) { 255 loading.hide(); 256 return; 257 } else if (typeof ret == 'string' || typeof ret == 'object') { 258 data = ret; 259 } 260 } 261 262 tmp.html(data); 263 _process_inline(); 264 } 265 } 266 })); 267 268 break; 269 270 case 'iframe': 271 _show(); 272 break; 273 } 274 }, 275 276 _process_inline = function () { 277 var 278 w = selectedOpts.width, 279 h = selectedOpts.height; 280 281 if (w.toString().indexOf('%') > -1) { 282 w = parseInt(($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px'; 283 284 } else { 285 w = w == 'auto' ? 'auto' : w + 'px'; 286 } 287 288 if (h.toString().indexOf('%') > -1) { 289 h = parseInt(($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px'; 290 291 } else { 292 h = h == 'auto' ? 'auto' : h + 'px'; 293 } 294 295 tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>'); 296 297 selectedOpts.width = tmp.width(); 298 selectedOpts.height = tmp.height(); 299 300 _show(); 301 }, 302 303 _process_image = function () { 304 selectedOpts.width = imgPreloader.width; 305 selectedOpts.height = imgPreloader.height; 306 307 $("<img />").attr({ 308 'id': 'fbplus-img', 309 'src': imgPreloader.src, 310 'alt': selectedOpts.title 311 }).appendTo(tmp); 312 313 _show(); 314 }, 315 316 _show = function () { 317 var pos, equal; 318 319 loading.hide(); 320 321 if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) { 322 $.event.trigger('fbplus-cancel'); 323 324 busy = false;
325 return; 326 } 327 328 busy = true; 329 330 $(content.add(overlay)).unbind(); 331 332 $(window).unbind("resize.fb scroll.fb"); 333 $(document).unbind('keydown.fb'); 334 335 if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') { 336 wrap.css('height', wrap.height()); 337 } 338 339 currentArray = selectedArray; 340 currentIndex = selectedIndex; 341 currentOpts = selectedOpts; 342 343 if (currentOpts.overlayShow) { 344 overlay.css({ 345 'background-color': currentOpts.overlayColor, 346 'opacity': currentOpts.overlayOpacity, 347 'cursor': currentOpts.hideOnOverlayClick ? 'pointer' : 'auto', 348 'height': $(document).height() 349 }); 350 351 if (!overlay.is(':visible')) { 352 if (isIE6) { 353 $('select:not(#fbplus-tmp select)').filter(function () { 354 return this.style.visibility !== 'hidden'; 355 }).css({'visibility': 'hidden'}).one('fbplus-cleanup', function () { 356 this.style.visibility = 'inherit'; 357 }); 358 } 359 360 overlay.show(); 361 } 362 } else { 363 overlay.hide(); 364 } 365 366 final_pos = _get_zoom_to(); 367 368 _process_title(); 369 370 if (wrap.is(":visible")) { 371 $(close.add(nav_left).add(nav_right)).hide(); 372 373 pos = wrap.position(), 374 375 start_pos = { 376 top: pos.top, 377 left: pos.left, 378 width: wrap.width(), 379 height: wrap.height() 380 }; 381 382 equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height); 383 384 content.fadeTo(currentOpts.changeFade, 0.3, function () { 385 var finish_resizing = function () { 386 content.html(tmp.contents()).fadeTo(currentOpts.changeFade, 1, _finish); 387 }; 388 389 $.event.trigger('fbplus-change'); 390 391 content 392 .empty() 393 .removeAttr('filter') 394 .css({ 395 'border-width': currentOpts.padding, 396 'width': final_pos.width - currentOpts.padding * 2, 397 'height': selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2 398 }); 399 400 if (equal) { 401 finish_resizing(); 402 403 } else { 404 fx.prop = 0; 405 406 $(fx).animate({prop: 1}, { 407 duration: currentOpts.changeSpeed, 408 easing: currentOpts.easingChange, 409 step: _draw, 410 complete: finish_resizing 411 }); 412 } 413 }); 414 415 return; 416 } 417 418 wrap.removeAttr("style"); 419 420 content.css('border-width', currentOpts.padding); 421 422 if (currentOpts.transitionIn == 'elastic') { 423 start_pos = _get_zoom_from(); 424 425 content.html(tmp.contents()); 426 427 wrap.show(); 428 429 if (currentOpts.opacity) { 430 final_pos.opacity = 0; 431 } 432 433 fx.prop = 0; 434 435 $(fx).animate({prop: 1}, { 436 duration: currentOpts.speedIn, 437 easing: currentOpts.easingIn, 438 step: _draw, 439 complete: _finish 440 }); 441 442 return; 443 } 444 445 if (currentOpts.titlePosition == 'inside' && titleHeight > 0) { 446 title.show(); 447 } 448 449 content 450 .css({ 451 'width': final_pos.width - currentOpts.padding * 2, 452 'height': selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2 453 }) 454 .html(tmp.contents()); 455 456 wrap 457 .css(final_pos) 458 .fadeIn(currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish); 459 }, 460 461 _format_title = function (title) { 462 if (title && title.length) { 463 if (currentOpts.titlePosition == 'float') { 464 return '<table id="fbplus-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fbplus-title-float-left"></td><td id="fbplus-title-float-main">' + title + '</td><td id="fbplus-title-float-right"></td></tr></table>'; 465 } 466 467 return '<div id="fbplus-title-' + currentOpts.titlePosition + '">' + title + '</div>'; 468 } 469 470 return false;
471 }, 472 473 _process_title = function () { 474 titleStr = currentOpts.title || ''; 475 titleHeight = 0; 476 477 title 478 .empty() 479 .removeAttr('style') 480 .removeClass(); 481 482 if (currentOpts.titleShow === false) { 483 title.hide(); 484 return; 485 } 486 487 titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr); 488 489 if (!titleStr || titleStr === '') { 490 title.hide(); 491 return; 492 } 493 494 title 495 .addClass('fbplus-title-' + currentOpts.titlePosition) 496 .html(titleStr) 497 .appendTo('body') 498 .show(); 499 500 switch (currentOpts.titlePosition) { 501 case 'inside': 502 title 503 .css({ 504 'width': final_pos.width - (currentOpts.padding * 2), 505 'marginLeft': currentOpts.padding, 506 'marginRight': currentOpts.padding 507 }); 508 509 titleHeight = title.outerHeight(true); 510 511 title.appendTo(outer); 512 513 final_pos.height += titleHeight; 514 break; 515 516 case 'over': 517 title 518 .css({ 519 'marginLeft': currentOpts.padding, 520 'width': final_pos.width - (currentOpts.padding * 2), 521 'bottom': currentOpts.padding 522 }) 523 .appendTo(outer); 524 break; 525 526 case 'float': 527 title 528 .css('left', parseInt((title.width() - final_pos.width - 40) / 2, 10) * -1) 529 .appendTo(wrap); 530 break; 531 532 default: 533 title 534 .css({ 535 'width': final_pos.width - (currentOpts.padding * 2), 536 'paddingLeft': currentOpts.padding, 537 'paddingRight': currentOpts.padding 538 }) 539 .appendTo(wrap); 540 break; 541 } 542 543 title.hide(); 544 }, 545 546 _set_navigation = function () { 547 if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) { 548 $(document).bind('keydown.fb', function (e) { 549 if (e.keyCode == 27 && currentOpts.enableEscapeButton) { 550 e.preventDefault(); 551 $.fancyboxPlus.close(); 552 553 } else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') { 554 e.preventDefault(); 555 $.fancyboxPlus[e.keyCode == 37 ? 'prev' : 'next'](); 556 } 557 }); 558 } 559 560 if (!currentOpts.showNavArrows) { 561 nav_left.hide(); 562 nav_right.hide(); 563 return; 564 } 565 566 if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) { 567 nav_left.show(); 568 } 569 570 if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length - 1)) { 571 nav_right.show(); 572 } 573 }, 574 575 _finish = function () { 576 if (!$.support.opacity) { 577 $('#fancybox-content').css('filter', 0); 578 $('#fancybox-wrap').css('filter', 0); 579 } 580 581 if (selectedOpts.autoDimensions) { 582 content.css('height', 'auto'); 583 } 584 585 wrap.css('height', 'auto'); 586 587 if (titleStr && titleStr.length) { 588 title.show(); 589 } 590 591 if (currentOpts.showCloseButton) { 592 close.show(); 593 } 594 595 _set_navigation(); 596 597 if (currentOpts.hideOnContentClick) { 598 content.bind('click', $.fancyboxPlus.close); 599 } 600 601 if (currentOpts.hideOnOverlayClick) { 602 overlay.bind('click', $.fancyboxPlus.close); 603 } 604 605 $(window).bind("resize.fb", $.fancyboxPlus.resize); 606 607 if (currentOpts.centerOnScroll) { 608 $(window).bind("scroll.fb", $.fancyboxPlus.center); 609 } 610 611 if (currentOpts.type == 'iframe') { 612 $('<iframe id="fbplus-frame" name="fbplus-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + 613 (navigator.userAgent.match(/msie [6]/i) ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content); 614 } 615 616 wrap.show(); 617 618 busy = false;
619 620 $.fancyboxPlus.center(); 621 622 currentOpts.onComplete(currentArray, currentIndex, currentOpts); 623 624 _preload_images(); 625 }, 626 627 _preload_images = function () { 628 var href, 629 objNext; 630 631 if ((currentArray.length - 1) > currentIndex) { 632 href = currentArray[currentIndex + 1].href; 633 634 if (typeof href !== 'undefined' && href.match(imgRegExp)) { 635 objNext = new Image(); 636 objNext.src = href; 637 } 638 } 639 640 if (currentIndex > 0) { 641 href = currentArray[currentIndex - 1].href; 642 643 if (typeof href !== 'undefined' && href.match(imgRegExp)) { 644 objNext = new Image(); 645 objNext.src = href; 646 } 647 } 648 }, 649 650 _draw = function (pos) { 651 var dim = { 652 width: parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10), 653 height: parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10), 654 655 top: parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10), 656 left: parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10) 657 }; 658 659 if (typeof final_pos.opacity !== 'undefined') { 660 dim.opacity = pos < 0.5 ? 0.5 : pos; 661 } 662 663 wrap.css(dim); 664 665 content.css({ 666 'width': dim.width - currentOpts.padding * 2, 667 'height': dim.height - (titleHeight * pos) - currentOpts.padding * 2 668 }); 669 }, 670 671 _get_viewport = function () { 672 return [ 673 $(window).width() - (currentOpts.margin * 2), 674 $(window).height() - (currentOpts.margin * 2), 675 $(document).scrollLeft() + currentOpts.margin, 676 $(document).scrollTop() + currentOpts.margin 677 ]; 678 }, 679 680 _get_zoom_to = function () { 681 var view = _get_viewport(), 682 to = {}, 683 resize = currentOpts.autoScale, 684 double_padding = currentOpts.padding * 2, 685 ratio; 686 687 if (currentOpts.width.toString().indexOf('%') > -1) { 688 to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10); 689 } else { 690 to.width = currentOpts.width + double_padding; 691 } 692 693 if (currentOpts.height.toString().indexOf('%') > -1) { 694 to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10); 695 } else { 696 to.height = currentOpts.height + double_padding; 697 } 698 699 if (resize && (to.width > view[0] || to.height > view[1])) { 700 if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') { 701 ratio = (currentOpts.width ) / (currentOpts.height ); 702 703 if ((to.width ) > view[0]) { 704 to.width = view[0]; 705 to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10); 706 } 707 708 if ((to.height) > view[1]) { 709 to.height = view[1]; 710 to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10); 711 } 712 713 } else { 714 to.width = Math.min(to.width, view[0]); 715 to.height = Math.min(to.height, view[1]); 716 } 717 } 718 719 to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10); 720 to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10); 721 722 return to; 723 }, 724 725 _get_obj_pos = function (obj) { 726 var pos = obj.offset(); 727 728 pos.top += parseInt(obj.css('paddingTop'), 10) || 0; 729 pos.left += parseInt(obj.css('paddingLeft'), 10) || 0; 730 731 pos.top += parseInt(obj.css('border-top-width'), 10) || 0; 732 pos.left += parseInt(obj.css('border-left-width'), 10) || 0; 733 734 pos.width = obj.width(); 735 pos.height = obj.height(); 736 737 return pos; 738 }, 739 740 _get_zoom_from = function () { 741 var orig = selectedOpts.orig ? $(selectedOpts.orig) : false, 742 from = {}, 743 pos, 744 view; 745 746 if (orig && orig.length) { 747 pos = _get_obj_pos(orig); 748 749 from = { 750 width: pos.width + (currentOpts.padding * 2), 751 height: pos.height + (currentOpts.padding * 2), 752 top: pos.top - currentOpts.padding - 20, 753 left: pos.left - currentOpts.padding - 20 754 }; 755 756 } else { 757 view = _get_viewport(); 758 759 from = { 760 width: currentOpts.padding * 2, 761 height: currentOpts.padding * 2,
762 top: parseInt(view[3] + view[1] * 0.5, 10), 763 left: parseInt(view[2] + view[0] * 0.5, 10) 764 }; 765 } 766 767 return from; 768 }, 769 770 _animate_loading = function () { 771 if (!loading.is(':visible')) { 772 clearInterval(loadingTimer); 773 return; 774 } 775 776 $('div', loading).css('top', (loadingFrame * -40) + 'px'); 777 778 loadingFrame = (loadingFrame + 1) % 12; 779 }; 780 781 /* 782 * Public methods 783 */ 784 785 $.fn.fancyboxPlus = function (options) { 786 if (!$(this).length) { 787 return this; 788 } 789 790 $(this) 791 .data('fancyboxPlus', $.extend({}, options, ($.metadata ? $(this).metadata() : {}))) 792 .unbind('click.fb') 793 .bind('click.fb', function (e) { 794 e.preventDefault(); 795 796 if (busy) { 797 return; 798 } 799 800 busy = true; 801 802 $(this).blur(); 803 804 selectedArray = []; 805 selectedIndex = 0; 806 807 var rel = $(this).attr('rel') || ''; 808 809 if (!rel || rel == '' || rel === 'nofollow') { 810 selectedArray.push(this); 811 812 } else { 813 selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]"); 814 selectedIndex = selectedArray.index(this); 815 } 816 817 _start(); 818 819 return; 820 }); 821 822 return this; 823 }; 824 825 $.fancyboxPlus = function (obj) { 826 var opts; 827 828 if (busy) { 829 return; 830 } 831 832 busy = true; 833 opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {}; 834 835 selectedArray = []; 836 selectedIndex = parseInt(opts.index, 10) || 0; 837 838 if ($.isArray(obj)) { 839 for (var i = 0, j = obj.length; i < j; i++) { 840 if (typeof obj[i] == 'object') { 841 $(obj[i]).data('fancyboxPlus', $.extend({}, opts, obj[i])); 842 } else { 843 obj[i] = $({}).data('fancyboxPlus', $.extend({content: obj[i]}, opts)); 844 } 845 } 846 847 selectedArray = jQuery.merge(selectedArray, obj); 848 849 } else { 850 if (typeof obj == 'object') { 851 $(obj).data('fancyboxPlus', $.extend({}, opts, obj)); 852 } else { 853 obj = $({}).data('fancyboxPlus', $.extend({content: obj}, opts)); 854 } 855 856 selectedArray.push(obj); 857 } 858 859 if (selectedIndex > selectedArray.length || selectedIndex < 0) { 860 selectedIndex = 0; 861 } 862 863 _start(); 864 }; 865 866 $.fancyboxPlus.showActivity = function () { 867 clearInterval(loadingTimer); 868 869 loading.show(); 870 loadingTimer = setInterval(_animate_loading, 66); 871 }; 872 873 $.fancyboxPlus.hideActivity = function () { 874 loading.hide(); 875 }; 876 877 $.fancyboxPlus.next = function () { 878 return $.fancyboxPlus.pos(currentIndex + 1); 879 }; 880 881 $.fancyboxPlus.prev = function () { 882 return $.fancyboxPlus.pos(currentIndex - 1); 883 }; 884 885 $.fancyboxPlus.pos = function (pos) { 886 if (busy) { 887 return; 888 } 889 890 pos = parseInt(pos); 891 892 selectedArray = currentArray; 893 894 if (pos > -1 && pos < currentArray.length) { 895 selectedIndex = pos; 896 _start(); 897 898 } else if (currentOpts.cyclic && currentArray.length > 1) { 899 selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1; 900 _start(); 901 } 902 903 return; 904 }; 905 906 $.fancyboxPlus.cancel = function () { 907 if (busy) { 908 return; 909 } 910 911 busy = true; 912 913 $.event.trigger('fbplus-cancel'); 914 915 _abort(); 916 917 selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts); 918 919 busy = false; 920 }; 921 922 // Note: within an iframe use - parent.$.fancyboxPlus.close(); 923 $.fancyboxPlus.close = function () { 924 if (busy || wrap.is(':hidden')) { 925 return; 926 } 927 928 busy = true; 929 930 if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) { 931 busy = false;
932 return; 933 } 934 935 _abort(); 936 937 $(close.add(nav_left).add(nav_right)).hide(); 938 939 $(content.add(overlay)).unbind(); 940 941 $(window).unbind("resize.fb scroll.fb"); 942 $(document).unbind('keydown.fb'); 943 944 content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank'); 945 946 if (currentOpts.titlePosition !== 'inside') { 947 title.empty(); 948 } 949 950 wrap.stop(); 951 952 function _cleanup() { 953 overlay.fadeOut('fast'); 954 955 title.empty().hide(); 956 wrap.hide(); 957 958 $.event.trigger('fbplus-cleanup'); 959 960 content.empty(); 961 962 currentOpts.onClosed(currentArray, currentIndex, currentOpts); 963 964 currentArray = selectedOpts = []; 965 currentIndex = selectedIndex = 0; 966 currentOpts = selectedOpts = {}; 967 968 busy = false; 969 } 970 971 if (currentOpts.transitionOut == 'elastic') { 972 start_pos = _get_zoom_from(); 973 974 var pos = wrap.position(); 975 976 final_pos = { 977 top: pos.top, 978 left: pos.left, 979 width: wrap.width(), 980 height: wrap.height() 981 }; 982 983 if (currentOpts.opacity) { 984 final_pos.opacity = 1; 985 } 986 987 title.empty().hide(); 988 989 fx.prop = 1; 990 991 $(fx).animate({prop: 0}, { 992 duration: currentOpts.speedOut, 993 easing: currentOpts.easingOut, 994 step: _draw, 995 complete: _cleanup 996 }); 997 998 } else { 999 wrap.fadeOut(currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup); 1000 } 1001 }; 1002 1003 $.fancyboxPlus.resize = function () { 1004 if (overlay.is(':visible')) { 1005 overlay.css('height', $(document).height()); 1006 } 1007 1008 $.fancyboxPlus.center(true); 1009 }; 1010 1011 $.fancyboxPlus.center = function () { 1012 var view, align; 1013 1014 if (busy) { 1015 return; 1016 } 1017 1018 align = arguments[0] === true ? 1 : 0; 1019 view = _get_viewport(); 1020 1021 if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) { 1022 return; 1023 } 1024 1025 wrap 1026 .stop() 1027 .animate({ 1028 'top': parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)), 1029 'left': parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding)) 1030 }, typeof arguments[0] == 'number' ? arguments[0] : 200); 1031 }; 1032 1033 $.fancyboxPlus.init = function () { 1034 if ($("#fbplus-wrap").length) { 1035 return; 1036 } 1037 1038 $('body').append( 1039 tmp = $('<div id="fbplus-tmp"></div>'), 1040 loading = $('<div id="fbplus-loading"><div></div></div>'), 1041 overlay = $('<div id="fbplus-overlay"></div>'), 1042 wrap = $('<div id="fbplus-wrap"></div>') 1043 ); 1044 1045 outer = $('<div id="fbplus-outer"></div>') 1046 .append('<div class="fbplus-bg" id="fbplus-bg-n"></div><div class="fbplus-bg" id="fbplus-bg-ne"></div><div class="fbplus-bg" id="fbplus-bg-e"></div><div class="fbplus-bg" id="fbplus-bg-se"></div><div class="fbplus-bg" id="fbplus-bg-s"></div><div class="fbplus-bg" id="fbplus-bg-sw"></div><div class="fbplus-bg" id="fbplus-bg-w"></div><div class="fbplus-bg" id="fbplus-bg-nw"></div>') 1047 .appendTo(wrap); 1048 1049 outer.append( 1050 content = $('<div id="fbplus-content"></div>'), 1051 close = $('<a id="fbplus-close"></a>'), 1052 title = $('<div id="fbplus-title"></div>'), 1053 1054 nav_left = $('<a href="javascript:;" id="fbplus-left"><span class="fancy-ico" id="fbplus-left-ico"></span></a>'), 1055 nav_right = $('<a href="javascript:;" id="fbplus-right"><span class="fancy-ico" id="fbplus-right-ico"></span></a>') 1056 ); 1057 1058 close.click($.fancyboxPlus.close); 1059 loading.click($.fancyboxPlus.cancel); 1060 1061 nav_left.click(function (e) { 1062 e.preventDefault(); 1063 $.fancyboxPlus.prev(); 1064 }); 1065 1066 nav_right.click(function (e) { 1067 e.preventDefault(); 1068 $.fancyboxPlus.next(); 1069 }); 1070 1071 if ($.fn.mousewheel) { 1072 wrap.bind('mousewheel.fb', function (e, delta) { 1073 if (busy) { 1074 e.preventDefault(); 1075 1076 } else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) { 1077 e.preventDefault(); 1078 $.fancyboxPlus[delta > 0 ? 'prev' : 'next'](); 1079 } 1080 }); 1081 } 1082 1083 if (!$.support.opacity) { 1084 wrap.addClass('fbplus-ie'); 1085 } 1086 1087 if (isIE6) { 1088 loading.addClass('fbplus-ie6'); 1089 wrap.addClass('fbplus-ie6'); 1090 1091 $('<iframe id="fbplus-hide-sel-frame" src="' + (/^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank' ) + '" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer); 1092 } 1093 }; 1094 1095 $.fn.fancyboxPlus.defaults = { 1096 padding: 10, 1097 margin: 40, 1098 opacity: false, 1099 modal: false,
1100 cyclic: false, 1101 scrolling: 'auto', // 'auto', 'yes' or 'no' 1102 1103 width: 560, 1104 height: 340, 1105 1106 autoScale: true, 1107 autoDimensions: true, 1108 centerOnScroll: false, 1109 1110 ajax: {}, 1111 swf: {wmode: 'transparent'}, 1112 1113 hideOnOverlayClick: true, 1114 hideOnContentClick: false, 1115 1116 overlayShow: true, 1117 overlayOpacity: 0.7, 1118 overlayColor: '#777', 1119 1120 titleShow: true, 1121 titlePosition: 'float', // 'float', 'outside', 'inside' or 'over' 1122 titleFormat: null, 1123 titleFromAlt: false, 1124 1125 transitionIn: 'fade', // 'elastic', 'fade' or 'none' 1126 transitionOut: 'fade', // 'elastic', 'fade' or 'none' 1127 1128 speedIn: 300, 1129 speedOut: 300, 1130 1131 changeSpeed: 300, 1132 changeFade: 'fast', 1133 1134 easingIn: 'swing', 1135 easingOut: 'swing', 1136 1137 showCloseButton: true, 1138 showNavArrows: true, 1139 enableEscapeButton: true, 1140 enableKeyboardNav: true, 1141 1142 onStart: function () { 1143 }, 1144 onCancel: function () { 1145 }, 1146 onComplete: function () { 1147 }, 1148 onCleanup: function () { 1149 }, 1150 onClosed: function () { 1151 }, 1152 onError: function () { 1153 } 1154 }; 1155 1156 $(document).ready(function () { 1157 $.fancyboxPlus.init(); 1158 }); 1159 1160})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.