zfben_rails_assets 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,872 @@
1
+ // ColorBox v1.3.17.1 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
2
+ // Copyright (c) 2011 Jack Moore - jack@colorpowered.com
3
+ // Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
4
+ (function ($, document, window) {
5
+ var
6
+ // ColorBox Default Settings.
7
+ // See http://colorpowered.com/colorbox for details.
8
+ defaults = {
9
+ transition: "elastic",
10
+ speed: 300,
11
+ width: false,
12
+ initialWidth: "600",
13
+ innerWidth: false,
14
+ maxWidth: false,
15
+ height: false,
16
+ initialHeight: "450",
17
+ innerHeight: false,
18
+ maxHeight: false,
19
+ scalePhotos: true,
20
+ scrolling: true,
21
+ inline: false,
22
+ html: false,
23
+ iframe: false,
24
+ fastIframe: true,
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
+ returnFocus: true,
37
+ loop: true,
38
+ slideshow: false,
39
+ slideshowAuto: true,
40
+ slideshowSpeed: 2500,
41
+ slideshowStart: "start slideshow",
42
+ slideshowStop: "stop slideshow",
43
+ onOpen: false,
44
+ onLoad: false,
45
+ onComplete: false,
46
+ onCleanup: false,
47
+ onClosed: false,
48
+ overlayClose: true,
49
+ escKey: true,
50
+ arrowKey: true,
51
+ top: false,
52
+ bottom: false,
53
+ left: false,
54
+ right: false,
55
+ fixed: false,
56
+ data: false
57
+ },
58
+
59
+ // Abstracting the HTML and event identifiers for easy rebranding
60
+ colorbox = 'colorbox',
61
+ prefix = 'cbox',
62
+
63
+ // Events
64
+ event_open = prefix + '_open',
65
+ event_load = prefix + '_load',
66
+ event_complete = prefix + '_complete',
67
+ event_cleanup = prefix + '_cleanup',
68
+ event_closed = prefix + '_closed',
69
+ event_purge = prefix + '_purge',
70
+
71
+ // Special Handling for IE
72
+ isIE = $.browser.msie && !$.support.opacity, // Detects IE6,7,8. IE9 supports opacity. Feature detection alone gave a false positive on at least one phone browser and on some development versions of Chrome, hence the user-agent test.
73
+ isIE6 = isIE && $.browser.version < 7,
74
+ event_ie6 = prefix + '_IE6',
75
+
76
+ // Cached jQuery Object Variables
77
+ $overlay,
78
+ $box,
79
+ $wrap,
80
+ $content,
81
+ $topBorder,
82
+ $leftBorder,
83
+ $rightBorder,
84
+ $bottomBorder,
85
+ $related,
86
+ $window,
87
+ $loaded,
88
+ $loadingBay,
89
+ $loadingOverlay,
90
+ $title,
91
+ $current,
92
+ $slideshow,
93
+ $next,
94
+ $prev,
95
+ $close,
96
+ $groupControls,
97
+
98
+ // Variables for cached values or use across multiple functions
99
+ settings = {},
100
+ interfaceHeight,
101
+ interfaceWidth,
102
+ loadedHeight,
103
+ loadedWidth,
104
+ element,
105
+ index,
106
+ photo,
107
+ open,
108
+ active,
109
+ closing,
110
+ handler,
111
+ loadingTimer,
112
+
113
+ publicMethod,
114
+ boxElement = prefix + 'Element';
115
+
116
+ // ****************
117
+ // HELPER FUNCTIONS
118
+ // ****************
119
+
120
+ // jQuery object generator to reduce code size
121
+ function $div(id, cssText) {
122
+ var div = document.createElement('div');
123
+ if (id) {
124
+ div.id = prefix + id;
125
+ }
126
+ div.style.cssText = cssText || '';
127
+ return $(div);
128
+ }
129
+
130
+ // Convert % values to pixels
131
+ function setSize(size, dimension) {
132
+ dimension = dimension === 'x' ? $window.width() : $window.height();
133
+ return (typeof size === 'string') ? Math.round((/%/.test(size) ? (dimension / 100) * parseInt(size, 10) : parseInt(size, 10))) : size;
134
+ }
135
+
136
+ // Checks an href to see if it is a photo.
137
+ // There is a force photo option (photo: true) for hrefs that cannot be matched by this regex.
138
+ function isImage(url) {
139
+ return settings.photo || /\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(url);
140
+ }
141
+
142
+ // Assigns function results to their respective settings. This allows functions to be used as values.
143
+ function process(settings) {
144
+ for (var i in settings) {
145
+ if ($.isFunction(settings[i]) && i.substring(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time.
146
+ settings[i] = settings[i].call(element);
147
+ }
148
+ }
149
+
150
+ settings.rel = settings.rel || element.rel || 'nofollow';
151
+ settings.href = settings.href || $(element).attr('href');
152
+ settings.title = settings.title || element.title;
153
+
154
+ if (typeof settings.href === "string") {
155
+ settings.href = $.trim(settings.href);
156
+ }
157
+ }
158
+
159
+ function trigger(event, callback) {
160
+ if (callback) {
161
+ callback.call(element);
162
+ }
163
+ $.event.trigger(event);
164
+ }
165
+
166
+ // Slideshow functionality
167
+ function slideshow() {
168
+ var
169
+ timeOut,
170
+ className = prefix + "Slideshow_",
171
+ click = "click." + prefix,
172
+ start,
173
+ stop,
174
+ clear;
175
+
176
+ if (settings.slideshow && $related[1]) {
177
+ start = function () {
178
+ $slideshow
179
+ .text(settings.slideshowStop)
180
+ .unbind(click)
181
+ .bind(event_complete, function () {
182
+ if (index < $related.length - 1 || settings.loop) {
183
+ timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
184
+ }
185
+ })
186
+ .bind(event_load, function () {
187
+ clearTimeout(timeOut);
188
+ })
189
+ .one(click + ' ' + event_cleanup, stop);
190
+ $box.removeClass(className + "off").addClass(className + "on");
191
+ timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
192
+ };
193
+
194
+ stop = function () {
195
+ clearTimeout(timeOut);
196
+ $slideshow
197
+ .text(settings.slideshowStart)
198
+ .unbind([event_complete, event_load, event_cleanup, click].join(' '))
199
+ .one(click, start);
200
+ $box.removeClass(className + "on").addClass(className + "off");
201
+ };
202
+
203
+ if (settings.slideshowAuto) {
204
+ start();
205
+ } else {
206
+ stop();
207
+ }
208
+ } else {
209
+ $box.removeClass(className + "off " + className + "on");
210
+ }
211
+ }
212
+
213
+ function launch(elem) {
214
+ if (!closing) {
215
+
216
+ element = elem;
217
+
218
+ process($.extend(settings, $.data(element, colorbox)));
219
+
220
+ $related = $(element);
221
+
222
+ index = 0;
223
+
224
+ if (settings.rel !== 'nofollow') {
225
+ $related = $('.' + boxElement).filter(function () {
226
+ var relRelated = $.data(this, colorbox).rel || this.rel;
227
+ return (relRelated === settings.rel);
228
+ });
229
+ index = $related.index(element);
230
+
231
+ // Check direct calls to ColorBox.
232
+ if (index === -1) {
233
+ $related = $related.add(element);
234
+ index = $related.length - 1;
235
+ }
236
+ }
237
+
238
+ if (!open) {
239
+ open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
240
+
241
+ $box.show();
242
+
243
+ if (settings.returnFocus) {
244
+ try {
245
+ element.blur();
246
+ $(element).one(event_closed, function () {
247
+ try {
248
+ this.focus();
249
+ } catch (e) {
250
+ // do nothing
251
+ }
252
+ });
253
+ } catch (e) {
254
+ // do nothing
255
+ }
256
+ }
257
+
258
+ // +settings.opacity avoids a problem in IE when using non-zero-prefixed-string-values, like '.5'
259
+ $overlay.css({"opacity": +settings.opacity, "cursor": settings.overlayClose ? "pointer" : "auto"}).show();
260
+
261
+ // Opens inital empty ColorBox prior to content being loaded.
262
+ settings.w = setSize(settings.initialWidth, 'x');
263
+ settings.h = setSize(settings.initialHeight, 'y');
264
+ publicMethod.position(0);
265
+
266
+ if (isIE6) {
267
+ $window.bind('resize.' + event_ie6 + ' scroll.' + event_ie6, function () {
268
+ $overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()});
269
+ }).trigger('resize.' + event_ie6);
270
+ }
271
+
272
+ trigger(event_open, settings.onOpen);
273
+
274
+ $groupControls.add($title).hide();
275
+
276
+ $close.html(settings.close).show();
277
+ }
278
+
279
+ publicMethod.load(true);
280
+ }
281
+ }
282
+
283
+ // ****************
284
+ // PUBLIC FUNCTIONS
285
+ // Usage format: $.fn.colorbox.close();
286
+ // Usage from within an iframe: parent.$.fn.colorbox.close();
287
+ // ****************
288
+
289
+ publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
290
+ var $this = this, autoOpen;
291
+
292
+ if (!$this[0] && $this.selector) { // if a selector was given and it didn't match any elements, go ahead and exit.
293
+ return $this;
294
+ }
295
+
296
+ options = options || {};
297
+
298
+ if (callback) {
299
+ options.onComplete = callback;
300
+ }
301
+
302
+ if (!$this[0] || $this.selector === undefined) { // detects $.colorbox() and $.fn.colorbox()
303
+ $this = $('<a/>');
304
+ options.open = true; // assume an immediate open
305
+ }
306
+
307
+ $this.each(function () {
308
+ $.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options));
309
+ $(this).addClass(boxElement);
310
+ });
311
+
312
+ autoOpen = options.open;
313
+
314
+ if ($.isFunction(autoOpen)) {
315
+ autoOpen = autoOpen.call($this);
316
+ }
317
+
318
+ if (autoOpen) {
319
+ launch($this[0]);
320
+ }
321
+
322
+ return $this;
323
+ };
324
+
325
+ // Initialize ColorBox: store common calculations, preload the interface graphics, append the html.
326
+ // This preps colorbox for a speedy open when clicked, and lightens the burdon on the browser by only
327
+ // having to run once, instead of each time colorbox is opened.
328
+ publicMethod.init = function () {
329
+ // Create & Append jQuery Objects
330
+ $window = $(window);
331
+ $box = $div().attr({id: colorbox, 'class': isIE ? prefix + (isIE6 ? 'IE6' : 'IE') : ''});
332
+ $overlay = $div("Overlay", isIE6 ? 'position:absolute' : '').hide();
333
+
334
+ $wrap = $div("Wrapper");
335
+ $content = $div("Content").append(
336
+ $loaded = $div("LoadedContent", 'width:0; height:0; overflow:hidden'),
337
+ $loadingOverlay = $div("LoadingOverlay").add($div("LoadingGraphic")),
338
+ $title = $div("Title"),
339
+ $current = $div("Current"),
340
+ $next = $div("Next"),
341
+ $prev = $div("Previous"),
342
+ $slideshow = $div("Slideshow").bind(event_open, slideshow),
343
+ $close = $div("Close")
344
+ );
345
+ $wrap.append( // The 3x3 Grid that makes up ColorBox
346
+ $div().append(
347
+ $div("TopLeft"),
348
+ $topBorder = $div("TopCenter"),
349
+ $div("TopRight")
350
+ ),
351
+ $div(false, 'clear:left').append(
352
+ $leftBorder = $div("MiddleLeft"),
353
+ $content,
354
+ $rightBorder = $div("MiddleRight")
355
+ ),
356
+ $div(false, 'clear:left').append(
357
+ $div("BottomLeft"),
358
+ $bottomBorder = $div("BottomCenter"),
359
+ $div("BottomRight")
360
+ )
361
+ ).children().children().css({'float': 'left'});
362
+
363
+ $loadingBay = $div(false, 'position:absolute; width:9999px; visibility:hidden; display:none');
364
+
365
+ $('body').prepend($overlay, $box.append($wrap, $loadingBay));
366
+
367
+ $content.children()
368
+ .hover(function () {
369
+ $(this).addClass('hover');
370
+ }, function () {
371
+ $(this).removeClass('hover');
372
+ }).addClass('hover');
373
+
374
+ // Cache values needed for size calculations
375
+ interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();//Subtraction needed for IE6
376
+ interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
377
+ loadedHeight = $loaded.outerHeight(true);
378
+ loadedWidth = $loaded.outerWidth(true);
379
+
380
+ // Setting padding to remove the need to do size conversions during the animation step.
381
+ $box.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth}).hide();
382
+
383
+ // Setup button events.
384
+ $next.click(function () {
385
+ publicMethod.next();
386
+ });
387
+ $prev.click(function () {
388
+ publicMethod.prev();
389
+ });
390
+ $close.click(function () {
391
+ publicMethod.close();
392
+ });
393
+
394
+ $groupControls = $next.add($prev).add($current).add($slideshow);
395
+
396
+ // Adding the 'hover' class allowed the browser to load the hover-state
397
+ // background graphics. The class can now can be removed.
398
+ $content.children().removeClass('hover');
399
+
400
+
401
+
402
+
403
+ $overlay.click(function () {
404
+ if (settings.overlayClose) {
405
+ publicMethod.close();
406
+ }
407
+ });
408
+
409
+ // Set Navigation Key Bindings
410
+ $(document).bind('keydown.' + prefix, function (e) {
411
+ var key = e.keyCode;
412
+ if (open && settings.escKey && key === 27) {
413
+ e.preventDefault();
414
+ publicMethod.close();
415
+ }
416
+ if (open && settings.arrowKey && $related[1]) {
417
+ if (key === 37) {
418
+ e.preventDefault();
419
+ $prev.click();
420
+ } else if (key === 39) {
421
+ e.preventDefault();
422
+ $next.click();
423
+ }
424
+ }
425
+ });
426
+ };
427
+
428
+ publicMethod.remove = function () {
429
+ $box.add($overlay).remove();
430
+ $('.' + boxElement).removeData(colorbox).removeClass(boxElement);
431
+ };
432
+
433
+ publicMethod.position = function (speed, loadedCallback) {
434
+ var animate_speed, top = 0, left = 0;
435
+
436
+ // remove the modal so that it doesn't influence the document width/height
437
+ $box.hide();
438
+
439
+ if (settings.fixed && !isIE6) {
440
+ $box.css({position: 'fixed'});
441
+ } else {
442
+ top = $window.scrollTop();
443
+ left = $window.scrollLeft();
444
+ $box.css({position: 'absolute'});
445
+ }
446
+
447
+ // keeps the top and left positions within the browser's viewport.
448
+ if (settings.right !== false) {
449
+ left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0);
450
+ } else if (settings.left !== false) {
451
+ left += setSize(settings.left, 'x');
452
+ } else {
453
+ left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2;
454
+ }
455
+
456
+ if (settings.bottom !== false) {
457
+ top += Math.max(document.documentElement.clientHeight - settings.h - loadedHeight - interfaceHeight - setSize(settings.bottom, 'y'), 0);
458
+ } else if (settings.top !== false) {
459
+ top += setSize(settings.top, 'y');
460
+ } else {
461
+ top += Math.max(document.documentElement.clientHeight - settings.h - loadedHeight - interfaceHeight, 0) / 2;
462
+ }
463
+
464
+ $box.show();
465
+
466
+ // setting the speed to 0 to reduce the delay between same-sized content.
467
+ animate_speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed;
468
+
469
+ // this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
470
+ // but it has to be shrank down around the size of div#colorbox when it's done. If not,
471
+ // it can invoke an obscure IE bug when using iframes.
472
+ $wrap[0].style.width = $wrap[0].style.height = "9999px";
473
+
474
+ function modalDimensions(that) {
475
+ // loading overlay height has to be explicitly set for IE6.
476
+ $topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
477
+ $loadingOverlay[0].style.height = $loadingOverlay[1].style.height = $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
478
+ }
479
+
480
+ $box.dequeue().animate({width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: top, left: left}, {
481
+ duration: animate_speed,
482
+ complete: function () {
483
+ modalDimensions(this);
484
+
485
+ active = false;
486
+
487
+ // shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
488
+ $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
489
+ $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
490
+
491
+ if (loadedCallback) {
492
+ loadedCallback();
493
+ }
494
+ },
495
+ step: function () {
496
+ modalDimensions(this);
497
+ }
498
+ });
499
+ };
500
+
501
+ publicMethod.resize = function (options) {
502
+ if (open) {
503
+ options = options || {};
504
+
505
+ if (options.width) {
506
+ settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth;
507
+ }
508
+ if (options.innerWidth) {
509
+ settings.w = setSize(options.innerWidth, 'x');
510
+ }
511
+ $loaded.css({width: settings.w});
512
+
513
+ if (options.height) {
514
+ settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight;
515
+ }
516
+ if (options.innerHeight) {
517
+ settings.h = setSize(options.innerHeight, 'y');
518
+ }
519
+ if (!options.innerHeight && !options.height) {
520
+ 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.
521
+ settings.h = $child.height();
522
+ $child.replaceWith($child.children()); // ditch the temporary wrapper div used in height calculation
523
+ }
524
+ $loaded.css({height: settings.h});
525
+
526
+ publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
527
+ }
528
+ };
529
+
530
+ publicMethod.prep = function (object) {
531
+ if (!open) {
532
+ return;
533
+ }
534
+
535
+ var speed = settings.transition === "none" ? 0 : settings.speed;
536
+
537
+ $window.unbind('resize.' + prefix);
538
+ $loaded.remove();
539
+ $loaded = $div('LoadedContent').html(object);
540
+
541
+ function getWidth() {
542
+ settings.w = settings.w || $loaded.width();
543
+ settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
544
+ return settings.w;
545
+ }
546
+ function getHeight() {
547
+ settings.h = settings.h || $loaded.height();
548
+ settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
549
+ return settings.h;
550
+ }
551
+
552
+ $loaded.hide()
553
+ .appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
554
+ .css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
555
+ .css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
556
+ .prependTo($content);
557
+
558
+ $loadingBay.hide();
559
+
560
+ // 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.
561
+ //$(photo).css({'float': 'none', marginLeft: 'auto', marginRight: 'auto'});
562
+
563
+ $(photo).css({'float': 'none'});
564
+
565
+ // Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
566
+ if (isIE6) {
567
+ $('select').not($box.find('select')).filter(function () {
568
+ return this.style.visibility !== 'hidden';
569
+ }).css({'visibility': 'hidden'}).one(event_cleanup, function () {
570
+ this.style.visibility = 'inherit';
571
+ });
572
+ }
573
+
574
+ function setPosition(s) {
575
+ publicMethod.position(s, function () {
576
+ var prev, prevSrc, next, nextSrc, total = $related.length, iframe, complete;
577
+
578
+ if (!open) {
579
+ return;
580
+ }
581
+
582
+ function removeFilter() {
583
+ if (isIE) {
584
+ $box[0].style.removeAttribute('filter');
585
+ }
586
+ }
587
+
588
+ complete = function () {
589
+ clearTimeout(loadingTimer);
590
+ $loadingOverlay.hide();
591
+ trigger(event_complete, settings.onComplete);
592
+ };
593
+
594
+ if (isIE) {
595
+ //This fadeIn helps the bicubic resampling to kick-in.
596
+ if (photo) {
597
+ $loaded.fadeIn(100);
598
+ }
599
+ }
600
+
601
+ $title.html(settings.title).add($loaded).show();
602
+
603
+ if (total > 1) { // handle grouping
604
+ if (typeof settings.current === "string") {
605
+ $current.html(settings.current.replace(/\{current\}/, index + 1).replace(/\{total\}/, total)).show();
606
+ }
607
+
608
+ $next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
609
+ $prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous);
610
+
611
+ prev = index ? $related[index - 1] : $related[total - 1];
612
+ next = index < total - 1 ? $related[index + 1] : $related[0];
613
+
614
+ if (settings.slideshow) {
615
+ $slideshow.show();
616
+ }
617
+
618
+ // Preloads images within a rel group
619
+ if (settings.preloading) {
620
+ nextSrc = $.data(next, colorbox).href || next.href;
621
+ prevSrc = $.data(prev, colorbox).href || prev.href;
622
+
623
+ nextSrc = $.isFunction(nextSrc) ? nextSrc.call(next) : nextSrc;
624
+ prevSrc = $.isFunction(prevSrc) ? prevSrc.call(prev) : prevSrc;
625
+
626
+ if (isImage(nextSrc)) {
627
+ $('<img/>')[0].src = nextSrc;
628
+ }
629
+
630
+ if (isImage(prevSrc)) {
631
+ $('<img/>')[0].src = prevSrc;
632
+ }
633
+ }
634
+ } else {
635
+ $groupControls.hide();
636
+ }
637
+
638
+ if (settings.iframe) {
639
+ iframe = $('<iframe/>').addClass(prefix + 'Iframe')[0];
640
+
641
+ if (settings.fastIframe) {
642
+ complete();
643
+ } else {
644
+ $(iframe).one('load', complete);
645
+ }
646
+ iframe.name = prefix + (+new Date());
647
+ iframe.src = settings.href;
648
+
649
+ if (!settings.scrolling) {
650
+ iframe.scrolling = "no";
651
+ }
652
+
653
+ if (isIE) {
654
+ iframe.frameBorder = 0;
655
+ iframe.allowTransparency = "true";
656
+ }
657
+
658
+ $(iframe).appendTo($loaded).one(event_purge, function () {
659
+ iframe.src = "//about:blank";
660
+ });
661
+ } else {
662
+ complete();
663
+ }
664
+
665
+ if (settings.transition === 'fade') {
666
+ $box.fadeTo(speed, 1, removeFilter);
667
+ } else {
668
+ removeFilter();
669
+ }
670
+
671
+ $window.bind('resize.' + prefix, function () {
672
+ publicMethod.position(0);
673
+ });
674
+ });
675
+ }
676
+
677
+ if (settings.transition === 'fade') {
678
+ $box.fadeTo(speed, 0, function () {
679
+ setPosition(0);
680
+ });
681
+ } else {
682
+ setPosition(speed);
683
+ }
684
+ };
685
+
686
+ publicMethod.load = function (launched) {
687
+ var href, setResize, prep = publicMethod.prep;
688
+
689
+ active = true;
690
+
691
+ photo = false;
692
+
693
+ element = $related[index];
694
+
695
+ if (!launched) {
696
+ process($.extend(settings, $.data(element, colorbox)));
697
+ }
698
+
699
+ trigger(event_purge);
700
+
701
+ trigger(event_load, settings.onLoad);
702
+
703
+ settings.h = settings.height ?
704
+ setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
705
+ settings.innerHeight && setSize(settings.innerHeight, 'y');
706
+
707
+ settings.w = settings.width ?
708
+ setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
709
+ settings.innerWidth && setSize(settings.innerWidth, 'x');
710
+
711
+ // Sets the minimum dimensions for use in image scaling
712
+ settings.mw = settings.w;
713
+ settings.mh = settings.h;
714
+
715
+ // Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
716
+ // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
717
+ if (settings.maxWidth) {
718
+ settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
719
+ settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
720
+ }
721
+ if (settings.maxHeight) {
722
+ settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
723
+ settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
724
+ }
725
+
726
+ href = settings.href;
727
+
728
+ loadingTimer = setTimeout(function () {
729
+ $loadingOverlay.show();
730
+ }, 100);
731
+
732
+ if (settings.inline) {
733
+ // Inserts an empty placeholder where inline content is being pulled from.
734
+ // An event is bound to put inline content back when ColorBox closes or loads new content.
735
+ $div().hide().insertBefore($(href)[0]).one(event_purge, function () {
736
+ $(this).replaceWith($loaded.children());
737
+ });
738
+ prep($(href));
739
+ } else if (settings.iframe) {
740
+ // IFrame element won't be added to the DOM until it is ready to be displayed,
741
+ // to avoid problems with DOM-ready JS that might be trying to run in that iframe.
742
+ prep(" ");
743
+ } else if (settings.html) {
744
+ prep(settings.html);
745
+ } else if (isImage(href)) {
746
+ $(photo = new Image())
747
+ .addClass(prefix + 'Photo')
748
+ .error(function () {
749
+ settings.title = false;
750
+ prep($div('Error').text('This image could not be loaded'));
751
+ })
752
+ .load(function () {
753
+ var percent;
754
+ photo.onload = null; //stops animated gifs from firing the onload repeatedly.
755
+
756
+ if (settings.scalePhotos) {
757
+ setResize = function () {
758
+ photo.height -= photo.height * percent;
759
+ photo.width -= photo.width * percent;
760
+ };
761
+ if (settings.mw && photo.width > settings.mw) {
762
+ percent = (photo.width - settings.mw) / photo.width;
763
+ setResize();
764
+ }
765
+ if (settings.mh && photo.height > settings.mh) {
766
+ percent = (photo.height - settings.mh) / photo.height;
767
+ setResize();
768
+ }
769
+ }
770
+
771
+ if (settings.h) {
772
+ photo.style.marginTop = Math.max(settings.h - photo.height, 0) / 2 + 'px';
773
+ }
774
+
775
+ if ($related[1] && (index < $related.length - 1 || settings.loop)) {
776
+ photo.style.cursor = 'pointer';
777
+ photo.onclick = function () {
778
+ publicMethod.next();
779
+ };
780
+ }
781
+
782
+ if (isIE) {
783
+ photo.style.msInterpolationMode = 'bicubic';
784
+ }
785
+
786
+ setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise.
787
+ prep(photo);
788
+ }, 1);
789
+ });
790
+
791
+ setTimeout(function () { // A pause because Opera 10.6+ will sometimes not run the onload function otherwise.
792
+ photo.src = href;
793
+ }, 1);
794
+ } else if (href) {
795
+ $loadingBay.load(href, settings.data, function (data, status, xhr) {
796
+ prep(status === 'error' ? $div('Error').text('Request unsuccessful: ' + xhr.statusText) : $(this).contents());
797
+ });
798
+ }
799
+ };
800
+
801
+ // Navigates to the next page/image in a set.
802
+ publicMethod.next = function () {
803
+ if (!active && $related[1] && (index < $related.length - 1 || settings.loop)) {
804
+ index = index < $related.length - 1 ? index + 1 : 0;
805
+ publicMethod.load();
806
+ }
807
+ };
808
+
809
+ publicMethod.prev = function () {
810
+ if (!active && $related[1] && (index || settings.loop)) {
811
+ index = index ? index - 1 : $related.length - 1;
812
+ publicMethod.load();
813
+ }
814
+ };
815
+
816
+ // Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
817
+ publicMethod.close = function () {
818
+ if (open && !closing) {
819
+
820
+ closing = true;
821
+
822
+ open = false;
823
+
824
+ trigger(event_cleanup, settings.onCleanup);
825
+
826
+ $window.unbind('.' + prefix + ' .' + event_ie6);
827
+
828
+ $overlay.fadeTo(200, 0);
829
+
830
+ $box.stop().fadeTo(300, 0, function () {
831
+
832
+ $box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
833
+
834
+ trigger(event_purge);
835
+
836
+ $loaded.remove();
837
+
838
+ setTimeout(function () {
839
+ closing = false;
840
+ trigger(event_closed, settings.onClosed);
841
+ }, 1);
842
+ });
843
+ }
844
+ };
845
+
846
+ // A method for fetching the current element ColorBox is referencing.
847
+ // returns a jQuery object.
848
+ publicMethod.element = function () {
849
+ return $(element);
850
+ };
851
+
852
+ publicMethod.settings = defaults;
853
+
854
+ // Bind the live event before DOM-ready for maximum performance in IE6 & 7.
855
+ handler = function (e) {
856
+ // checks to see if it was a non-left mouse-click and for clicks modified with ctrl, shift, or alt.
857
+ if (!((e.button !== 0 && typeof e.button !== 'undefined') || e.ctrlKey || e.shiftKey || e.altKey)) {
858
+ e.preventDefault();
859
+ launch(this);
860
+ }
861
+ };
862
+
863
+ if ($.fn.delegate) {
864
+ $(document).delegate('.' + boxElement, 'click', handler);
865
+ } else {
866
+ $('.' + boxElement).live('click', handler);
867
+ }
868
+
869
+ // Initializes ColorBox when the DOM has loaded
870
+ $(publicMethod.init);
871
+
872
+ }(jQuery, document, this));