|
1 |
| -// ColorBox v1.3.18 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+ |
2 |
| -// Copyright (c) 2011 Jack Moore - jack@colorpowered.com |
3 |
| -// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php |
| 1 | +// ColorBox v1.3.19 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+ |
| 2 | +// Copyright (c) 2011 Jack Moore - jacklmoore.com |
| 3 | +// License: http://www.opensource.org/licenses/mit-license.php |
4 | 4 |
|
5 | 5 | (function ($, document, window) {
|
6 | 6 | var
|
|
35 | 35 | close: "close",
|
36 | 36 | open: false,
|
37 | 37 | returnFocus: true,
|
| 38 | + reposition: true, |
38 | 39 | loop: true,
|
39 | 40 | slideshow: false,
|
40 | 41 | slideshowAuto: true,
|
|
71 | 72 | event_purge = prefix + '_purge',
|
72 | 73 |
|
73 | 74 | // Special Handling for IE
|
74 |
| - isIE = $.browser.msie && !$.support.opacity, // Detects IE6,7,8. IE9 supports opacity. Feature detection alone gave a false positive on at least one phone browser and on some development versions of Chrome, hence the user-agent test. |
75 |
| - isIE6 = isIE && $.browser.version < 7, |
| 75 | + isIE = !$.support.opacity && !$.support.style, // IE7 & IE8 |
| 76 | + isIE6 = isIE && !window.XMLHttpRequest, // IE6 |
76 | 77 | event_ie6 = prefix + '_IE6',
|
77 |
| - |
| 78 | + |
78 | 79 | // Cached jQuery Object Variables
|
79 | 80 | $overlay,
|
80 | 81 | $box,
|
|
119 | 120 |
|
120 | 121 | // Convience function for creating new jQuery objects
|
121 | 122 | function $tag(tag, id, css) {
|
122 |
| - var element = document.createElement(tag); |
123 |
| - |
124 |
| - if (id) { |
125 |
| - element.id = prefix + id; |
126 |
| - } |
127 |
| - |
128 |
| - if (css) { |
129 |
| - element.style.cssText = css; |
130 |
| - } |
131 |
| - |
132 |
| - return $(element); |
| 123 | + var element = document.createElement(tag); |
| 124 | + |
| 125 | + if (id) { |
| 126 | + element.id = prefix + id; |
| 127 | + } |
| 128 | + |
| 129 | + if (css) { |
| 130 | + element.style.cssText = css; |
| 131 | + } |
| 132 | + |
| 133 | + return $(element); |
133 | 134 | }
|
134 | 135 |
|
135 | 136 | // Determine the next and previous members in a group.
|
|
195 | 196 | .text(settings.slideshowStop)
|
196 | 197 | .unbind(click)
|
197 | 198 | .bind(event_complete, function () {
|
198 |
| - if (index < $related.length - 1 || settings.loop) { |
| 199 | + if (settings.loop || $related[index + 1]) { |
199 | 200 | timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
|
200 | 201 | }
|
201 | 202 | })
|
|
260 | 261 | $box.show();
|
261 | 262 |
|
262 | 263 | if (settings.returnFocus) {
|
263 |
| - try { |
264 |
| - element.blur(); |
265 |
| - $(element).one(event_closed, function () { |
266 |
| - try { |
267 |
| - this.focus(); |
268 |
| - } catch (e) { |
269 |
| - // do nothing |
270 |
| - } |
271 |
| - }); |
272 |
| - } catch (e) { |
273 |
| - // do nothing |
274 |
| - } |
| 264 | + $(element).blur().one(event_closed, function () { |
| 265 | + $(this).focus(); |
| 266 | + }); |
275 | 267 | }
|
276 | 268 |
|
277 | 269 | // +settings.opacity avoids a problem in IE when using non-zero-prefixed-string-values, like '.5'
|
|
327 | 319 |
|
328 | 320 | $this.each(function () {
|
329 | 321 | $.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options));
|
330 |
| - $(this).addClass(boxElement); |
331 |
| - }); |
| 322 | + }).addClass(boxElement); |
332 | 323 |
|
333 | 324 | if (($.isFunction(options.open) && options.open.call($this)) || options.open) {
|
334 | 325 | launch($this[0]);
|
|
342 | 333 | // having to run once, instead of each time colorbox is opened.
|
343 | 334 | publicMethod.init = function () {
|
344 | 335 | if (!$box) {
|
345 |
| - |
| 336 | + |
346 | 337 | // If the body is not present yet, wait for DOM ready
|
347 | 338 | if (!$('body')[0]) {
|
348 | 339 | $(publicMethod.init);
|
|
385 | 376 |
|
386 | 377 | $loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none');
|
387 | 378 |
|
388 |
| - $('body').prepend($overlay, $box.append($wrap, $loadingBay)); |
| 379 | + $('body').append($overlay, $box.append($wrap, $loadingBay)); |
389 | 380 |
|
390 | 381 | // Cache values needed for size calculations
|
391 | 382 | interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();//Subtraction needed for IE6
|
|
443 | 434 | };
|
444 | 435 |
|
445 | 436 | publicMethod.position = function (speed, loadedCallback) {
|
446 |
| - var top = 0, left = 0, offset = $box.offset(); |
| 437 | + var |
| 438 | + top = 0, |
| 439 | + left = 0, |
| 440 | + offset = $box.offset(), |
| 441 | + scrollTop = $window.scrollTop(), |
| 442 | + scrollLeft = $window.scrollLeft(); |
447 | 443 |
|
448 | 444 | $window.unbind('resize.' + prefix);
|
449 | 445 |
|
450 | 446 | // remove the modal so that it doesn't influence the document width/height
|
451 |
| - $box.css({top: -99999, left: -99999}); |
| 447 | + $box.css({top: -9e4, left: -9e4}); |
452 | 448 |
|
453 | 449 | if (settings.fixed && !isIE6) {
|
| 450 | + offset.top -= scrollTop; |
| 451 | + offset.left -= scrollLeft; |
454 | 452 | $box.css({position: 'fixed'});
|
455 | 453 | } else {
|
456 |
| - top = $window.scrollTop(); |
457 |
| - left = $window.scrollLeft(); |
| 454 | + top = scrollTop; |
| 455 | + left = scrollLeft; |
458 | 456 | $box.css({position: 'absolute'});
|
459 | 457 | }
|
460 | 458 |
|
|
474 | 472 | } else {
|
475 | 473 | top += Math.round(Math.max($window.height() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
|
476 | 474 | }
|
477 |
| - |
| 475 | + |
478 | 476 | $box.css({top: offset.top, left: offset.left});
|
479 |
| - |
| 477 | + |
480 | 478 | // setting the speed to 0 to reduce the delay between same-sized content.
|
481 | 479 | speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed || 0;
|
482 | 480 |
|
|
486 | 484 | $wrap[0].style.width = $wrap[0].style.height = "9999px";
|
487 | 485 |
|
488 | 486 | function modalDimensions(that) {
|
489 |
| - // loading overlay height has to be explicitly set for IE6. |
490 | 487 | $topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
|
491 |
| - $loadingOverlay[0].style.height = $loadingOverlay[1].style.height = $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height; |
| 488 | + $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height; |
492 | 489 | }
|
493 | 490 |
|
494 | 491 | $box.dequeue().animate({width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: top, left: left}, {
|
|
501 | 498 | // shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
|
502 | 499 | $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
|
503 | 500 | $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
|
504 |
| - |
| 501 | + |
| 502 | + if (settings.reposition) { |
| 503 | + setTimeout(function () { // small delay before binding onresize due to an IE8 bug. |
| 504 | + $window.bind('resize.' + prefix, publicMethod.position); |
| 505 | + }, 1); |
| 506 | + } |
| 507 | + |
505 | 508 | if (loadedCallback) {
|
506 | 509 | loadedCallback();
|
507 | 510 | }
|
508 |
| - |
509 |
| - setTimeout(function () { // small delay before binding onresize due to an IE8 bug. |
510 |
| - $window.bind('resize.' + prefix, publicMethod.position); |
511 |
| - }, 1); |
512 | 511 | },
|
513 | 512 | step: function () {
|
514 | 513 | modalDimensions(this);
|
|
633 | 632 | getIndex(-1),
|
634 | 633 | getIndex(1)
|
635 | 634 | ];
|
636 |
| - while ((i = $related[preload.pop()])) { |
| 635 | + while (i = $related[preload.pop()]) { |
637 | 636 | src = $.data(i, colorbox).href || i.href;
|
638 | 637 | if ($.isFunction(src)) {
|
639 | 638 | src = src.call(i);
|
|
780 | 779 | photo.style.marginTop = Math.max(settings.h - photo.height, 0) / 2 + 'px';
|
781 | 780 | }
|
782 | 781 |
|
783 |
| - if ($related[1] && (index < $related.length - 1 || settings.loop)) { |
| 782 | + if ($related[1] && (settings.loop || $related[index + 1])) { |
784 | 783 | photo.style.cursor = 'pointer';
|
785 | 784 | photo.onclick = function () {
|
786 | 785 | publicMethod.next();
|
|
808 | 807 |
|
809 | 808 | // Navigates to the next page/image in a set.
|
810 | 809 | publicMethod.next = function () {
|
811 |
| - if (!active && $related[1] && (index < $related.length - 1 || settings.loop)) { |
| 810 | + if (!active && $related[1] && (settings.loop || $related[index + 1])) { |
812 | 811 | index = getIndex(1);
|
813 | 812 | publicMethod.load();
|
814 | 813 | }
|
815 | 814 | };
|
816 | 815 |
|
817 | 816 | publicMethod.prev = function () {
|
818 |
| - if (!active && $related[1] && (index || settings.loop)) { |
| 817 | + if (!active && $related[1] && (settings.loop || index)) { |
819 | 818 | index = getIndex(-1);
|
820 | 819 | publicMethod.load();
|
821 | 820 | }
|
|
858 | 857 | };
|
859 | 858 |
|
860 | 859 | publicMethod.settings = defaults;
|
861 |
| - |
| 860 | + |
862 | 861 | // Bind the live event before DOM-ready for maximum performance in IE6 & 7.
|
863 | 862 | $('.' + boxElement, document).live('click', function (e) {
|
864 | 863 | // ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt.
|
|
0 commit comments