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