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