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