PageSourceSearch

https://www.visitfuerteventura.com/themes/custom/hic_front_theme/js/colorbox/jquery.colorbox.js?v=1.6.4

js visitfuerteventura.com collected 2026-10-02 11:35:40 UTC 38,092 bytes, 1,106 lines download raw bytes

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