~zubairassad89/sahana-eden/vms_gsoc

« back to all changes in this revision

Viewing changes to static/scripts/S3/jquery.colorbox.js

  • Committer: Patricia Tressel
  • Date: 2010-08-15 13:34:25 UTC
  • mfrom: (768.1.211 eden)
  • Revision ID: tressel@phobos-20100815133425-z1eazm12k5pewg62
Merge from trunk, except for models/vol.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ColorBox v1.3.6 - a full featured, light-weight, customizable lightbox based on jQuery 1.3
 
1
// ColorBox v1.3.9 - a full featured, light-weight, customizable lightbox based on jQuery 1.3
2
2
// c) 2009 Jack Moore - www.colorpowered.com - jack@colorpowered.com
3
3
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
4
 
 
5
 
(function ($) {
6
 
        // Shortcuts (to increase compression)
7
 
        var colorbox = 'colorbox',
8
 
        hover = 'hover',
9
 
        TRUE = true,
10
 
        FALSE = false,
11
 
        cboxPublic,
12
 
        isIE = $.browser.msie && !$.support.opacity, // feature detection alone gave false positives in some browsers
 
4
(function ($, window) {
 
5
        
 
6
        var
 
7
        // ColorBox Default Settings.   
 
8
        // See http://colorpowered.com/colorbox for details.
 
9
        defaults = {
 
10
                transition: "elastic",
 
11
                speed: 300,
 
12
                width: false,
 
13
                initialWidth: "600",
 
14
                innerWidth: false,
 
15
                maxWidth: false,
 
16
                height: false,
 
17
                initialHeight: "450",
 
18
                innerHeight: false,
 
19
                maxHeight: false,
 
20
                scalePhotos: true,
 
21
                scrolling: true,
 
22
                inline: false,
 
23
                html: false,
 
24
                iframe: false,
 
25
                photo: false,
 
26
                href: false,
 
27
                title: false,
 
28
                rel: false,
 
29
                opacity: 0.9,
 
30
                preloading: true,
 
31
                current: "image {current} of {total}",
 
32
                previous: "previous",
 
33
                next: "next",
 
34
                close: "close",
 
35
                open: false,
 
36
                loop: true,
 
37
                slideshow: false,
 
38
                slideshowAuto: true,
 
39
                slideshowSpeed: 2500,
 
40
                slideshowStart: "start slideshow",
 
41
                slideshowStop: "stop slideshow",
 
42
                onOpen: false,
 
43
                onLoad: false,
 
44
                onComplete: false,
 
45
                onCleanup: false,
 
46
                onClosed: false,
 
47
                overlayClose: true,             
 
48
                escKey: true,
 
49
                arrowKey: true
 
50
        },
 
51
        
 
52
        // Abstracting the HTML and event identifiers for easy rebranding
 
53
        colorbox = 'colorbox',
 
54
        prefix = 'cbox',
 
55
        
 
56
        // Events       
 
57
        event_open = prefix + '_open',
 
58
        event_load = prefix + '_load',
 
59
        event_complete = prefix + '_complete',
 
60
        event_cleanup = prefix + '_cleanup',
 
61
        event_closed = prefix + '_closed',
 
62
        
 
63
        // Special Handling for IE
 
64
        isIE = $.browser.msie && !$.support.opacity, // feature detection alone gave a false positive on at least one phone browser and on some development versions of Chrome.
13
65
        isIE6 = isIE && $.browser.version < 7,
14
 
 
15
 
        // Event Strings (to increase compression)
16
 
        cbox_open = 'cbox_open',
17
 
        cbox_load = 'cbox_load',
18
 
        cbox_complete = 'cbox_complete',
19
 
        cbox_cleanup = 'cbox_cleanup',
20
 
        cbox_closed = 'cbox_closed',
21
 
        cbox_resize = 'resize.cbox_resize',
 
66
        event_ie6 = prefix + '_IE6',
22
67
 
23
68
        // Cached jQuery Object Variables
24
69
        $overlay,
25
 
        $cbox,
 
70
        $box,
26
71
        $wrap,
27
72
        $content,
28
73
        $topBorder,
34
79
        $loaded,
35
80
        $loadingBay,
36
81
        $loadingOverlay,
37
 
        $loadingGraphic,
38
82
        $title,
39
83
        $current,
40
84
        $slideshow,
54
98
        open,
55
99
        active,
56
100
        
57
 
        // ColorBox Default Settings.   
58
 
        // See http://colorpowered.com/colorbox for details.
59
 
        defaults = {
60
 
                transition: "elastic",
61
 
                speed: 350,
62
 
                width: FALSE,
63
 
                height: FALSE,
64
 
                innerWidth: FALSE,
65
 
                innerHeight: FALSE,
66
 
                initialWidth: "400",
67
 
                initialHeight: "400",
68
 
                maxWidth: FALSE,
69
 
                maxHeight: FALSE,
70
 
                scalePhotos: TRUE,
71
 
                scrolling: TRUE,
72
 
                inline: FALSE,
73
 
                html: FALSE,
74
 
                iframe: FALSE,
75
 
                photo: FALSE,
76
 
                href: FALSE,
77
 
                title: FALSE,
78
 
                rel: FALSE,
79
 
                opacity: 0.9,
80
 
                preloading: TRUE,
81
 
                current: "image {current} of {total}",
82
 
                previous: "previous",
83
 
                next: "next",
84
 
                close: "close",
85
 
                open: FALSE,
86
 
                overlayClose: TRUE,
87
 
                
88
 
                slideshow: FALSE,
89
 
                slideshowAuto: TRUE,
90
 
                slideshowSpeed: 2500,
91
 
                slideshowStart: "start slideshow",
92
 
                slideshowStop: "stop slideshow",
93
 
                
94
 
                onOpen: FALSE,
95
 
                onLoad: FALSE,
96
 
                onComplete: FALSE,
97
 
                onCleanup: FALSE,
98
 
                onClosed: FALSE
99
 
        };
 
101
        publicMethod,
 
102
        boxElement = prefix + 'Element';
100
103
        
101
104
        // ****************
102
105
        // HELPER FUNCTIONS
103
106
        // ****************
104
 
                
 
107
 
 
108
        // jQuery object generator to reduce code size
 
109
        function $div(id, css) { 
 
110
                id = id ? ' id="' + prefix + id + '"' : '';
 
111
                css = css ? ' style="' + css + '"' : '';
 
112
                return $('<div' + id + css + '/>');
 
113
        }
 
114
 
105
115
        // Convert % values to pixels
106
116
        function setSize(size, dimension) {
107
 
                dimension = dimension === 'x' ? $window.width() : $window.height();//document.documentElement.clientWidth : document.documentElement.clientHeight;
 
117
                dimension = dimension === 'x' ? $window.width() : $window.height();
108
118
                return (typeof size === 'string') ? Math.round((size.match(/%/) ? (dimension / 100) * parseInt(size, 10) : parseInt(size, 10))) : size;
109
119
        }
110
120
 
122
132
                            settings[i] = settings[i].call(element);
123
133
                        }
124
134
                }
125
 
                settings.rel = settings.rel || element.rel;
126
 
                settings.href = settings.href || element.href;
 
135
                settings.rel = settings.rel || element.rel || 'nofollow';
 
136
                settings.href = settings.href || $(element).attr('href');
127
137
                settings.title = settings.title || element.title;
128
138
        }
129
139
 
131
141
                
132
142
                element = elem;
133
143
                
134
 
                settings = $(element).data(colorbox);
 
144
                settings = $.extend({}, $(element).data(colorbox));
135
145
                
136
146
                process(); // Convert functions to their returned values.
137
147
                
138
 
                if (settings.rel && settings.rel !== 'nofollow') {
139
 
                        $related = $('.cboxElement').filter(function () {
 
148
                if (settings.rel !== 'nofollow') {
 
149
                        $related = $('.' + boxElement).filter(function () {
140
150
                                var relRelated = $(this).data(colorbox).rel || this.rel;
141
151
                                return (relRelated === settings.rel);
142
152
                        });
143
153
                        index = $related.index(element);
144
154
                        
145
155
                        // Check direct calls to ColorBox.
146
 
                        if (index < 0) {
 
156
                        if (index === -1) {
147
157
                                $related = $related.add(element);
148
158
                                index = $related.length - 1;
149
159
                        }
153
163
                }
154
164
                
155
165
                if (!open) {
156
 
                        open = TRUE;
157
 
                        
158
 
                        active = TRUE; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
 
166
                        open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
159
167
                        
160
168
                        bookmark = element;
161
169
                        
162
 
                        bookmark.blur(); // Remove the focus from the calling element.
163
 
                        
164
 
                        // Set Navigation Key Bindings
165
 
                        $(document).bind("keydown.cbox_close", function (e) {
166
 
                                if (e.keyCode === 27) {
167
 
                                        e.preventDefault();
168
 
                                        cboxPublic.close();
169
 
                                }
170
 
                        }).bind("keydown.cbox_arrows", function (e) {
171
 
                                if ($related.length > 1) {
172
 
                                        if (e.keyCode === 37) {
173
 
                                                e.preventDefault();
174
 
                                                $prev.click();
175
 
                                        } else if (e.keyCode === 39) {
176
 
                                                e.preventDefault();
177
 
                                                $next.click();
178
 
                                        }
179
 
                                }
180
 
                        });
181
 
                        
182
 
                        if (settings.overlayClose) {
183
 
                                $overlay.css({"cursor": "pointer"}).one('click', cboxPublic.close);
184
 
                        }
185
 
                        
186
 
                        $.event.trigger(cbox_open);
 
170
                        try {
 
171
                                bookmark.blur(); // Remove the focus from the calling element.
 
172
                        }catch (e) {}
 
173
                        
 
174
                        $.event.trigger(event_open);
187
175
                        if (settings.onOpen) {
188
176
                                settings.onOpen.call(element);
189
177
                        }
190
178
                        
191
 
                        $overlay.css({"opacity": settings.opacity}).show();
 
179
                        // +settings.opacity avoids a problem in IE when using non-zero-prefixed-string-values, like '.5'
 
180
                        $overlay.css({"opacity": +settings.opacity, "cursor": settings.overlayClose ? "pointer" : "auto"}).show();
192
181
                        
193
182
                        // Opens inital empty ColorBox prior to content being loaded.
194
183
                        settings.w = setSize(settings.initialWidth, 'x');
195
184
                        settings.h = setSize(settings.initialHeight, 'y');
196
 
                        cboxPublic.position(0);
 
185
                        publicMethod.position(0);
197
186
                        
198
187
                        if (isIE6) {
199
 
                                $window.bind('resize.cboxie6 scroll.cboxie6', function () {
 
188
                                $window.bind('resize.' + event_ie6 + ' scroll.' + event_ie6, function () {
200
189
                                        $overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()});
201
 
                                }).trigger("scroll.cboxie6");
 
190
                                }).trigger('scroll.' + event_ie6);
202
191
                        }
203
192
                }
204
193
                
206
195
                
207
196
                $close.html(settings.close).show();
208
197
                
209
 
                cboxPublic.slideshow();
 
198
                publicMethod.slideshow();
210
199
                
211
 
                cboxPublic.load();
 
200
                publicMethod.load();
212
201
        }
213
202
 
214
203
        // ****************
217
206
        // Usage from within an iframe: parent.$.fn.colorbox.close();
218
207
        // ****************
219
208
        
220
 
        cboxPublic = $.fn.colorbox = function (options, callback) {
 
209
        publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
221
210
                var $this = this;
222
211
                
223
 
                if (!$this.length) {
224
 
                        if ($this.selector === '') { // empty selector means a direct call, ie: $.fn.colorbox();
225
 
                                $this = $('<a/>');
226
 
                                options.open = TRUE;
227
 
                        } else { // else the selector didn't match anything, and colorbox should go ahead and return.
228
 
                                return this;
229
 
                        }
 
212
                if (!$this[0] && $this.selector) { // if a selector was given and it didn't match any elements, go ahead and exit.
 
213
                        return $this;
 
214
                }
 
215
                
 
216
                options = options || {};
 
217
                
 
218
                if (callback) {
 
219
                        options.onComplete = callback;
 
220
                }
 
221
                
 
222
                if (!$this[0] || $this.selector === undefined) { // detects $.colorbox() and $.fn.colorbox()
 
223
                        $this = $('<a/>');
 
224
                        options.open = true; // assume an immediate open
230
225
                }
231
226
                
232
227
                $this.each(function () {
233
 
                        var data = $.extend({}, $(this).data(colorbox) ? $(this).data(colorbox) : defaults, options);
234
 
                        
235
 
                        $(this).data(colorbox, data).addClass("cboxElement");
236
 
                        
237
 
                        if (callback) {
238
 
                                $(this).data(colorbox).onComplete = callback;
239
 
                        }
 
228
                        $(this).data(colorbox, $.extend({}, $(this).data(colorbox) || defaults, options)).addClass(boxElement);
240
229
                });
241
230
                
242
 
                if (options && options.open) {
243
 
                        launch($this);
 
231
                if (options.open) {
 
232
                        launch($this[0]);
244
233
                }
245
234
                
246
 
                return this;
 
235
                return $this;
247
236
        };
248
237
 
249
238
        // Initialize ColorBox: store common calculations, preload the interface graphics, append the html.
250
239
        // This preps colorbox for a speedy open when clicked, and lightens the burdon on the browser by only
251
240
        // having to run once, instead of each time colorbox is opened.
252
 
        cboxPublic.init = function () {
253
 
                
254
 
                // jQuery object generator to save a bit of space
255
 
                function $div(id) {
256
 
                        return $('<div id="cbox' + id + '"/>');
257
 
                }
258
 
                
 
241
        publicMethod.init = function () {
259
242
                // Create & Append jQuery Objects
260
243
                $window = $(window);
261
 
                $cbox = $('<div id="colorbox"/>');
262
 
                $overlay = $div("Overlay").hide();
 
244
                $box = $div().attr({id: colorbox, 'class': isIE ? prefix + 'IE' : ''});
 
245
                $overlay = $div("Overlay", isIE6 ? 'position:absolute' : '').hide();
 
246
                
263
247
                $wrap = $div("Wrapper");
264
248
                $content = $div("Content").append(
265
 
                        $loaded = $div("LoadedContent").css({width: 0, height: 0}),
266
 
                        $loadingOverlay = $div("LoadingOverlay"),
267
 
                        $loadingGraphic = $div("LoadingGraphic"),
 
249
                        $loaded = $div("LoadedContent", 'width:0; height:0'),
 
250
                        $loadingOverlay = $div("LoadingOverlay").add($div("LoadingGraphic")),
268
251
                        $title = $div("Title"),
269
252
                        $current = $div("Current"),
270
 
                        $slideshow = $div("Slideshow"),
271
253
                        $next = $div("Next"),
272
254
                        $prev = $div("Previous"),
 
255
                        $slideshow = $div("Slideshow"),
273
256
                        $close = $div("Close")
274
257
                );
275
258
                $wrap.append( // The 3x3 Grid that makes up ColorBox
276
 
                        $('<div/>').append(
 
259
                        $div().append(
277
260
                                $div("TopLeft"),
278
261
                                $topBorder = $div("TopCenter"),
279
262
                                $div("TopRight")
280
263
                        ),
281
 
                        $('<div/>').append(
 
264
                        $div().append(
282
265
                                $leftBorder = $div("MiddleLeft"),
283
266
                                $content,
284
267
                                $rightBorder = $div("MiddleRight")
285
268
                        ),
286
 
                        $('<div/>').append(
 
269
                        $div().append(
287
270
                                $div("BottomLeft"),
288
271
                                $bottomBorder = $div("BottomCenter"),
289
272
                                $div("BottomRight")
290
273
                        )
291
274
                ).children().children().css({'float': 'left'});
292
275
                
293
 
                $loadingBay = $("<div style='position:absolute; top:0; left:0; width:9999px; height:0;'/>");
294
 
                
295
 
                $('body').prepend($overlay, $cbox.append($wrap, $loadingBay));
296
 
                                
297
 
                if (isIE) {
298
 
                        $cbox.addClass('cboxIE');
299
 
                        if (isIE6) {
300
 
                                $overlay.css('position', 'absolute');
301
 
                        }
302
 
                }
303
 
                
304
 
                // Add rollover event to navigation elements
 
276
                $loadingBay = $div(false, 'position:absolute; width:9999px; visibility:hidden; display:none');
 
277
                
 
278
                $('body').prepend($overlay, $box.append($wrap, $loadingBay));
 
279
                
305
280
                $content.children()
306
 
                .bind('mouseover mouseout', function(){
307
 
                        $(this).toggleClass(hover);
308
 
                }).addClass(hover);
 
281
                .hover(function () {
 
282
                        $(this).addClass('hover');
 
283
                }, function () {
 
284
                        $(this).removeClass('hover');
 
285
                }).addClass('hover');
309
286
                
310
287
                // Cache values needed for size calculations
311
 
                interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(TRUE) - $content.height();//Subtraction needed for IE6
312
 
                interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(TRUE) - $content.width();
313
 
                loadedHeight = $loaded.outerHeight(TRUE);
314
 
                loadedWidth = $loaded.outerWidth(TRUE);
 
288
                interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();//Subtraction needed for IE6
 
289
                interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
 
290
                loadedHeight = $loaded.outerHeight(true);
 
291
                loadedWidth = $loaded.outerWidth(true);
315
292
                
316
293
                // Setting padding to remove the need to do size conversions during the animation step.
317
 
                $cbox.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth}).hide();
 
294
                $box.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth}).hide();
318
295
                
319
 
                // Setup button & key events.
320
 
                $next.click(cboxPublic.next);
321
 
                $prev.click(cboxPublic.prev);
322
 
                $close.click(cboxPublic.close);
 
296
                // Setup button events.
 
297
                $next.click(publicMethod.next);
 
298
                $prev.click(publicMethod.prev);
 
299
                $close.click(publicMethod.close);
323
300
                
324
301
                // Adding the 'hover' class allowed the browser to load the hover-state
325
302
                // background graphics.  The class can now can be removed.
326
 
                $content.children().removeClass(hover);
 
303
                $content.children().removeClass('hover');
327
304
                
328
 
                $('.cboxElement').live('click', function (e) {
329
 
                        if (e.button !== 0 && typeof e.button !== 'undefined') {// checks to see if it was a non-left mouse-click.
330
 
                                return TRUE;
 
305
                $('.' + boxElement).live('click', function (e) {
 
306
                        // checks to see if it was a non-left mouse-click and for clicks modified with ctrl, shift, or alt.
 
307
                        if ((e.button !== 0 && typeof e.button !== 'undefined') || e.ctrlKey || e.shiftKey || e.altKey) {
 
308
                                return true;
331
309
                        } else {
332
310
                                launch(this);                   
333
 
                                return FALSE;
334
 
                        }
335
 
                });
 
311
                                return false;
 
312
                        }
 
313
                });
 
314
                
 
315
                $overlay.click(function () {
 
316
                        if (settings.overlayClose) {
 
317
                                publicMethod.close();
 
318
                        }
 
319
                });
 
320
                
 
321
                // Set Navigation Key Bindings
 
322
                $(document).bind("keydown", function (e) {
 
323
                        if (open && settings.escKey && e.keyCode === 27) {
 
324
                                e.preventDefault();
 
325
                                publicMethod.close();
 
326
                        }
 
327
                        if (open && settings.arrowKey && !active && $related[1]) {
 
328
                                if (e.keyCode === 37 && (index || settings.loop)) {
 
329
                                        e.preventDefault();
 
330
                                        $prev.click();
 
331
                                } else if (e.keyCode === 39 && (index < $related.length - 1 || settings.loop)) {
 
332
                                        e.preventDefault();
 
333
                                        $next.click();
 
334
                                }
 
335
                        }
 
336
                });
 
337
        };
 
338
        
 
339
        publicMethod.remove = function () {
 
340
                $box.add($overlay).remove();
 
341
                $('.' + boxElement).die('click').removeData(colorbox).removeClass(boxElement);
336
342
        };
337
343
 
338
 
        cboxPublic.position = function (speed, loadedCallback) {
 
344
        publicMethod.position = function (speed, loadedCallback) {
339
345
                var
340
346
                animate_speed,
341
 
                winHeight = $window.height(),
342
347
                // keeps the top and left positions within the browser's viewport.
343
 
                posTop = Math.max(winHeight - settings.h - loadedHeight - interfaceHeight,0)/2 + $window.scrollTop(),
344
 
                posLeft = Math.max(document.documentElement.clientWidth - settings.w - loadedWidth - interfaceWidth,0)/2 + $window.scrollLeft();
 
348
                posTop = Math.max($window.height() - settings.h - loadedHeight - interfaceHeight, 0) / 2 + $window.scrollTop(),
 
349
                posLeft = Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2 + $window.scrollLeft();
345
350
                
346
351
                // setting the speed to 0 to reduce the delay between same-sized content.
347
 
                animate_speed = ($cbox.width() === settings.w+loadedWidth && $cbox.height() === settings.h+loadedHeight) ? 0 : speed;
 
352
                animate_speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed;
348
353
                
349
354
                // this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
350
355
                // but it has to be shrank down around the size of div#colorbox when it's done.  If not,
351
356
                // it can invoke an obscure IE bug when using iframes.
352
357
                $wrap[0].style.width = $wrap[0].style.height = "9999px";
353
358
                
354
 
                function modalDimensions (that) {
355
 
                        // loading overlay size has to be sure that IE6 uses the correct height.
 
359
                function modalDimensions(that) {
 
360
                        // loading overlay height has to be explicitly set for IE6.
356
361
                        $topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
357
 
                        $loadingGraphic[0].style.height = $loadingOverlay[0].style.height = $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
 
362
                        $loadingOverlay[0].style.height = $loadingOverlay[1].style.height = $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
358
363
                }
359
364
                
360
 
                $cbox.dequeue().animate({width:settings.w+loadedWidth, height:settings.h+loadedHeight, top:posTop, left:posLeft}, {duration: animate_speed,
361
 
                        complete: function(){
 
365
                $box.dequeue().animate({width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: posTop, left: posLeft}, {
 
366
                        duration: animate_speed,
 
367
                        complete: function () {
362
368
                                modalDimensions(this);
363
369
                                
364
 
                                active = FALSE;
 
370
                                active = false;
365
371
                                
366
372
                                // shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
367
 
                                $wrap[0].style.width = (settings.w+loadedWidth+interfaceWidth) + "px";
368
 
                                $wrap[0].style.height = (settings.h+loadedHeight+interfaceHeight) + "px";
 
373
                                $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
 
374
                                $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
369
375
                                
370
 
                                if (loadedCallback) {loadedCallback();}
 
376
                                if (loadedCallback) {
 
377
                                        loadedCallback();
 
378
                                }
371
379
                        },
372
 
                        step: function(){
 
380
                        step: function () {
373
381
                                modalDimensions(this);
374
382
                        }
375
383
                });
376
384
        };
377
385
 
378
 
        cboxPublic.resize = function (object) {
379
 
                if(!open){ return; }
380
 
                
381
 
                var topMargin,
382
 
                prev,
383
 
                prevSrc,
384
 
                next,
385
 
                nextSrc,
386
 
                photo,
387
 
                timeout,
388
 
                speed = settings.transition==="none" ? 0 : settings.speed;
389
 
                
390
 
                $window.unbind(cbox_resize);
391
 
                
392
 
                if(!object){
393
 
                        timeout = setTimeout(function(){ // timer allows IE to render the dimensions before attempting to calculate the height
 
386
        publicMethod.resize = function (options) {
 
387
                if (open) {
 
388
                        options = options || {};
 
389
                        
 
390
                        if (options.width) {
 
391
                                settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth;
 
392
                        }
 
393
                        if (options.innerWidth) {
 
394
                                settings.w = setSize(options.innerWidth, 'x');
 
395
                        }
 
396
                        $loaded.css({width: settings.w});
 
397
                        
 
398
                        if (options.height) {
 
399
                                settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight;
 
400
                        }
 
401
                        if (options.innerHeight) {
 
402
                                settings.h = setSize(options.innerHeight, 'y');
 
403
                        }
 
404
                        if (!options.innerHeight && !options.height) {                          
394
405
                                var $child = $loaded.wrapInner("<div style='overflow:auto'></div>").children(); // temporary wrapper to get an accurate estimate of just how high the total content should be.
395
406
                                settings.h = $child.height();
396
 
                                $loaded.css({height:settings.h});
397
407
                                $child.replaceWith($child.children()); // ditch the temporary wrapper div used in height calculation
398
 
                                cboxPublic.position(speed);
399
 
                        }, 1);
 
408
                        }
 
409
                        $loaded.css({height: settings.h});
 
410
                        
 
411
                        publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
 
412
                }
 
413
        };
 
414
 
 
415
        publicMethod.prep = function (object) {
 
416
                if (!open) {
400
417
                        return;
401
418
                }
402
419
                
 
420
                var photo,
 
421
                speed = settings.transition === "none" ? 0 : settings.speed;
 
422
                
 
423
                $window.unbind('resize.' + prefix);
403
424
                $loaded.remove();
404
 
                $loaded = $('<div id="cboxLoadedContent"/>').html(object);
 
425
                $loaded = $div('LoadedContent').html(object);
405
426
                
406
 
                function getWidth(){
 
427
                function getWidth() {
407
428
                        settings.w = settings.w || $loaded.width();
408
429
                        settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
409
430
                        return settings.w;
410
431
                }
411
 
                function getHeight(){
 
432
                function getHeight() {
412
433
                        settings.h = settings.h || $loaded.height();
413
434
                        settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
414
435
                        return settings.h;
415
436
                }
416
437
                
417
438
                $loaded.hide()
418
 
                .appendTo($loadingBay)// content has to be appended to the DOM for accurate size calculations.  Appended to an absolutely positioned element, rather than BODY, which avoids an extremely brief display of the vertical scrollbar in Firefox that can occur for a small minority of websites.
419
 
                .css({width:getWidth(), overflow:settings.scrolling ? 'auto' : 'hidden'})
420
 
                .css({height:getHeight()})// sets the height independently from the width in case the new width influences the value of height.
 
439
                .appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
 
440
                .css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
 
441
                .css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
421
442
                .prependTo($content);
422
443
                
423
 
                $('#cboxPhoto').css({cssFloat:'none'});// 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.
 
444
                $loadingBay.hide();
 
445
                
 
446
                $('#' + prefix + 'Photo').css({cssFloat: 'none'});// 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.
424
447
                
425
448
                // Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
426
449
                if (isIE6) {
427
 
                        $('select:not(#colorbox select)').filter(function(){
 
450
                        $('select').not($box.find('select')).filter(function () {
428
451
                                return this.style.visibility !== 'hidden';
429
 
                        }).css({'visibility':'hidden'}).one(cbox_cleanup, function(){
 
452
                        }).css({'visibility': 'hidden'}).one(event_cleanup, function () {
430
453
                                this.style.visibility = 'inherit';
431
454
                        });
432
455
                }
433
456
                                
434
 
                function setPosition (s) {
435
 
                        cboxPublic.position(s, function(){
436
 
                                if (!open) { return; }
 
457
                function setPosition(s) {
 
458
                        var prev, prevSrc, next, nextSrc, total = $related.length, loop = settings.loop;
 
459
                        publicMethod.position(s, function () {
 
460
                                function defilter() {
 
461
                                        if (isIE) {
 
462
                                                //IE adds a filter when ColorBox fades in and out that can cause problems if the loaded content contains transparent pngs.
 
463
                                                $box[0].style.removeAttribute("filter");
 
464
                                        }
 
465
                                }
 
466
                                
 
467
                                if (!open) {
 
468
                                        return;
 
469
                                }
437
470
                                
438
471
                                if (isIE) {
439
472
                                        //This fadeIn helps the bicubic resampling to kick-in.
440
 
                                        if( photo ){$loaded.fadeIn(100);}
441
 
                                        //IE adds a filter when ColorBox fades in and out that can cause problems if the loaded content contains transparent pngs.
442
 
                                        $cbox[0].style.removeAttribute("filter");
 
473
                                        if (photo) {
 
474
                                                $loaded.fadeIn(100);
 
475
                                        }
443
476
                                }
444
477
                                
445
478
                                //Waited until the iframe is added to the DOM & it is visible before setting the src.
446
479
                                //This increases compatability with pages using DOM dependent JavaScript.
447
 
                                if(settings.iframe){
448
 
                                        $loaded.append("<iframe id='cboxIframe'" + (settings.scrolling ? " " : "scrolling='no'") + " name='iframe_"+new Date().getTime()+"' frameborder=0 src='"+settings.href+"' " + (isIE ? "allowtransparency='true'" : '') + " />");
 
480
                                if (settings.iframe) {
 
481
                                        $("<iframe frameborder=0" + (settings.scrolling ? "" : " scrolling='no'") + (isIE ? " allowtransparency='true'" : '') + "/>")
 
482
                                        .attr({src: settings.href, name: new Date().getTime()})
 
483
                                        .appendTo($loaded);
449
484
                                }
450
485
                                
451
486
                                $loaded.show();
452
487
                                
453
488
                                $title.show().html(settings.title);
454
489
                                
455
 
                                if ($related.length>1) {
456
 
                                        $current.html(settings.current.replace(/\{current\}/, index+1).replace(/\{total\}/, $related.length)).show();
457
 
                                        $next.html(settings.next).show();
458
 
                                        $prev.html(settings.previous).show();
459
 
                                        
460
 
                                        if(settings.slideshow){
 
490
                                if (total > 1) { // handle grouping
 
491
                                        $current.html(settings.current.replace(/\{current\}/, index + 1).replace(/\{total\}/, total)).show();
 
492
                                        
 
493
                                        $next[(loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
 
494
                                        $prev[(loop || index) ? "show" : "hide"]().html(settings.previous);
 
495
                                        
 
496
                                        prev = index ? $related[index - 1] : $related[total - 1];
 
497
                                        next = index < total - 1 ? $related[index + 1] : $related[0];
 
498
                                        
 
499
                                        if (settings.slideshow) {
461
500
                                                $slideshow.show();
 
501
                                                if (index === total - 1 && !loop && $box.is('.' + prefix + 'Slideshow_on')) {
 
502
                                                        $slideshow.click();
 
503
                                                }
 
504
                                        }
 
505
                                        
 
506
                                        // Preloads images within a rel group
 
507
                                        if (settings.preloading) {
 
508
                                                nextSrc = $(next).data(colorbox).href || next.href;
 
509
                                                prevSrc = $(prev).data(colorbox).href || prev.href;
 
510
                                                
 
511
                                                if (isImage(nextSrc)) {
 
512
                                                        $('<img/>')[0].src = nextSrc;
 
513
                                                }
 
514
                                                
 
515
                                                if (isImage(prevSrc)) {
 
516
                                                        $('<img/>')[0].src = prevSrc;
 
517
                                                }
462
518
                                        }
463
519
                                }
464
520
                                
465
521
                                $loadingOverlay.hide();
466
 
                                $loadingGraphic.hide();
467
 
                                
468
 
                                $.event.trigger(cbox_complete);
 
522
                                
 
523
                                if (settings.transition === 'fade') {
 
524
                                        $box.fadeTo(speed, 1, function () {
 
525
                                                defilter();
 
526
                                        });
 
527
                                } else {
 
528
                                        defilter();
 
529
                                }
 
530
                                
 
531
                                $window.bind('resize.' + prefix, function () {
 
532
                                        publicMethod.position(0);
 
533
                                });
 
534
                                
 
535
                                $.event.trigger(event_complete);
469
536
                                if (settings.onComplete) {
470
537
                                        settings.onComplete.call(element);
471
538
                                }
472
 
                                
473
 
                                if (settings.transition === 'fade'){
474
 
                                        $cbox.fadeTo(speed, 1, function(){
475
 
                                                if(isIE){$cbox[0].style.removeAttribute("filter");}
476
 
                                        });
477
 
                                }
478
 
                                
479
 
                                $window.bind(cbox_resize, function(){
480
 
                                        cboxPublic.position(0);
481
 
                                });
482
539
                        });
483
540
                }
484
541
                
485
 
                if((settings.transition === 'fade' && $cbox.fadeTo(speed, 0, function(){setPosition(0);})) || setPosition(speed)){}
486
 
                
487
 
                // Preloads images within a rel group
488
 
                if (settings.preloading && $related.length>1) {
489
 
                        prev = index > 0 ? $related[index-1] : $related[$related.length-1];
490
 
                        next = index < $related.length-1 ? $related[index+1] : $related[0];
491
 
                        nextSrc = $(next).data(colorbox).href || next.href;
492
 
                        prevSrc = $(prev).data(colorbox).href || prev.href;
493
 
                        
494
 
                        if(isImage(nextSrc)){
495
 
                                $('<img />').attr('src', nextSrc);
496
 
                        }
497
 
                        
498
 
                        if(isImage(prevSrc)){
499
 
                                $('<img />').attr('src', prevSrc);
500
 
                        }
 
542
                if (settings.transition === 'fade') {
 
543
                        $box.fadeTo(speed, 0, function () {
 
544
                                setPosition(0);
 
545
                        });
 
546
                } else {
 
547
                        setPosition(speed);
501
548
                }
502
549
        };
503
550
 
504
 
        cboxPublic.load = function () {
505
 
                var href, img, setResize, resize = cboxPublic.resize;
506
 
                
507
 
                active = TRUE;
508
 
                
509
 
                /*
510
 
                 
511
 
                // I decided to comment this out because I can see it causing problems as users
512
 
                // really should just set the dimensions on their IMG elements instead,
513
 
                // but I'm leaving the code in as it may be useful to someone.
514
 
                // To use, uncomment the function and change 'if(textStatus === "success"){ resize(this); }'
515
 
                // to 'if(textStatus === "success"){ preload(this); }'
516
 
                
517
 
                // Preload loops through the HTML to find IMG elements and loads their sources.
518
 
                // This allows the resize method to accurately estimate the dimensions of the new content.
519
 
                function preload(html){
520
 
                        var
521
 
                        $ajax = $(html),
522
 
                        $imgs = $ajax.find('img'),
523
 
                        x = $imgs.length;
524
 
                        
525
 
                        function loadloop(){
526
 
                                var img = new Image();
527
 
                                x = x-1;
528
 
                                if(x >= 0){
529
 
                                        img.onload = loadloop;
530
 
                                        img.src = $imgs[x].src;
531
 
                                } else {
532
 
                                        resize($ajax);
533
 
                                }
534
 
                        }
535
 
                        
536
 
                        loadloop();
537
 
                }
538
 
                */
 
551
        publicMethod.load = function () {
 
552
                var href, img, setResize, prep = publicMethod.prep;
 
553
                
 
554
                active = true;
539
555
                
540
556
                element = $related[index];
541
557
                
542
 
                settings = $(element).data(colorbox);
 
558
                settings = $.extend({}, $(element).data(colorbox));
543
559
                
544
560
                //convert functions to static values
545
561
                process();
546
562
                
547
 
                $.event.trigger(cbox_load);
 
563
                $.event.trigger(event_load);
548
564
                if (settings.onLoad) {
549
565
                        settings.onLoad.call(element);
550
566
                }
551
567
                
552
 
                // Evaluate the height based on the optional height and width settings.
553
568
                settings.h = settings.height ?
554
569
                                setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
555
 
                                settings.innerHeight ?
556
 
                                        setSize(settings.innerHeight, 'y') :
557
 
                                        FALSE;
 
570
                                settings.innerHeight && setSize(settings.innerHeight, 'y');
 
571
                
558
572
                settings.w = settings.width ?
559
573
                                setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
560
 
                                settings.innerWidth ?
561
 
                                        setSize(settings.innerWidth, 'x') :
562
 
                                        FALSE;
 
574
                                settings.innerWidth && setSize(settings.innerWidth, 'x');
563
575
                
564
576
                // Sets the minimum dimensions for use in image scaling
565
577
                settings.mw = settings.w;
567
579
                
568
580
                // Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
569
581
                // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
570
 
                if(settings.maxWidth){
 
582
                if (settings.maxWidth) {
571
583
                        settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
572
584
                        settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
573
585
                }
574
 
                if(settings.maxHeight){
 
586
                if (settings.maxHeight) {
575
587
                        settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
576
588
                        settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
577
589
                }
579
591
                href = settings.href;
580
592
                
581
593
                $loadingOverlay.show();
582
 
                $loadingGraphic.show();
583
594
                
584
595
                if (settings.inline) {
585
596
                        // Inserts an empty placeholder where inline content is being pulled from.
586
597
                        // An event is bound to put inline content back when ColorBox closes or loads new content.
587
 
                        $('<div id="cboxInlineTemp" />').hide().insertBefore($(href)[0]).bind(cbox_load+' '+cbox_cleanup, function(){
 
598
                        $div('InlineTemp').hide().insertBefore($(href)[0]).bind(event_load + ' ' + event_cleanup, function () {
588
599
                                $(this).replaceWith($loaded.children());
589
600
                        });
590
 
                        resize($(href));
 
601
                        prep($(href));
591
602
                } else if (settings.iframe) {
592
603
                        // IFrame element won't be added to the DOM until it is ready to be displayed,
593
604
                        // to avoid problems with DOM-ready JS that might be trying to run in that iframe.
594
 
                        resize(" ");
 
605
                        prep(" ");
595
606
                } else if (settings.html) {
596
 
                        resize(settings.html);
597
 
                } else if (isImage(href)){
 
607
                        prep(settings.html);
 
608
                } else if (isImage(href)) {
598
609
                        img = new Image();
599
 
                        img.onload = function(){
 
610
                        img.onload = function () {
600
611
                                var percent;
601
612
                                
602
613
                                img.onload = null;
603
 
                                
604
 
                                img.id = 'cboxPhoto';
605
 
                                
606
 
                                $(img).css({margin:'auto', border:'none', display:'block', cssFloat:'left'});
607
 
                                
608
 
                                if(settings.scalePhotos){
609
 
                                        setResize = function(){
 
614
                                img.id = prefix + 'Photo';
 
615
                                $(img).css({margin: 'auto', border: 'none', display: 'block', cssFloat: 'left'});
 
616
                                
 
617
                                if (settings.scalePhotos) {
 
618
                                        setResize = function () {
610
619
                                                img.height -= img.height * percent;
611
620
                                                img.width -= img.width * percent;       
612
621
                                        };
613
 
                                        if(settings.mw && img.width > settings.mw){
 
622
                                        if (settings.mw && img.width > settings.mw) {
614
623
                                                percent = (img.width - settings.mw) / img.width;
615
624
                                                setResize();
616
625
                                        }
617
 
                                        if(settings.mh && img.height > settings.mh){
 
626
                                        if (settings.mh && img.height > settings.mh) {
618
627
                                                percent = (img.height - settings.mh) / img.height;
619
628
                                                setResize();
620
629
                                        }
621
630
                                }
622
631
                                
623
632
                                if (settings.h) {
624
 
                                        img.style.marginTop = Math.max(settings.h - img.height,0)/2 + 'px';
625
 
                                }
626
 
                                
627
 
                                resize(img);
628
 
                                
629
 
                                if($related.length > 1){
630
 
                                        $(img).css({cursor:'pointer'}).click(cboxPublic.next);
631
 
                                }
632
 
                                
633
 
                                if(isIE){
634
 
                                        img.style.msInterpolationMode='bicubic';
 
633
                                        img.style.marginTop = Math.max(settings.h - img.height, 0) / 2 + 'px';
 
634
                                }
 
635
                                
 
636
                                setTimeout(function () { // Chrome will sometimes report a 0 by 0 size if there isn't pause in execution
 
637
                                        prep(img);
 
638
                                }, 1);
 
639
                                
 
640
                                if ($related[1] && (index < $related.length - 1 || settings.loop)) {
 
641
                                        $(img).css({cursor: 'pointer'}).click(publicMethod.next);
 
642
                                }
 
643
                                
 
644
                                if (isIE) {
 
645
                                        img.style.msInterpolationMode = 'bicubic';
635
646
                                }
636
647
                        };
637
648
                        img.src = href;
638
649
                } else {
639
 
                        $('<div />').appendTo($loadingBay).load(href, function(data, textStatus){
640
 
                                if(textStatus === "success"){
641
 
                                        resize(this);
642
 
                                } else {
643
 
                                        resize($("<p>Request unsuccessful.</p>"));
644
 
                                }
 
650
                        $div().appendTo($loadingBay).load(href, function (data, status, xhr) {
 
651
                                prep(status === 'error' ? 'Request unsuccessful: ' + xhr.statusText : this);
645
652
                        });
646
653
                }
647
654
        };
648
655
 
649
656
        // Navigates to the next page/image in a set.
650
 
        cboxPublic.next = function () {
651
 
                if(!active){
652
 
                        index = index < $related.length-1 ? index+1 : 0;
653
 
                        cboxPublic.load();
 
657
        publicMethod.next = function () {
 
658
                if (!active) {
 
659
                        index = index < $related.length - 1 ? index + 1 : 0;
 
660
                        publicMethod.load();
654
661
                }
655
662
        };
656
663
        
657
 
        cboxPublic.prev = function () {
658
 
                if(!active){
659
 
                        index = index > 0 ? index-1 : $related.length-1;
660
 
                        cboxPublic.load();
 
664
        publicMethod.prev = function () {
 
665
                if (!active) {
 
666
                        index = index ? index - 1 : $related.length - 1;
 
667
                        publicMethod.load();
661
668
                }
662
669
        };
663
670
 
664
 
        cboxPublic.slideshow = function () {
665
 
                var stop, timeOut, className = 'cboxSlideshow_';
 
671
        publicMethod.slideshow = function () {
 
672
                var stop, timeOut, className = prefix + 'Slideshow_';
666
673
                
667
 
                $slideshow.bind(cbox_closed, function(){
 
674
                $slideshow.bind(event_closed, function () {
668
675
                        $slideshow.unbind();
669
676
                        clearTimeout(timeOut);
670
 
                        $cbox.removeClass(className+"off"+" "+className+"on");
 
677
                        $box.removeClass(className + "off " + className + "on");
671
678
                });
672
679
                
673
 
                function start(){
 
680
                function start() {
674
681
                        $slideshow
675
682
                        .text(settings.slideshowStop)
676
 
                        .bind(cbox_complete, function(){
677
 
                                timeOut = setTimeout(cboxPublic.next, settings.slideshowSpeed);
 
683
                        .bind(event_complete, function () {
 
684
                                timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
678
685
                        })
679
 
                        .bind(cbox_load, function(){
 
686
                        .bind(event_load, function () {
680
687
                                clearTimeout(timeOut);  
681
 
                        }).one("click", function(){
 
688
                        }).one("click", function () {
682
689
                                stop();
683
 
                                $(this).removeClass(hover);
684
690
                        });
685
 
                        $cbox.removeClass(className+"off").addClass(className+"on");
 
691
                        $box.removeClass(className + "off").addClass(className + "on");
686
692
                }
687
693
                
688
 
                stop = function(){
 
694
                stop = function () {
689
695
                        clearTimeout(timeOut);
690
696
                        $slideshow
691
697
                        .text(settings.slideshowStart)
692
 
                        .unbind(cbox_complete+' '+cbox_load)
693
 
                        .one("click", function(){
 
698
                        .unbind(event_complete + ' ' + event_load)
 
699
                        .one("click", function () {
694
700
                                start();
695
 
                                timeOut = setTimeout(cboxPublic.next, settings.slideshowSpeed);
696
 
                                $(this).removeClass(hover);
 
701
                                timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
697
702
                        });
698
 
                        $cbox.removeClass(className+"on").addClass(className+"off");
 
703
                        $box.removeClass(className + "on").addClass(className + "off");
699
704
                };
700
705
                
701
 
                if(settings.slideshow && $related.length>1){
702
 
                        if(settings.slideshowAuto){
 
706
                if (settings.slideshow && $related[1]) {
 
707
                        if (settings.slideshowAuto) {
703
708
                                start();
704
709
                        } else {
705
710
                                stop();
708
713
        };
709
714
 
710
715
        // Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
711
 
        cboxPublic.close = function () {
712
 
                
713
 
                $.event.trigger(cbox_cleanup);
714
 
                if (settings.onCleanup) {
715
 
                        settings.onCleanup.call(element);
 
716
        publicMethod.close = function () {
 
717
                if (open) {
 
718
                        open = false;
 
719
                        
 
720
                        $.event.trigger(event_cleanup);
 
721
                        
 
722
                        if (settings.onCleanup) {
 
723
                                settings.onCleanup.call(element);
 
724
                        }
 
725
                        
 
726
                        $window.unbind('.' + prefix + ' .' + event_ie6);
 
727
                        
 
728
                        $overlay.fadeTo('fast', 0);
 
729
                        
 
730
                        $box.stop().fadeTo('fast', 0, function () {
 
731
                                $box.find('iframe').attr('src', 'about:blank'); // change the location of the iframe to avoid a problem in IE with flash objects not clearing.
 
732
                                
 
733
                                $loaded.remove();
 
734
                                
 
735
                                $box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
 
736
                                
 
737
                                try {
 
738
                                        bookmark.focus();
 
739
                                } catch (e) {
 
740
                                        // do nothing
 
741
                                }
 
742
                                
 
743
                                setTimeout(function () {
 
744
                                        $.event.trigger(event_closed);
 
745
                                        if (settings.onClosed) {
 
746
                                                settings.onClosed.call(element);
 
747
                                        }
 
748
                                }, 1);
 
749
                        });
716
750
                }
717
 
                
718
 
                open = FALSE;
719
 
                $(document).unbind("keydown.cbox_close keydown.cbox_arrows");
720
 
                $window.unbind(cbox_resize+' resize.cboxie6 scroll.cboxie6');
721
 
                $overlay.css({cursor: 'auto'}).fadeOut('fast');
722
 
                
723
 
                $cbox
724
 
                .stop(TRUE, FALSE)
725
 
                .fadeOut('fast', function () {
726
 
                        $('#colorbox iframe').attr('src', 'about:blank');
727
 
                        $loaded.remove();
728
 
                        $cbox.css({'opacity': 1});
729
 
                        
730
 
                        try{
731
 
                                bookmark.focus();
732
 
                        } catch (er){
733
 
                                // do nothing
734
 
                        }
735
 
                        
736
 
                        $.event.trigger(cbox_closed);
737
 
                        if (settings.onClosed) {
738
 
                                settings.onClosed.call(element);
739
 
                        }
740
 
                });
741
751
        };
742
752
 
743
753
        // A method for fetching the current element ColorBox is referencing.
744
754
        // returns a jQuery object.
745
 
        cboxPublic.element = function(){ return $(element); };
 
755
        publicMethod.element = function () {
 
756
                return $(element);
 
757
        };
746
758
 
747
 
        cboxPublic.settings = defaults;
 
759
        publicMethod.settings = defaults;
748
760
 
749
761
        // Initializes ColorBox when the DOM has loaded
750
 
        $(cboxPublic.init);
 
762
        $(publicMethod.init);
751
763
 
752
 
}(jQuery));
 
764
}(jQuery, this));