simplecov-html 0.8.0 → 0.9.0

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