short 0.5.2 → 0.5.3

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