jquery-colorbox-rails 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 430bc8fa7e2dda50d54805748e65138cbf6ec799
4
- data.tar.gz: a30f26fc96a2b9d911ce1120995a0cfcb66c94f5
3
+ metadata.gz: c92475192c16fc5de9b5cbab99153ac5f987100e
4
+ data.tar.gz: 7c66b2a01a65d37e7f08b7d5173765dc35a36924
5
5
  SHA512:
6
- metadata.gz: c3bd610bcf1522c628ad7a52280b19dd7d989535c5fc4ebf1be76d181713ee8cbb0126cf9d361e7c033bfb8537507ecad3a65b72cac0b35724040848a4772a26
7
- data.tar.gz: 8d30c543f2609ea5033cbd932c085107e617f2966dedc536bc22c5075547851ce4da48af7ce6a7700e605797497bc158ff1e895c55fcd11bcee06885bedfae4c
6
+ metadata.gz: 5347eeab8f4dc5e286621c165263247f0230e1a6e9e7c7a70778416945160c071d4c1def00cc0a060d54b55973e0edb9ce38489f914463a5204596f7e6a94b9f
7
+ data.tar.gz: 605fec9da3b5a2d3135489c76daefa1a0e7551b2791bda6c8a13858b5fbf7adc7d90b1f9c85dcdf2083917a8f4639ee2b79b00949dbd51e95b30f154f141882f
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  jquery-colorbox-rails integrates [jquery.colorbox](https://github.com/jackmoore/colorbox) with rails 3.1+ asset pipeline.
4
4
 
5
- Colorbox version: <b id="colorbox-version">1.4.36</b>
5
+ Colorbox version: <b id="colorbox-version">1.5.9</b>
6
6
 
7
7
  ### Installation
8
8
 
@@ -1,3 +1,3 @@
1
1
  module JqueryColorboxRails
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -0,0 +1,15 @@
1
+ /*
2
+ jQuery Colorbox language configuration
3
+ language: Lithuanian (lt)
4
+ translated by: Tomas Norkūnas
5
+ */
6
+ jQuery.extend(jQuery.colorbox.settings, {
7
+ current: "Nuotrauka {current} iš {total}",
8
+ previous: "Atgal",
9
+ next: "Pirmyn",
10
+ close: "Uždaryti",
11
+ xhrError: "Nepavyko užkrauti turinio.",
12
+ imgError: "Nepavyko užkrauti nuotraukos.",
13
+ slideshowStart: "Pradėti automatinę peržiūrą",
14
+ slideshowStop: "Sustabdyti automatinę peržiūrą"
15
+ });
@@ -0,0 +1,15 @@
1
+ /*
2
+ jQuery Colorbox language configuration
3
+ language: Myanmar (my)
4
+ translated by: Yan Naing
5
+ */
6
+ jQuery.extend(jQuery.colorbox.settings, {
7
+ current: "ပုံ {total} မှာ {current} မြောက်ပုံ",
8
+ previous: "ရှေ့သို့",
9
+ next: "နောက်သို့",
10
+ close: "ပိတ်မည်",
11
+ xhrError: "ပါဝင်သော အကြောင်းအရာများ ဖော်ပြရာတွင် အနည်းငယ် ချို့ယွင်းမှုရှိနေပါသည်",
12
+ imgError: "ပုံပြသရာတွင် အနည်းငယ် ချို့ယွင်းချက် ရှိနေပါသည်",
13
+ slideshowStart: "ပုံများ စတင်ပြသမည်",
14
+ slideshowStop: "ပုံပြသခြင်း ရပ်ဆိုင်မည်"
15
+ });
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Colorbox v1.4.36 - 2014-02-01
2
+ Colorbox v1.5.9 - 2014-04-25
3
3
  jQuery lightbox and modal window plugin
4
4
  (c) 2014 Jack Moore - http://www.jacklmoore.com/colorbox
5
5
  license: http://www.opensource.org/licenses/mit-license.php
@@ -29,9 +29,6 @@
29
29
  maxHeight: false,
30
30
  scalePhotos: true,
31
31
  scrolling: true,
32
- href: false,
33
- title: false,
34
- rel: false,
35
32
  opacity: 0.9,
36
33
  preloading: true,
37
34
  className: false,
@@ -54,7 +51,7 @@
54
51
  slideshowSpeed: 2500,
55
52
  slideshowStart: "start slideshow",
56
53
  slideshowStop: "stop slideshow",
57
- photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp)((#|\?).*)?$/i,
54
+ photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i,
58
55
 
59
56
  // alternate image paths for high-res displays
60
57
  retinaImage: false,
@@ -78,9 +75,21 @@
78
75
  onLoad: false,
79
76
  onComplete: false,
80
77
  onCleanup: false,
81
- onClosed: 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
+ }
82
90
  },
83
-
91
+
92
+
84
93
  // Abstracting the HTML and event identifiers for easy rebranding
85
94
  colorbox = 'colorbox',
86
95
  prefix = 'cbox',
@@ -115,7 +124,7 @@
115
124
  $prev,
116
125
  $close,
