1/*! 2 Colorbox v1.4.37 - 2014-02-11 3 jQuery lightbox and modal window plugin 4 (c) 2014 Jack Moore - http://www.jacklmoore.com/colorbox 5 license: http://www.opensource.org/licenses/mit-license.php 6*/ 7(function ($, document, window) { 8 var 9 // Default settings object. 10 // See http://jacklmoore.com/colorbox for details. 11 defaults = { 12 // data sources 13 html: false, 14 photo: false, 15 iframe: false, 16 inline: false, 17 18 // behavior and appearance 19 transition: "elastic", 20 speed: 600, 21 fadeOut: 400, 22 width: false, 23 initialWidth: "600", 24 innerWidth: false, 25 maxWidth: false, 26 height: false, 27 initialHeight: "450", 28 innerHeight: false, 29 maxHeight: false, 30 scalePhotos: true, 31 scrolling: true, 32 href: false, 33 title: false, 34 rel: false, 35 opacity: 0.9, 36 preloading: true, 37 className: false, 38 overlayClose: true, 39 escKey: true, 40 arrowKey: true, 41 top: false, 42 bottom: false, 43 left: false, 44 right: false, 45 fixed: false, 46 data: undefined, 47 closeButton: false, 48 fastIframe: true, 49 open: false, 50 reposition: true, 51 loop: true, 52 slideshow: false, 53 slideshowAuto: true, 54 slideshowSpeed: 2500, 55 slideshowStart: "start slideshow", 56 slideshowStop: "stop slideshow", 57 photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr)((#|\?).*)?$/i, 58 59 // alternate image paths for high-res displays 60 retinaImage: false, 61 retinaUrl: false, 62 retinaSuffix: '@2x.$1', 63 64 // internationalization 65 current: "image {current} of {total}", 66 previous: "previous", 67 next: "next", 68 close: "close", 69 xhrError: "This content failed to load.", 70 imgError: "This image failed to load.", 71 72 // accessbility 73 returnFocus: true, 74 trapFocus: true, 75 76 // callbacks 77 onOpen: false, 78 onLoad: false, 79 onComplete: false, 80 onCleanup: false, 81 onClosed: false 82 }, 83 84 // Abstracting the HTML and event identifiers for easy rebranding 85 colorbox = 'colorbox', 86 prefix = 'cbox', 87 boxElement = prefix + 'Element', 88 89 // Events 90 event_open = prefix + '_open', 91 event_load = prefix + '_load', 92 event_complete = prefix + '_complete', 93 event_cleanup = prefix + '_cleanup', 94 event_closed = prefix + '_closed', 95 event_purge = prefix + '_purge', 96 97 // Cached jQuery Object Variables 98 $overlay, 99 $box, 100 $wrap, 101 $content, 102 $topBorder, 103 $leftBorder, 104 $rightBorder, 105 $bottomBorder, 106 $related, 107 $window, 108 $loaded, 109 $loadingBay, 110 $loadingOverlay, 111 $title, 112 $current, 113 $slideshow, 114 $next, 115 $prev, 116 $close, 117 $groupControls, 118 $events = $('<a/>'), // $([]) would be prefered, but there is an issue with jQuery 1.4.2 119 120 // Variables for cached values or use across multiple functions 121 settings, 122 interfaceHeight, 123 interfaceWidth, 124 loadedHeight, 125 loadedWidth, 126 element, 127 index, 128 photo, 129 open, 130 active, 131 closing, 132 loadingTimer, 133 publicMethod, 134 div = "div", 135 className, 136 requests = 0, 137 previousCSS = {}, 138 init; 139 140 // **************** 141 // HELPER FUNCTIONS 142 // **************** 143 144 // Convenience function for creating new jQuery objects 145 function $tag(tag, id, css) { 146 var element = document.createElement(tag); 147 148 if (id) { 149 element.id = prefix + id; 150 } 151 152 if (css) { 153 element.style.cssText = css; 154 } 155 156 return $(element); 157 } 158 159 // Get the window height using innerHeight when available to avoid an issue with iOS 160 // http://bugs.jquery.com/ticket/6724 161 function winheight() { 162 return window.innerHeight ? window.innerHeight : $(window).height(); 163 } 164 165 // Determine the next and previous members in a group. 166 function getIndex(increment) { 167 var 168 max = $related.length, 169 newIndex = (index + increment) % max; 170 171 return (newIndex < 0) ? max + newIndex : newIndex; 172 } 173 174 // Convert '%' and 'px' values to integers 175 function setSize(size, dimension) { 176 return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10)); 177 } 178 179 // Checks an href to see if it is a photo. 180 // There is a force photo option (photo: true) for hrefs that cannot be matched by the regex. 181 function isImage(settings, url) { 182 return settings.photo || settings.photoRegex.test(url); 183 } 184 185 function retinaUrl(settings, url) { 186 return settings.retinaUrl && window.devicePixelRatio > 1 ? url.replace(settings.photoRegex, settings.retinaSuffix) : url; 187 } 188 189 function trapFocus(e) { 190 if ('contains' in $box[0] && !$box[0].contains(e.target)) { 191 e.stopPropagation(); 192 $box.focus(); 193 } 194 } 195 196 // Assigns function results to their respective properties 197 function makeSettings() { 198 var i, 199 data = $.data(element, colorbox); 200 201 if (data == null) { 202 settings = $.extend({}, defaults); 203 if (console && console.log) { 204 console.log('Error: cboxElement missing settings object'); 205 } 206 } else { 207 settings = $.extend({}, data); 208 } 209 210 for (i in settings) { 211 if ($.isFunction(settings[i]) && i.slice(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time. 212 settings[i] = settings[i].call(element); 213 } 214 } 215 216 settings.rel = settings.rel || element.rel || $(element).data('rel') || 'nofollow'; 217 settings.href = settings.href || $(element).attr('href'); 218 settings.title = settings.title || element.title; 219 220 if (typeof settings.href === "string") { 221 settings.href = $.trim(settings.href); 222 } 223 } 224 225 function trigger(event, callback) { 226 // for external use 227 $(document).trigger(event); 228 229 // for internal use 230 $events.triggerHandler(event); 231 232 if ($.isFunction(callback)) { 233 callback.call(element); 234 } 235 } 236 237 238 var slideshow = (function(){ 239 var active, 240 className = prefix + "Slideshow_", 241 click = "click." + prefix, 242 timeOut; 243 244 function clear () { 245 clearTimeout(timeOut); 246 } 247 248 function set() { 249 if (settings.loop || $related[index + 1]) { 250 clear(); 251 timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed); 252 } 253 } 254 255 function start() { 256 $slideshow
257 .html(settings.slideshowStop) 258 .unbind(click) 259 .one(click, stop); 260 261 $events 262 .bind(event_complete, set) 263 .bind(event_load, clear); 264 265 $box.removeClass(className + "off").addClass(className + "on"); 266 } 267 268 function stop() { 269 clear(); 270 271 $events 272 .unbind(event_complete, set) 273 .unbind(event_load, clear); 274 275 $slideshow 276 .html(settings.slideshowStart) 277 .unbind(click) 278 .one(click, function () { 279 publicMethod.next(); 280 start(); 281 }); 282 283 $box.removeClass(className + "on").addClass(className + "off"); 284 } 285 286 function reset() { 287 active = false; 288 $slideshow.hide(); 289 clear(); 290 $events 291 .unbind(event_complete, set) 292 .unbind(event_load, clear); 293 $box.removeClass(className + "off " + className + "on"); 294 } 295 296 return function(){ 297 if (active) { 298 if (!settings.slideshow) { 299 $events.unbind(event_cleanup, reset); 300 reset(); 301 } 302 } else { 303 if (settings.slideshow && $related[1]) { 304 active = true; 305 $events.one(event_cleanup, reset); 306 if (settings.slideshowAuto) { 307 start(); 308 } else { 309 stop(); 310 } 311 $slideshow.show(); 312 } 313 } 314 }; 315 316 }()); 317 318 319 function launch(target) { 320 if (!closing) { 321 322 element = target; 323 324 makeSettings(); 325 326 $related = $(element); 327 328 index = 0; 329 330 if (settings.rel !== 'nofollow') { 331 $related = $('.' + boxElement).filter(function () { 332 var data = $.data(this, colorbox), 333 relRelated; 334 335 if (data) { 336 relRelated = $(this).data('rel') || data.rel || this.rel; 337 } 338 339 return (relRelated === settings.rel); 340 }); 341 index = $related.index(element); 342 343 // Check direct calls to Colorbox. 344 if (index === -1) { 345 $related = $related.add(element); 346 index = $related.length - 1; 347 } 348 } 349 350 $overlay.css({ 351 opacity: parseFloat(settings.opacity), 352 cursor: settings.overlayClose ? "pointer" : "auto", 353 visibility: 'visible' 354 }).show(); 355 356 357 if (className) { 358 $box.add($overlay).removeClass(className); 359 } 360 if (settings.className) { 361 $box.add($overlay).addClass(settings.className); 362 } 363 className = settings.className; 364 365 if (settings.closeButton) { 366 $close.html(settings.close).appendTo($content); 367 } else { 368 $close.appendTo('<div/>'); 369 } 370 371 if (!open) { 372 open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys. 373 374 // Show colorbox so the sizes can be calculated in older versions of jQuery 375 $box.css({visibility:'hidden', display:'block'}); 376 377 $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden'); 378 $content.css({width:'', height:''}).append($loaded); 379 380 // Cache values needed for size calculations 381 interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height(); 382 interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width(); 383 loadedHeight = $loaded.outerHeight(true); 384 loadedWidth = $loaded.outerWidth(true); 385 386 // Opens inital empty Colorbox prior to content being loaded. 387 settings.w = setSize(settings.initialWidth, 'x'); 388 settings.h = setSize(settings.initialHeight, 'y'); 389 $loaded.css({width:'', height:settings.h}); 390 publicMethod.position(); 391 392 trigger(event_open, settings.onOpen); 393 394 $groupControls.add($title).hide(); 395 396 $box.focus(); 397 398 if (settings.trapFocus) { 399 // Confine focus to the modal 400 // Uses event capturing that is not supported in IE8- 401 if (document.addEventListener) { 402 403 document.addEventListener('focus', trapFocus, true); 404 405 $events.one(event_closed, function () { 406 document.removeEventListener('focus', trapFocus, true); 407 }); 408 } 409 } 410 411 // Return focus on closing 412 if (settings.returnFocus) { 413 $events.one(event_closed, function () { 414 $(element).focus(); 415 }); 416 } 417 } 418 load(); 419 } 420 } 421 422 // Colorbox's markup needs to be added to the DOM prior to being called 423 // so that the browser will go ahead and load the CSS background images. 424 function appendHTML() { 425 if (!$box && document.body) { 426 init = false;
vendor: 9,551 bytes, lines 427-752
427 $window = $(window); 428 $box = $tag(div).attr({ 429 id: colorbox, 430 'class': $.support.opacity === false ? prefix + 'IE' : '', // class for optional IE8 & lower targeted CSS. 431 role: 'dialog', 432 tabindex: '-1' 433 }).hide(); 434 $overlay = $tag(div, "Overlay").hide(); 435 $loadingOverlay = $([$tag(div, "LoadingOverlay")[0],$tag(div, "LoadingGraphic")[0]]); 436 $wrap = $tag(div, "Wrapper"); 437 $content = $tag(div, "Content").append( 438 $title = $tag(div, "Title"), 439 $current = $tag(div, "Current"), 440 $prev = $('<button type="button"/>').attr({id:prefix+'Previous'}), 441 $next = $('<button type="button"/>').attr({id:prefix+'Next'}), 442 $slideshow = $tag('button', "Slideshow"), 443 $loadingOverlay 444 ); 445 446 $close = $('<button type="button"/>').attr({id:prefix+'Close'}); 447 448 $wrap.append( // The 3x3 Grid that makes up Colorbox 449 $tag(div).append( 450 $tag(div, "TopLeft"), 451 $topBorder = $tag(div, "TopCenter"), 452 $tag(div, "TopRight") 453 ), 454 $tag(div, false, 'clear:left').append( 455 $leftBorder = $tag(div, "MiddleLeft"), 456 $content, 457 $rightBorder = $tag(div, "MiddleRight") 458 ), 459 $tag(div, false, 'clear:left').append( 460 $tag(div, "BottomLeft"), 461 $bottomBorder = $tag(div, "BottomCenter"), 462 $tag(div, "BottomRight") 463 ) 464 ).find('div div').css({'float': 'left'}); 465 466 $loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none; max-width:none;'); 467 468 $groupControls = $next.add($prev).add($current).add($slideshow); 469 470 $(document.body).append($overlay, $box.append($wrap, $loadingBay)); 471 } 472 } 473 474 // Add Colorbox's event bindings 475 function addBindings() { 476 function clickHandler(e) { 477 // ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt. 478 // See: http://jacklmoore.com/notes/click-events/ 479 if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey)) { 480 e.preventDefault(); 481 launch(this); 482 } 483 } 484 485 if ($box) { 486 if (!init) { 487 init = true; 488 489 // Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly. 490 $next.click(function () { 491 publicMethod.next(); 492 }); 493 $prev.click(function () { 494 publicMethod.prev(); 495 }); 496 $close.click(function () { 497 publicMethod.close(); 498 }); 499 $overlay.click(function () { 500 if (settings.overlayClose) { 501 publicMethod.close(); 502 } 503 }); 504 505 // Key Bindings 506 $(document).bind('keydown.' + prefix, function (e) { 507 var key = e.keyCode; 508 if (open && settings.escKey && key === 27) { 509 e.preventDefault(); 510 publicMethod.close(); 511 } 512 if (open && settings.arrowKey && $related[1] && !e.altKey) { 513 if (key === 37) { 514 e.preventDefault(); 515 $prev.click(); 516 } else if (key === 39) { 517 e.preventDefault(); 518 $next.click(); 519 } 520 } 521 }); 522 523 if ($.isFunction($.fn.on)) { 524 // For jQuery 1.7+ 525 $(document).on('click.'+prefix, '.'+boxElement, clickHandler); 526 } else { 527 // For jQuery 1.3.x -> 1.6.x 528 // This code is never reached in jQuery 1.9, so do not contact me about 'live' being removed. 529 // This is not here for jQuery 1.9, it's here for legacy users. 530 $('.'+boxElement).live('click.'+prefix, clickHandler); 531 } 532 } 533 return true; 534 } 535 return false; 536 } 537 538 // Don't do anything if Colorbox already exists. 539 if ($.colorbox) { 540 return; 541 } 542 543 // Append the HTML when the DOM loads 544 $(appendHTML); 545 546 547 // **************** 548 // PUBLIC FUNCTIONS 549 // Usage format: $.colorbox.close(); 550 // Usage from within an iframe: parent.jQuery.colorbox.close(); 551 // **************** 552 553 publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) { 554 var $this = this; 555 556 options = options || {}; 557 558 appendHTML(); 559 560 if (addBindings()) { 561 if ($.isFunction($this)) { // assume a call to $.colorbox 562 $this = $('<a/>'); 563 options.open = true; 564 } else if (!$this[0]) { // colorbox being applied to empty collection 565 return $this; 566 } 567 568 if (callback) { 569 options.onComplete = callback; 570 } 571 572 $this.each(function () { 573 $.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options)); 574 }).addClass(boxElement); 575 576 if (($.isFunction(options.open) && options.open.call($this)) || options.open) { 577 launch($this[0]); 578 } 579 } 580 581 return $this; 582 }; 583 584 publicMethod.position = function (speed, loadedCallback) { 585 var 586 css, 587 top = 0, 588 left = 0, 589 offset = $box.offset(), 590 scrollTop, 591 scrollLeft; 592 593 $window.unbind('resize.' + prefix); 594 595 // remove the modal so that it doesn't influence the document width/height 596 $box.css({top: -9e4, left: -9e4}); 597 598 scrollTop = $window.scrollTop(); 599 scrollLeft = $window.scrollLeft(); 600 601 if (settings.fixed) { 602 offset.top -= scrollTop; 603 offset.left -= scrollLeft; 604 $box.css({position: 'fixed'}); 605 } else { 606 top = scrollTop; 607 left = scrollLeft; 608 $box.css({position: 'absolute'}); 609 } 610 611 // keeps the top and left positions within the browser's viewport. 612 if (settings.right !== false) { 613 left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0); 614 } else if (settings.left !== false) { 615 left += setSize(settings.left, 'x'); 616 } else { 617 left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2); 618 } 619 620 if (settings.bottom !== false) { 621 top += Math.max(winheight() - settings.h - loadedHeight - interfaceHeight - setSize(settings.bottom, 'y'), 0); 622 } else if (settings.top !== false) { 623 top += setSize(settings.top, 'y'); 624 } else { 625 top += Math.round(Math.max(winheight() - settings.h - loadedHeight - interfaceHeight, 0) / 2); 626 } 627 628 $box.css({top: offset.top, left: offset.left, visibility:'visible'}); 629 630 // this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly, 631 // but it has to be shrank down around the size of div#colorbox when it's done. If not, 632 // it can invoke an obscure IE bug when using iframes. 633 $wrap[0].style.width = $wrap[0].style.height = "9999px"; 634 635 function modalDimensions() { 636 $topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = (parseInt($box[0].style.width,10) - interfaceWidth)+'px'; 637 $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = (parseInt($box[0].style.height,10) - interfaceHeight)+'px'; 638 } 639 640 css = {width: settings.w + loadedWidth + interfaceWidth, height: settings.h + loadedHeight + interfaceHeight, top: top, left: left}; 641 642 // setting the speed to 0 if the content hasn't changed size or position 643 if (speed) { 644 var tempSpeed = 0; 645 $.each(css, function(i){ 646 if (css[i] !== previousCSS[i]) { 647 tempSpeed = speed; 648 return; 649 } 650 }); 651 speed = tempSpeed; 652 } 653 654 previousCSS = css; 655 656 if (!speed) { 657 $box.css(css); 658 } 659 660 $box.dequeue().animate(css, { 661 duration: speed || 0, 662 complete: function () { 663 modalDimensions(); 664 665 active = false; 666 667 // shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation. 668 $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px"; 669 $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px"; 670 671 if (settings.reposition) { 672 setTimeout(function () { // small delay before binding onresize due to an IE8 bug. 673 $window.bind('resize.' + prefix, function(){ 674 publicMethod.position(); 675 }); 676 }, 1); 677 } 678 679 if ($.isFunction(loadedCallback)) { 680 loadedCallback(); 681 } 682 }, 683 step: modalDimensions 684 }); 685 }; 686 687 publicMethod.resize = function (options) { 688 var scrolltop; 689 690 if (open) { 691 options = options || {}; 692 693 if (options.width) { 694 settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth; 695 } 696 697 if (options.innerWidth) { 698 settings.w = setSize(options.innerWidth, 'x'); 699 } 700 701 $loaded.css({width: settings.w}); 702 703 if (options.height) { 704 settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight; 705 } 706 707 if (options.innerHeight) { 708 settings.h = setSize(options.innerHeight, 'y'); 709 } 710 711 if (!options.innerHeight && !options.height) { 712 scrolltop = $loaded.scrollTop(); 713 $loaded.css({height: "auto"}); 714 settings.h = $loaded.height(); 715 } 716 717 $loaded.css({height: settings.h}); 718 719 if(scrolltop) { 720 $loaded.scrollTop(scrolltop); 721 } 722 723 publicMethod.position(settings.transition === "none" ? 0 : settings.speed); 724 } 725 }; 726 727 publicMethod.prep = function (object) { 728 if (!open) { 729 return; 730 } 731 732 var callback, speed = settings.transition === "none" ? 0 : settings.speed; 733 734 $loaded.empty().remove(); // Using empty first may prevent some IE7 issues. 735 736 $loaded = $tag(div, 'LoadedContent').append(object); 737 738 function getWidth() { 739 settings.w = settings.w || $loaded.width(); 740 settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w; 741 return settings.w; 742 } 743 function getHeight() { 744 settings.h = settings.h || $loaded.height(); 745 settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h; 746 return settings.h; 747 } 748 749 $loaded.hide() 750 .appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations. 751 .css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'}) 752 .css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
753 .prependTo($content); 754 755 $loadingBay.hide(); 756 757 // floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width. 758 759 $(photo).css({'float': 'none'}); 760 761 callback = function () { 762 var total = $related.length, 763 iframe, 764 frameBorder = 'frameBorder', 765 allowTransparency = 'allowTransparency', 766 complete; 767 768 if (!open) { 769 return; 770 } 771 772 function removeFilter() { // Needed for IE7 & IE8 in versions of jQuery prior to 1.7.2 773 if ($.support.opacity === false) { 774 $box[0].style.removeAttribute('filter'); 775 } 776 } 777 778 complete = function () { 779 clearTimeout(loadingTimer); 780 $loadingOverlay.hide(); 781 trigger(event_complete, settings.onComplete); 782 }; 783 784 785 $title.html(settings.title).add($loaded).show(); 786 787 if (total > 1) { // handle grouping 788 if (typeof settings.current === "string") { 789 $current.html(settings.current.replace('{current}', index + 1).replace('{total}', total)).show(); 790 } 791 792 $next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(sett
792ings.next); 793 $prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous); 794 795 slideshow(); 796 797 // Preloads images within a rel group 798 if (settings.preloading) { 799 $.each([getIndex(-1), getIndex(1)], function(){ 800 var src, 801 img, 802 i = $related[this], 803 data = $.data(i, colorbox); 804 805 if (data && data.href) { 806 src = data.href; 807 if ($.isFunction(src)) { 808 src = src.call(i); 809 } 810 } else { 811 src = $(i).attr('href'); 812 } 813 814 if (src && isImage(data, src)) { 815 src = retinaUrl(data, src); 816 img = document.createElement('img'); 817 img.src = src; 818 } 819 }); 820 } 821 } else { 822 $groupControls.hide(); 823 } 824 825 if (settings.iframe) { 826 iframe = $tag('iframe')[0]; 827 828 if (frameBorder in iframe) { 829 iframe[frameBorder] = 0; 830 } 831 832 if (allowTransparency in iframe) { 833 iframe[allowTransparency] = "true"; 834 } 835 836 if (!settings.scrolling) { 837 iframe.scrolling = "no"; 838 } 839 840 $(iframe) 841 .attr({ 842 src: settings.href, 843 name: (new Date()).getTime(), // give the iframe a unique name to prevent caching 844 'class': prefix + 'Iframe', 845 allowFullScreen : true, // allow HTML5 video to go fullscreen 846 webkitAllowFullScreen : true, 847 mozallowfullscreen : true 848 }) 849 .one('load', complete) 850 .appendTo($loaded); 851 852 $events.one(event_purge, function () { 853 iframe.src = "//about:blank"; 854 }); 855 856 if (settings.fastIframe) { 857 $(iframe).trigger('load'); 858 } 859 } else { 860 complete(); 861 } 862 863 if (settings.transition === 'fade') { 864 $box.fadeTo(speed, 1, removeFilter); 865 } else { 866 removeFilter(); 867 } 868 }; 869 870 if (settings.transition === 'fade') { 871 $box.fadeTo(speed, 0, function () { 872 publicMethod.position(0, callback); 873 }); 874 } else { 875 publicMethod.position(speed, callback); 876 } 877 }; 878 879 function load () { 880 var href, setResize, prep = publicMethod.prep, $inline, request = ++requests; 881 882 active = true; 883 884 photo = false; 885 886 element = $related[index]; 887 888 makeSettings(); 889 890 trigger(event_purge); 891 892 trigger(event_load, settings.onLoad); 893 894 settings.h = settings.height ? 895 setSize(settings.height, 'y') - loadedHeight - interfaceHeight : 896 settings.innerHeight && setSize(settings.innerHeight, 'y'); 897 898 settings.w = settings.width ? 899 setSize(settings.width, 'x') - loadedWidth - interfaceWidth : 900 settings.innerWidth && setSize(settings.innerWidth, 'x'); 901 902 // Sets the minimum dimensions for use in image scaling 903 settings.mw = settings.w; 904 settings.mh = settings.h; 905
906 // Re-evaluate the minimum width and height based on maxWidth and maxHeight values. 907 // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead. 908 if (settings.maxWidth) { 909 settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth; 910 settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw; 911 } 912 if (settings.maxHeight) { 913 settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight; 914 settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh; 915 } 916 917 href = settings.href; 918 919 loadingTimer = setTimeout(function () { 920 $loadingOverlay.show(); 921 }, 100); 922 923 if (settings.inline) { 924 // Inserts an empty placeholder where inline content is being pulled from. 925 // An event is bound to put inline content back when Colorbox closes or loads new content. 926 $inline = $tag(div).hide().insertBefore($(href)[0]); 927 928 $events.one(event_purge, function () { 929 $inline.replaceWith($loaded.children()); 930 }); 931 932 prep($(href)); 933 } else if (settings.iframe) { 934 // IFrame element won't be added to the DOM until it is ready to be displayed, 935 // to avoid problems with DOM-ready JS that might be trying to run in that iframe. 936 prep(" "); 937 } else if (settings.html) { 938 prep(settings.html); 939 } else if (isImage(settings, href)) { 940 941 href = retinaUrl(settings, href); 942 943 photo = document.createElement('img'); 944 945 $(photo) 946 .addClass(prefix + 'Photo') 947 .bind('error',function () { 948 settings.title = false; 949 prep($tag(div, 'Error').html(settings.imgError)); 950 }) 951 .one('load', function () { 952 var percent; 953 954 if (request !== requests) { 955 return; 956 } 957 958 $.each(['alt', 'longdesc', 'aria-describedby'], function(i,val){ 959 var attr = $(element).attr(val) || $(element).attr('data-'+val); 960 if (attr) { 961 photo.setAttribute(val, attr); 962 } 963 }); 964 965 if (settings.retinaImage && window.devicePixelRatio > 1) { 966 photo.height = photo.height / window.devicePixelRatio; 967 photo.width = photo.width / window.devicePixelRatio; 968 } 969 970 if (settings.scalePhotos) { 971 setResize = function () { 972 photo.height -= photo.height * percent; 973 photo.width -= photo.width * percent; 974 }; 975 if (settings.mw && photo.width > settings.mw) { 976 percent = (photo.width - settings.mw) / photo.width; 977 setResize(); 978 } 979 if (settings.mh && photo.height > settings.mh) { 980 percent = (photo.height - settings.mh) / photo.height; 981 setResize(); 982 } 983 } 984 985 if (settings.h) { 986 photo.style.marginTop = Math.max(settings.mh - photo.height, 0) / 2 + 'px'; 987 } 988 989 if ($related[1] && (settings.loop || $related[index + 1])) { 990 photo.style.cursor = 'pointer'; 991 photo.onclick = function () { 992 publicMethod.next(); 993 }; 994 } 995 996 photo.style.width = photo.width + 'px'; 997 photo.style.height = photo.height + 'px'; 998 999 setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise. 1000 prep(photo); 1001 }, 1); 1002 }); 1003 1004 setTimeout(function () { // A pause because Opera 10.6+ will sometimes not run the onload function otherwise. 1005 photo.src = href; 1006 }, 1); 1007 } else if (href) { 1008 $loadingBay.load(href, settings.data, function (data, status) { 1009 if (request === requests) { 1010 prep(status === 'error' ? $tag(div, 'Error').html(settings.xhrError) : $(this).contents()); 1011 } 1012 }); 1013 } 1014 } 1015 1016 // Navigates to the next page/image in a set. 1017 publicMethod.next = function () { 1018 if (!active && $related[1] && (settings.loop || $related[index + 1])) { 1019 index = getIndex(1); 1020 launch($related[index]); 1021 } 1022 }; 1023 1024 publicMethod.prev = function () { 1025 if (!active && $related[1] && (settings.loop || index)) { 1026 index = getIndex(-1); 1027 launch($related[index]); 1028 } 1029 }; 1030 1031 // Note: to use this within an iframe use the following format: parent.jQuery.colorbox.close(); 1032 publicMethod.close = function () { 1033 if (open && !closing) { 1034 1035 closing = true; 1036 1037 open = false; 1038 1039 trigger(event_cleanup, settings.onCleanup); 1040 1041 $window.unbind('.' + prefix); 1042 1043 $overlay.fadeTo(settings.fadeOut || 0, 0); 1044 1045 $box.stop().fadeTo(settings.fadeOut || 0, 0, function () { 1046 1047 $box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide(); 1048 1049 trigger(event_purge); 1050 1051 $loaded.empty().remove(); // Using empty first may prevent some IE7 issues. 1052 1053 setTimeout(function () { 1054 closing = false;
1055 trigger(event_closed, settings.onClosed); 1056 }, 1); 1057 }); 1058 } 1059 }; 1060 1061 // Removes changes Colorbox made to the document, but does not remove the plugin. 1062 publicMethod.remove = function () { 1063 if (!$box) { return; } 1064 1065 $box.stop(); 1066 $.colorbox.close(); 1067 $box.stop().remove(); 1068 $overlay.remove(); 1069 closing = false; 1070 $box = null; 1071 $('.' + boxElement) 1072 .removeData(colorbox) 1073 .removeClass(boxElement); 1074 1075 $(document).unbind('click.'+prefix); 1076 }; 1077 1078 // A method for fetching the current element Colorbox is referencing. 1079 // returns a jQuery object. 1080 publicMethod.element = function () { 1081 return $(element); 1082 }; 1083 1084 publicMethod.settings = defaults; 1085 1086}(jQuery, document, window));
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.