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