117
126
  $groupControls,
118
- $events = $('<a/>'), // $([]) would be prefered, but there is an issue with jQuery 1.4.2
127
+ $events = $('<a/>'), // $({}) would be prefered, but there is an issue with jQuery 1.4.2
119
128
 
120
129
  // Variables for cached values or use across multiple functions
121
130
  settings,
@@ -123,7 +132,6 @@
123
132
  interfaceWidth,
124
133
  loadedHeight,
125
134
  loadedWidth,
126
- element,
127
135
  index,
128
136
  photo,
129
137
  open,
@@ -132,7 +140,6 @@
132
140
  loadingTimer,
133
141
  publicMethod,
134
142
  div = "div",
135
- className,
136
143
  requests = 0,
137
144
  previousCSS = {},
138
145
  init;
@@ -162,6 +169,38 @@
162
169
  return window.innerHeight ? window.innerHeight : $(window).height();
163
170
  }
164
171
 
172
+ function Settings(element, options) {
173
+ if (options !== Object(options)) {
174
+ options = {};
175
+ }
176
+
177
+ this.cache = {};
178
+ this.el = element;
179
+
180
+ this.value = function(key) {
181
+ var dataAttr;
182
+
183
+ if (this.cache[key] === undefined) {
184
+ dataAttr = $(this.el).attr('data-cbox-'+key);
185
+
186
+ if (dataAttr !== undefined) {
187
+ this.cache[key] = dataAttr;
188
+ } else if (options[key] !== undefined) {
189
+ this.cache[key] = options[key];
190
+ } else if (defaults[key] !== undefined) {
191
+ this.cache[key] = defaults[key];
192
+ }
193
+ }
194
+
195
+ return this.cache[key];
196
+ };
197
+
198
+ this.get = function(key) {
199
+ var value = this.value(key);
200
+ return $.isFunction(value) ? value.call(this.el, this) : value;
201
+ };
202
+ }
203
+
165
204
  // Determine the next and previous members in a group.
