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