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