166
205
  function getIndex(increment) {
167
206
  var
@@ -179,62 +218,55 @@
179
218
  // Checks an href to see if it is a photo.
180
219
  // There is a force photo option (photo: true) for hrefs that cannot be matched by the regex.
181
220
  function isImage(settings, url) {
182
- return settings.photo || settings.photoRegex.test(url);
221
+ return settings.get('photo') || settings.get('photoRegex').test(url);
183
222
  }
184
223
 
185
224
  function retinaUrl(settings, url) {
186
- return settings.retinaUrl && window.devicePixelRatio > 1 ? url.replace(settings.photoRegex, settings.retinaSuffix) : url;
225
+ return settings.get('retinaUrl') && window.devicePixelRatio > 1 ? url.replace(settings.get('photoRegex'), settings.get('retinaSuffix')) : url;
187
226
  }
188
227
 
189
228
  function trapFocus(e) {
190
- if ('contains' in $box[0] && !$box[0].contains(e.target)) {
229
+ if ('contains' in $box[0] && !$box[0].contains(e.target) && e.target !== $overlay[0]) {
191
230
  e.stopPropagation();
192
231
  $box.focus();
193
232
  }
194
233
  }
195
234
 
196
- // Assigns function results to their respective properties
197
- function makeSettings() {
198
- var i,
199
- data = $.data(element, colorbox);
200
-
201
- if (data == null) {
202
- settings = $.extend({}, defaults);
203
- if (console && console.log) {
204
- console.log('Error: cboxElement missing settings object');
205
- }
206
- } else {
207
- settings = $.extend({}, data);
235
+ function setClass(str) {
236
+ if (setClass.str !== str) {
237
+ $box.add($overlay).removeClass(setClass.str).addClass(str);
238
+ setClass.str = str;
208
239
  }
240
+ }
241
+
242
+ function getRelated(rel) {
243
+ index = 0;
209
244
 
210
- for (i in settings) {
211
- 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.
212
- settings[i] = settings[i].call(element);
245
+ if (rel && rel !== false) {
246
+ $related = $('.' + boxElement).filter(function () {
247
+ var options = $.data(this, colorbox);
248
+ var settings = new Settings(this, options);
249
+ return (settings.get('rel') === rel);
250
+ });
251
+ index = $related.index(settings.el);
252
+
253
+ // Check direct calls to Colorbox.
254
+ if (index === -1) {
255
+ $related = $related.add(settings.el);
256
+ index = $related.length - 1;
213
257
  }
214
- }
215
-
216
- settings.rel = settings.rel || element.rel || $(element).data('rel') || 'nofollow';
217
- settings.href = settings.href || $(element).attr('href');
218
- settings.title = settings.title || element.title;
219
-
220
- if (typeof settings.href === "string") {
221
- settings.href = $.trim(settings.href);
258
+ } else {
259
+ $related = $(settings.el);
222
260
  }
223
261
  }
224
262
 
225
- function trigger(event, callback) {
263
+ function trigger(event) {
226
264
  // for external use
227
265
  $(document).trigger(event);
228
-
229
266
  // for internal use
230
267
  $events.triggerHandler(event);
231
-
232
- if ($.isFunction(callback)) {
233
- callback.call(element);
234
- }
235
268
  }
236
269
 
237
-
238
270
  var slideshow = (function(){
239
271
  var active,
240
272
  className = prefix + "Slideshow_",
@@ -246,15 +278,15 @@
246
278
  }
247
279
 
248
280
  function set() {
249
- if (settings.loop || $related[index + 1]) {
281
+ if (settings.get('loop') || $related[index + 1]) {
250
282
  clear();
251
- timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
283
+ timeOut = setTimeout(publicMethod.next, settings.get('slideshowSpeed'));
252
284
  }
253
285
  }
254
286
 
255
287
  function start() {
256
288
  $slideshow
257
- .html(settings.slideshowStop)
289
+ .html(settings.get('slideshowStop'))
258
290
  .unbind(click)
259
291
  .one(click, stop);
260
292
 
@@ -273,7 +305,7 @@
273
305
  .unbind(event_load, clear);
274
306
 
275
307
  $slideshow
276
- .html(settings.slideshowStart)
308
+ .html(settings.get('slideshowStart'))
277
309
  .unbind(click)
278
310
  .one(click, function () {
279
311
  publicMethod.next();
@@ -295,15 +327,15 @@
295
327
 
296
328
  return function(){
297
329
  if (active) {
298
- if (!settings.slideshow) {
330
+ if (!settings.get('slideshow')) {
299
331
  $events.unbind(event_cleanup, reset);
300
332
  reset();
301
333
  }
302
334
  } else {
303
- if (settings.slideshow && $related[1]) {
335
+ if (settings.get('slideshow') && $related[1]) {
304
336
  active = true;
305
337
  $events.one(event_cleanup, reset);
306
- if (settings.slideshowAuto) {
338
+ if (settings.get('slideshowAuto')) {
307
339
  start();
308
340
  } else {
309
341
  stop();
@@ -316,65 +348,26 @@
316
348
  }());
317
349
 
318
350
 
319
- function launch(target) {
320
- if (!closing) {
321
-
322
- element = target;
323
-
324
- makeSettings();
325
-
326
- $related = $(element);
327
-
328
- index = 0;
329
-
330
- if (settings.rel !== 'nofollow') {
331
- $related = $('.' + boxElement).filter(function () {
332
- var data = $.data(this, colorbox),
333
- relRelated;
351
+ function launch(element) {
352
+ var options;
334
353
 
335
- if (data) {
336
- relRelated = $(this).data('rel') || data.rel || this.rel;
337
- }
338
-
339
- return (relRelated === settings.rel);
340
- });
341
- index = $related.index(element);
342
-
343
- // Check direct calls to Colorbox.
344
- if (index === -1) {
345
- $related = $related.add(element);
346
- index = $related.length - 1;
347
- }
348
- }
349
-
350
- $overlay.css({
351
- opacity: parseFloat(settings.opacity),
352
- cursor: settings.overlayClose ? "pointer" : "auto",
353
- visibility: 'visible'
354
- }).show();
355
-
354
+ if (!closing) {
356
355
 
357
- if (className) {
358
- $box.add($overlay).removeClass(className);
359
- }
360
- if (settings.className) {
361
- $box.add($overlay).addClass(settings.className);
362
- }
363
- className = settings.className;
356
+ options = $(element).data('colorbox');
364
357
 
365
- if (settings.closeButton) {
366
- $close.html(settings.close).appendTo($content);
367
- } else {
368
- $close.appendTo('<div/>');
369
- }
358
+ settings = new Settings(element, options);
359
+
360
+ getRelated(settings.get('rel'));
370
361
 
371
362
  if (!open) {
372
363
  open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
364
+
365
+ setClass(settings.get('className'));
373
366
 
374
367
  // Show colorbox so the sizes can be calculated in older versions of jQuery
375
- $box.css({visibility:'hidden', display:'block'});
368
+ $box.css({visibility:'hidden', display:'block', opacity:''});
376
369
 
377
- $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden');
370
+ $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden; visibility:hidden');
378
371
  $content.css({width:'', height:''}).append($loaded);
379
372
 
380
373
  // Cache values needed for size calculations
@@ -384,18 +377,25 @@
384
377
  loadedWidth = $loaded.outerWidth(true);
385
378
 
386
379
  // Opens inital empty Colorbox prior to content being loaded.
387
- settings.w = setSize(settings.initialWidth, 'x');
388
- settings.h = setSize(settings.initialHeight, 'y');
380
+ var initialWidth = setSize(settings.get('initialWidth'), 'x');
381
+ var initialHeight = setSize(settings.get('initialHeight'), 'y');
382
+ var maxWidth = settings.get('maxWidth');
383
+ var maxHeight = settings.get('maxHeight');
384
+
385
+ settings.w = (maxWidth !== false ? Math.min(initialWidth, setSize(maxWidth, 'x')) : initialWidth) - loadedWidth - interfaceWidth;
386
+ settings.h = (maxHeight !== false ? Math.min(initialHeight, setSize(maxHeight, 'y')) : initialHeight) - loadedHeight - interfaceHeight;
387
+
389
388
  $loaded.css({width:'', height:settings.h});
390
389
  publicMethod.position();
391
390
 
392
- trigger(event_open, settings.onOpen);
393
-
391
+ trigger(event_open);
392
+ settings.get('onOpen');
393
+
394
394
  $groupControls.add($title).hide();
395
395
 
396
396
  $box.focus();
397
397
 
398
- if (settings.trapFocus) {
398
+ if (settings.get('trapFocus')) {
399
399
  // Confine focus to the modal
400
400
  // Uses event capturing that is not supported in IE8-
401
401
  if (document.addEventListener) {
@@ -409,12 +409,25 @@
409
409
  }
410
410
 
411
411
  // Return focus on closing
412
- if (settings.returnFocus) {
412
+ if (settings.get('returnFocus')) {
413
413
  $events.one(event_closed, function () {
414
- $(element).focus();
414
+ $(settings.el).focus();
415
415
  });
416
416
  }
417
417
  }
418
+
419
+ $overlay.css({
420
+ opacity: parseFloat(settings.get('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
+
418
431
  load();
419
432
  }
420
433
  }
@@ -497,7 +510,7 @@
497
510
  publicMethod.close();
498
511
  });
499
512
  $overlay.click(function () {
500
- if (settings.overlayClose) {
513
+ if (settings.get('overlayClose')) {
501
514
  publicMethod.close();
502
515
  }
503
516
  });
@@ -505,11 +518,11 @@
505
518
  // Key Bindings
506
519
  $(document).bind('keydown.' + prefix, function (e) {
507
520
  var key = e.keyCode;
508
- if (open && settings.escKey && key === 27) {
521
+ if (open && settings.get('escKey') && key === 27) {
509
522
  e.preventDefault();
510
523
  publicMethod.close();
511
524
  }
512
- if (open && settings.arrowKey && $related[1] && !e.altKey) {
525
+ if (open && settings.get('arrowKey') && $related[1] && !e.altKey) {
513
526
  if (key === 37) {
514
527
  e.preventDefault();
515
528
  $prev.click();
@@ -551,34 +564,44 @@
551
564
  // ****************
552
565
 
553
566
  publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
554
- var $this = this;
555
-
567
+ var settings;
568
+ var $obj = this;
569
+
556
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
+ }
557
583
 
558
584
  appendHTML();
559
585
 
560
586
  if (addBindings()) {
561
- if ($.isFunction($this)) { // assume a call to $.colorbox
562
- $this = $('<a/>');
563
- options.open = true;
564
- } else if (!$this[0]) { // colorbox being applied to empty collection
565
- return $this;
566
- }
567
-
587
+
568
588
  if (callback) {
569
589
  options.onComplete = callback;
570
590
  }
571
-
572
- $this.each(function () {
573
- $.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options));
591
+
592
+ $obj.each(function () {
593
+ var old = $.data(this, colorbox) || {};
594
+ $.data(this, colorbox, $.extend(old, options));
574
595
  }).addClass(boxElement);
596
+
597
+ settings = new Settings($obj[0], options);
575
598
 
576
- if (($.isFunction(options.open) && options.open.call($this)) || options.open) {
577
- launch($this[0]);
599
+ if (settings.get('open')) {
600
+ launch($obj[0]);
578
601
  }
579
602
  }
580
603
 
581
- return $this;
604
+ return $obj;
582
605
  };
583
606
 
584
607
  publicMethod.position = function (speed, loadedCallback) {
@@ -598,7 +621,7 @@
598
621
  scrollTop = $window.scrollTop();
599
622
  scrollLeft = $window.scrollLeft();
600
623
 
601
- if (settings.fixed) {
624
+ if (settings.get('fixed')) {
602
625
  offset.top -= scrollTop;
603
626
  offset.left -= scrollLeft;
604
627
  $box.css({position: 'fixed'});
@@ -609,18 +632,18 @@
609
632
  }
610
633
 
611
634
  // keeps the top and left positions within the browser's viewport.
612
- if (settings.right !== false) {
613
- left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0);
614
- } else if (settings.left !== false) {
615
- left += setSize(settings.left, 'x');
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');
616
639
  } else {
617
640
  left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2);
618
641
  }
619
642
 
620
- if (settings.bottom !== false) {
621
- top += Math.max(winheight() - settings.h - loadedHeight - interfaceHeight - setSize(settings.bottom, 'y'), 0);
622
- } else if (settings.top !== false) {
623
- top += setSize(settings.top, 'y');
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');
624
647
  } else {
625
648
  top += Math.round(Math.max(winheight() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
626
649
  }
@@ -668,7 +691,7 @@
668
691
  $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
669
692
  $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
670
693
 
671
- if (settings.reposition) {
694
+ if (settings.get('reposition')) {
672
695
  setTimeout(function () { // small delay before binding onresize due to an IE8 bug.
673
696
  $window.bind('resize.' + prefix, publicMethod.position);
674
697
  }, 1);
@@ -718,7 +741,7 @@
718
741
  $loaded.scrollTop(scrolltop);
719
742
  }
720
743
 
721
- publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
744
+ publicMethod.position(settings.get('transition') === "none" ? 0 : settings.get('speed'));
722
745
  }
723
746
  };
724
747
 
@@ -727,9 +750,9 @@
727
750
  return;
728
751
  }
729
752
 
730
- var callback, speed = settings.transition === "none" ? 0 : settings.speed;
753
+ var callback, speed = settings.get('transition') === "none" ? 0 : settings.get('speed');
731
754
 
732
- $loaded.empty().remove(); // Using empty first may prevent some IE7 issues.
755
+ $loaded.remove();
733
756
 
734
757
  $loaded = $tag(div, 'LoadedContent').append(object);
735
758
 
@@ -746,7 +769,7 @@
746
769
 
747
770
  $loaded.hide()
748
771
  .appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
749
- .css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
772
+ .css({width: getWidth(), overflow: settings.get('scrolling') ? 'auto' : 'hidden'})
750
773
  .css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
751
774
  .prependTo($content);
752
775
 
@@ -756,18 +779,18 @@
756
779
 
757
780
  $(photo).css({'float': 'none'});
758
781
 
782
+ setClass(settings.get('className'));
783
+
759
784
  callback = function () {
760
785
  var total = $related.length,
761
786
  iframe,
762
- frameBorder = 'frameBorder',
763
- allowTransparency = 'allowTransparency',
764
787
  complete;
765
788
 
766
789
  if (!open) {
767
790
  return;
768
791
  }
769
792
 
770
- function removeFilter() { // Needed for IE7 & IE8 in versions of jQuery prior to 1.7.2
793
+ function removeFilter() { // Needed for IE8 in versions of jQuery prior to 1.7.2
771
794
  if ($.support.opacity === false) {
772
795
  $box[0].style.removeAttribute('filter');
773
796
  }
@@ -776,41 +799,34 @@
776
799
  complete = function () {
777
800
  clearTimeout(loadingTimer);
778
801
  $loadingOverlay.hide();
779
- trigger(event_complete, settings.onComplete);
802
+ trigger(event_complete);
803
+ settings.get('onComplete');
780
804
  };
781
805
 
782
806
 
783
- $title.html(settings.title).add($loaded).show();
807
+ $title.html(settings.get('title')).show();
808
+ $loaded.show();
784
809
 
785
810
  if (total > 1) { // handle grouping
786
- if (typeof settings.current === "string") {
787
- $current.html(settings.current.replace('{current}', index + 1).replace('{total}', total)).show();
811
+ if (typeof settings.get('current') === "string") {
812
+ $current.html(settings.get('current').replace('{current}', index + 1).replace('{total}', total)).show();
788
813
  }
789
814
 
790
- $next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
791
- $prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous);
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'));
792
817
 
793
818
  slideshow();
794
819
 
795
820
  // Preloads images within a rel group
796
- if (settings.preloading) {
821
+ if (settings.get('preloading')) {
797
822
  $.each([getIndex(-1), getIndex(1)], function(){
798
- var src,
799
- img,
823
+ var img,
800
824
  i = $related[this],
801
- data = $.data(i, colorbox);
802
-
803
- if (data && data.href) {
804
- src = data.href;
805
- if ($.isFunction(src)) {
806
- src = src.call(i);
807
- }
808
- } else {
809
- src = $(i).attr('href');
810
- }
825
+ settings = new Settings(i, $.data(i, colorbox)),
826
+ src = settings.get('href');
811
827
 
812
- if (src && isImage(data, src)) {
813
- src = retinaUrl(data, src);
828
+ if (src && isImage(settings, src)) {
829
+ src = retinaUrl(settings, src);
814
830
  img = document.createElement('img');
815
831
  img.src = src;
816
832
  }
@@ -820,29 +836,27 @@
820
836
  $groupControls.hide();
821
837
  }
822
838
 
823
- if (settings.iframe) {
824
- iframe = $tag('iframe')[0];
839
+ if (settings.get('iframe')) {
840
+ iframe = document.createElement('iframe');
825
841
 
826
- if (frameBorder in iframe) {
827
- iframe[frameBorder] = 0;
842
+ if ('frameBorder' in iframe) {
843
+ iframe.frameBorder = 0;
828
844
  }
829
845
 
830
- if (allowTransparency in iframe) {
831
- iframe[allowTransparency] = "true";
846
+ if ('allowTransparency' in iframe) {
847
+ iframe.allowTransparency = "true";
832
848
  }
833
849
 
834
- if (!settings.scrolling) {
850
+ if (!settings.get('scrolling')) {
835
851
  iframe.scrolling = "no";
836
852
  }
837
853
 
838
854
  $(iframe)
839
855
  .attr({
840
- src: settings.href,
856
+ src: settings.get('href'),
841
857
  name: (new Date()).getTime(), // give the iframe a unique name to prevent caching
842
858
  'class': prefix + 'Iframe',
843
- allowFullScreen : true, // allow HTML5 video to go fullscreen
844
- webkitAllowFullScreen : true,
845
- mozallowfullscreen : true
859
+ allowFullScreen : true // allow HTML5 video to go fullscreen
846
860
  })
847
861
  .one('load', complete)
848
862
  .appendTo($loaded);
@@ -851,21 +865,21 @@
851
865
  iframe.src = "//about:blank";
852
866
  });
853
867
 
854
- if (settings.fastIframe) {
868
+ if (settings.get('fastIframe')) {
855
869
  $(iframe).trigger('load');
856
870
  }
857
871
  } else {
858
872
  complete();
859
873
  }
860
874
 
861
- if (settings.transition === 'fade') {
875
+ if (settings.get('transition') === 'fade') {
862
876
  $box.fadeTo(speed, 1, removeFilter);
863
877
  } else {
864
878
  removeFilter();
865
879
  }
866
880
  };
867
881
 
868
- if (settings.transition === 'fade') {
882
+ if (settings.get('transition') === 'fade') {
869
883
  $box.fadeTo(speed, 0, function () {
870
884
  publicMethod.position(0, callback);
871
885
  });
@@ -881,21 +895,17 @@
881
895
 
882
896
  photo = false;
883
897
 
884
- element = $related[index];
885
-
886
- makeSettings();
887
-
888
898
  trigger(event_purge);
899
+ trigger(event_load);
900
+ settings.get('onLoad');
889
901
 
890
- trigger(event_load, settings.onLoad);
891
-
892
- settings.h = settings.height ?
893
- setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
894
- settings.innerHeight && setSize(settings.innerHeight, 'y');
902
+ settings.h = settings.get('height') ?
903
+ setSize(settings.get('height'), 'y') - loadedHeight - interfaceHeight :
904
+ settings.get('innerHeight') && setSize(settings.get('innerHeight'), 'y');
895
905
 
896
- settings.w = settings.width ?
897
- setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
898
- settings.innerWidth && setSize(settings.innerWidth, 'x');
906
+ settings.w = settings.get('width') ?
907
+ setSize(settings.get('width'), 'x') - loadedWidth - interfaceWidth :
908
+ settings.get('innerWidth') && setSize(settings.get('innerWidth'), 'x');
899
909
 
900
910
  // Sets the minimum dimensions for use in image scaling
901
911
  settings.mw = settings.w;
@@ -903,109 +913,109 @@
903
913
 
904
914
  // Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
905
915
  // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
906
- if (settings.maxWidth) {
907
- settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
916
+ if (settings.get('maxWidth')) {
917
+ settings.mw = setSize(settings.get('maxWidth'), 'x') - loadedWidth - interfaceWidth;
908
918
  settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
909
919
  }
910
- if (settings.maxHeight) {
911
- settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
920
+ if (settings.get('maxHeight')) {
921
+ settings.mh = setSize(settings.get('maxHeight'), 'y') - loadedHeight - interfaceHeight;
912
922
  settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
913
923
  }
914
924
 
915
- href = settings.href;
925
+ href = settings.get('href');
916
926
 
917
927
  loadingTimer = setTimeout(function () {
918
928
  $loadingOverlay.show();
919
929
  }, 100);
920
930
 
921
- if (settings.inline) {
931
+ if (settings.get('inline')) {
932
+ var $target = $(href);
922
933
  // Inserts an empty placeholder where inline content is being pulled from.
923
934
  // An event is bound to put inline content back when Colorbox closes or loads new content.
924
- $inline = $tag(div).hide().insertBefore($(href)[0]);
935
+ $inline = $('<div>').hide().insertBefore($target);
925
936
 
926
937
  $events.one(event_purge, function () {
927
- $inline.replaceWith($loaded.children());
938
+ $inline.replaceWith($target);
928
939
  });
929
940
 
930
- prep($(href));
931
- } else if (settings.iframe) {
941
+ prep($target);
942
+ } else if (settings.get('iframe')) {
932
943
  // IFrame element won't be added to the DOM until it is ready to be displayed,
933
944
  // to avoid problems with DOM-ready JS that might be trying to run in that iframe.
934
945
  prep(" ");
935
- } else if (settings.html) {
936
- prep(settings.html);
946
+ } else if (settings.get('html')) {
947
+ prep(settings.get('html'));
937
948
  } else if (isImage(settings, href)) {
938
949
 
939
950
  href = retinaUrl(settings, href);
940
951
 
941
- photo = document.createElement('img');
952
+ photo = new Image();
942
953
 
943
954
  $(photo)
944
955
  .addClass(prefix + 'Photo')
945
956
  .bind('error',function () {
946
- settings.title = false;
947
- prep($tag(div, 'Error').html(settings.imgError));
957
+ prep($tag(div, 'Error').html(settings.get('imgError')));
948
958
  })
949
959
  .one('load', function () {
950
- var percent;
951
-
952
960
  if (request !== requests) {
953
961
  return;
954
962
  }
955
963
 
956
- $.each(['alt', 'longdesc', 'aria-describedby'], function(i,val){
957
- var attr = $(element).attr(val) || $(element).attr('data-'+val);
958
- if (attr) {
959
- photo.setAttribute(val, attr);
960
- }
961
- });
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;
962
968
 
963
- if (settings.retinaImage && window.devicePixelRatio > 1) {
964
- photo.height = photo.height / window.devicePixelRatio;
965
- photo.width = photo.width / window.devicePixelRatio;
966
- }
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
+ });
967
975
 
968
- if (settings.scalePhotos) {
969
- setResize = function () {
970
- photo.height -= photo.height * percent;
971
- photo.width -= photo.width * percent;
972
- };
973
- if (settings.mw && photo.width > settings.mw) {
974
- percent = (photo.width - settings.mw) / photo.width;
975
- setResize();
976
- }
977
- if (settings.mh && photo.height > settings.mh) {
978
- percent = (photo.height - settings.mh) / photo.height;
979
- setResize();
976
+ if (settings.get('retinaImage') && window.devicePixelRatio > 1) {
977
+ photo.height = photo.height / window.devicePixelRatio;
978
+ photo.width = photo.width / window.devicePixelRatio;
980
979
  }
981
- }
982
-
983
- if (settings.h) {
984
- photo.style.marginTop = Math.max(settings.mh - photo.height, 0) / 2 + 'px';
985
- }
986
-
987
- if ($related[1] && (settings.loop || $related[index + 1])) {
988
- photo.style.cursor = 'pointer';
989
- photo.onclick = function () {
990
- publicMethod.next();
991
- };
992
- }
993
980
 
994
- photo.style.width = photo.width + 'px';
995
- photo.style.height = photo.height + 'px';
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
+ }
996
1006
 
997
- setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise.
1007
+ photo.style.width = photo.width + 'px';
1008
+ photo.style.height = photo.height + 'px';
998
1009
  prep(photo);
999
1010
  }, 1);
1000
1011
  });
1001
1012
 
1002
- setTimeout(function () { // A pause because Opera 10.6+ will sometimes not run the onload function otherwise.
1003
- photo.src = href;
1004
- }, 1);
1013
+ photo.src = href;
1014
+
1005
1015
  } else if (href) {
1006
- $loadingBay.load(href, settings.data, function (data, status) {
1016
+ $loadingBay.load(href, settings.get('data'), function (data, status) {
1007
1017
  if (request === requests) {
1008
- prep(status === 'error' ? $tag(div, 'Error').html(settings.xhrError) : $(this).contents());
1018
+ prep(status === 'error' ? $tag(div, 'Error').html(settings.get('xhrError')) : $(this).contents());
1009
1019
  }
1010
1020
  });
1011
1021
  }
@@ -1013,14 +1023,14 @@
1013
1023
 
1014
1024
  // Navigates to the next page/image in a set.
1015
1025
  publicMethod.next = function () {
1016
- if (!active && $related[1] && (settings.loop || $related[index + 1])) {
1026
+ if (!active && $related[1] && (settings.get('loop') || $related[index + 1])) {
1017
1027
  index = getIndex(1);
1018
1028
  launch($related[index]);
1019
1029
  }
1020
1030
  };
1021
1031
 
1022
1032
  publicMethod.prev = function () {
1023
- if (!active && $related[1] && (settings.loop || index)) {
1033
+ if (!active && $related[1] && (settings.get('loop') || index)) {
1024
1034
  index = getIndex(-1);
1025
1035
  launch($related[index]);
1026
1036
  }
@@ -1031,26 +1041,22 @@
1031
1041
  if (open && !closing) {
1032
1042
 
1033
1043
  closing = true;
1034
-
1035
1044
  open = false;
1036
-
1037
- trigger(event_cleanup, settings.onCleanup);
1038
-
1045
+ trigger(event_cleanup);
1046
+ settings.get('onCleanup');
1039
1047
  $window.unbind('.' + prefix);
1048
+ $overlay.fadeTo(settings.get('fadeOut') || 0, 0);
1040
1049
 
1041
- $overlay.fadeTo(settings.fadeOut || 0, 0);
1042
-
1043
- $box.stop().fadeTo(settings.fadeOut || 0, 0, function () {
1044
-
1045
- $box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
1046
-
1050
+ $box.stop().fadeTo(settings.get('fadeOut') || 0, 0, function () {
1051
+ $box.hide();
1052
+ $overlay.hide();
1047
1053
  trigger(event_purge);
1048
-
1049
- $loaded.empty().remove(); // Using empty first may prevent some IE7 issues.
1054
+ $loaded.remove();
1050
1055
 
1051
1056
  setTimeout(function () {
1052
1057
  closing = false;
1053
- trigger(event_closed, settings.onClosed);
1058
+ trigger(event_closed);
1059
+ settings.get('onClosed');
1054
1060
  }, 1);
1055
1061
  });
1056
1062
  }
@@ -1076,9 +1082,9 @@
1076
1082
  // A method for fetching the current element Colorbox is referencing.
1077
1083
  // returns a jQuery object.
1078
1084
  publicMethod.element = function () {
1079
- return $(element);
1085
+ return $(settings.el);
1080
1086
  };
1081
1087
 
1082
1088
  publicMethod.settings = defaults;
1083
1089
 
1084
- }(jQuery, document, window));
1090
+ }(jQuery, document, window));
@@ -12,7 +12,7 @@
12
12
  #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;}
13
13
  #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}
14
14
  .cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;}
15
- .cboxIframe{width:100%; height:100%; display:block; border:0;}
15
+ .cboxIframe{width:100%; height:100%; display:block; border:0; padding:0; margin:0;}
16
16
  #colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;}
17
17
 
18
18
  /*
@@ -12,7 +12,7 @@
12
12
  #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;}
13
13
  #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}
14
14
  .cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;}
15
- .cboxIframe{width:100%; height:100%; display:block; border:0;}
15
+ .cboxIframe{width:100%; height:100%; display:block; border:0; padding:0; margin:0;}
16
16
  #colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;}
17
17
 
18
18
  /*
@@ -12,7 +12,7 @@
12
12
  #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;}
13
13
  #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}
14
14
  .cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;}
15
- .cboxIframe{width:100%; height:100%; display:block; border:0;}
15
+ .cboxIframe{width:100%; height:100%; display:block; border:0; padding:0; margin:0;}
16
16
  #colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;}
17
17
 
18
18
  /*
@@ -12,7 +12,7 @@
12
12
  #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;}
13
13
  #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}
14
14
  .cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;}
15
- .cboxIframe{width:100%; height:100%; display:block; border:0;}
15
+ .cboxIframe{width:100%; height:100%; display:block; border:0; padding:0; margin:0;}
16
16
  #colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;}
17
17
 
18
18
  /*
@@ -12,7 +12,7 @@
12
12
  #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;}
13
13
  #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}
14
14
  .cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;}
15
- .cboxIframe{width:100%; height:100%; display:block; border:0;}
15
+ .cboxIframe{width:100%; height:100%; display:block; border:0; padding:0; margin:0;}
16
16
  #colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;}
17
17
 
18
18
  /*
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-colorbox-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Knapik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-03 00:00:00.000000000 Z
11
+ date: 2014-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
27
  description: jQuery Colorbox [https://github.com/jackmoore/colorbox] integration for
@@ -32,6 +32,13 @@ executables: []
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
+ - Gemfile
36
+ - MIT-LICENSE
37
+ - README.md
38
+ - Rakefile
39
+ - lib/jquery-colorbox-rails.rb
40
+ - lib/jquery-colorbox-rails/engine.rb
41
+ - lib/jquery-colorbox-rails/version.rb
35
42
  - vendor/assets/images/colorbox/example1/border.png
36
43
  - vendor/assets/images/colorbox/example1/controls.png
37
44
  - vendor/assets/images/colorbox/example1/loading.gif
@@ -68,7 +75,9 @@ files:
68
75
  - vendor/assets/javascripts/jquery.colorbox-it.js
69
76
  - vendor/assets/javascripts/jquery.colorbox-ja.js
70
77
  - vendor/assets/javascripts/jquery.colorbox-kr.js
78
+ - vendor/assets/javascripts/jquery.colorbox-lt.js
71
79
  - vendor/assets/javascripts/jquery.colorbox-lv.js
80
+ - vendor/assets/javascripts/jquery.colorbox-my.js
72
81
  - vendor/assets/javascripts/jquery.colorbox-nl.js
73
82
  - vendor/assets/javascripts/jquery.colorbox-no.js
74
83
  - vendor/assets/javascripts/jquery.colorbox-pl.js
@@ -89,13 +98,6 @@ files:
89
98
  - vendor/assets/stylesheets/jquery.colorbox-example3.css.scss
90
99
  - vendor/assets/stylesheets/jquery.colorbox-example4.css.scss
91
100
  - vendor/assets/stylesheets/jquery.colorbox-example5.css.scss
92
- - lib/jquery-colorbox-rails/engine.rb
93
- - lib/jquery-colorbox-rails/version.rb
94
- - lib/jquery-colorbox-rails.rb
95
- - MIT-LICENSE
96
- - Rakefile
97
- - Gemfile
98
- - README.md
99
101
  homepage: https://github.com/knapo/jquery-colorbox-rails
100
102
  licenses:
101
103
  - MIT
@@ -106,17 +108,17 @@ require_paths:
106
108
  - lib
107
109
  required_ruby_version: !ruby/object:Gem::Requirement
108
110
  requirements:
109
- - - '>='
111
+ - - ">="
110
112
  - !ruby/object:Gem::Version
111
113
  version: '0'
112
114
  required_rubygems_version: !ruby/object:Gem::Requirement
113
115
  requirements:
114
- - - '>='
116
+ - - ">="
115
117
  - !ruby/object:Gem::Version
116
118
  version: '0'
117
119
  requirements: []
118
120
  rubyforge_project: jquery-colorbox-rails
119
- rubygems_version: 2.1.11
121
+ rubygems_version: 2.2.2
120
122
  signing_key:
121
123
  specification_version: 4
122
124
  summary: jQuery Colorbox integration for Rails 3.1+ asset pipeline