swipebox 1.3.0.2 → 1.4.1

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: 903e8dac097206db8c9e25caee1086e184c33483
4
- data.tar.gz: cf0b6af816942097436dcaaaf3730d294e0cef4b
3
+ metadata.gz: 828c397530a1e7d9f3b2395f4f0093bcf8adda3b
4
+ data.tar.gz: c58e50ae61b66228b2d61bdbbb1c13d4ea67b590
5
5
  SHA512:
6
- metadata.gz: 4916614e27134b439bcc79c56392e37dae49770651382b793401c63339b542582d1dac21e37ef9f74a11004037c8d0d3502db404ae5352453b7d6206fb92f3e5
7
- data.tar.gz: 890aa6af31c3f7f59486d708541c25602a3677e4ac591d77563562061087029db27f5e04e7a0b6657e2574e3e12f44875cb53bc848f01a05a24c6f756f69574c
6
+ metadata.gz: 6ef6ebd4561ce37c615fe353fc63d9bd120be2b40ec07767b124d8f52c3c19efce63144e9284073d432dc92dd0e83526cd2a37b02340a2282bb04a0af1985b58
7
+ data.tar.gz: 6bc667601a9afad34f722040316d7455247f8e33a3d2e7dbd1b022c59dd516f8a76519e217c06366ae231fc202dd3e428040dbc0e37cfcc72a5c02247544aaf3
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  [![Build Status](http://img.shields.io/travis/mrfoto/swipebox.svg?style=flat-square)](https://travis-ci.org/mrfoto/swipebox)
5
5
  [![Code Climate](http://img.shields.io/codeclimate/github/mrfoto/swipebox.svg?style=flat-square)](https://codeclimate.com/github/mrfoto/swipebox)
6
6
  [![Dependency Status](http://img.shields.io/gemnasium/mrfoto/swipebox.svg?style=flat-square)](https://gemnasium.com/mrfoto/swipebox)
7
+ [![swipebox API Documentation](https://img.shields.io/badge/omniref-docs-da2b48.svg?style=flat-square)](https://www.omniref.com/ruby/gems/swipebox)
7
8
 
8
9
  [Swipebox | A touchable jQuery lightbox](http://brutaldesign.github.io/swipebox/) for the Rails asset pipeline
9
10
 
@@ -45,19 +46,20 @@ $('.swipebox').swipebox();
45
46
 
46
47
  ```javascript
47
48
  useCSS : true, // false will force the use of jQuery for animations
48
- initialIndexOnArray: 0, // which image index to init when a array is passed
49
+ useSVG : true, // false to force the use of png for buttons
50
+ initialIndexOnArray : 0, // which image index to init when a array is passed
49
51
  hideCloseButtonOnMobile : false, // true will hide the close button on mobile devices
50
52
  hideBarsDelay : 3000, // delay before hiding bars on desktop
51
53
  videoMaxWidth : 1140, // videos max width
52
- beforeOpen: function(){} , // called before opening
54
+ beforeOpen: function() {}, // called before opening
53
55
  afterOpen: null, // called after opening
54
- afterClose: function(){}, // called after closing
55
- loopAtEnd: false // true will return to the first image after the last image is reached
56
+ afterClose: function() {}, // called after closing
57
+ loopAtEnd: false // true will return to the first image after the last image is reached of Bootstrap)
56
58
  ```
57
59
 
58
60
  Look at the original [Swipebox repo](https://github.com/brutaldesign/swipebox#usage) for more.
59
61
 
60
- I have modified source a bit from the 1.3.0.2 version:
62
+ I have modified source a bit from the 1.4.1 version:
61
63
  - SCSS instead of CSS because we need the `image-url` helpers
62
64
  - .png -> .svg via class not hardcoded image path
63
65
 
@@ -1,3 +1,3 @@
1
1
  module Swipebox
2
- VERSION = '1.3.0.2'
2
+ VERSION = '1.4.1'
3
3
  end
@@ -1,4 +1,4 @@
1
- /*! Swipebox v1.3.0.2 | Constantin Saguin csag.co | MIT License | github.com/brutaldesign/swipebox */
1
+ /*! Swipebox v1.4.1 | Constantin Saguin csag.co | MIT License | github.com/brutaldesign/swipebox */
2
2
 
3
3
  ;( function ( window, document, $, undefined ) {
4
4
 
@@ -6,48 +6,53 @@
6
6
 
7
7
  // Default options
8
8
  var ui,
9
- defaults = {
10
- useCSS : true,
11
- useSVG : true,
12
- initialIndexOnArray : 0,
13
- hideCloseButtonOnMobile : false,
14
- hideBarsDelay : 3000,
15
- videoMaxWidth : 1140,
16
- vimeoColor : 'cccccc',
17
- beforeOpen: null,
18
- afterOpen: null,
19
- afterClose: null,
20
- loopAtEnd: false,
21
- autoplayVideos: false
22
- },
23
-
24
- plugin = this,
25
- elements = [], // slides array [ { href:'...', title:'...' }, ...],
26
- $elem,
27
- selector = elem.selector,
28
- $selector = $( selector ),
29
- isMobile = navigator.userAgent.match( /(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i ),
30
- isTouch = isMobile !== null || document.createTouch !== undefined || ( 'ontouchstart' in window ) || ( 'onmsgesturechange' in window ) || navigator.msMaxTouchPoints,
31
- supportSVG = !! document.createElementNS && !! document.createElementNS( 'http://www.w3.org/2000/svg', 'svg').createSVGRect,
32
- winWidth = window.innerWidth ? window.innerWidth : $( window ).width(),
33
- winHeight = window.innerHeight ? window.innerHeight : $( window ).height(),
34
- currentX = 0,
35
- /* jshint multistr: true */
36
- html = '<div id="swipebox-overlay">\
37
- <div id="swipebox-container">\
38
- <div id="swipebox-slider"></div>\
39
- <div id="swipebox-top-bar">\
40
- <div id="swipebox-title"></div>\
41
- </div>\
42
- <div id="swipebox-bottom-bar">\
43
- <div id="swipebox-arrows">\
44
- <a id="swipebox-prev"></a>\
45
- <a id="swipebox-next"></a>\
46
- </div>\
47
- </div>\
48
- <a id="swipebox-close"></a>\
49
- </div>\
50
- </div>';
9
+ defaults = {
10
+ useCSS : true,
11
+ useSVG : true,
12
+ initialIndexOnArray : 0,
13
+ removeBarsOnMobile : true,
14
+ hideCloseButtonOnMobile : false,
15
+ hideBarsDelay : 3000,
16
+ videoMaxWidth : 1140,
17
+ vimeoColor : 'cccccc',
18
+ beforeOpen: null,
19
+ afterOpen: null,
20
+ afterClose: null,
21
+ nextSlide: null,
22
+ prevSlide: null,
23
+ loopAtEnd: false,
24
+ autoplayVideos: false,
25
+ queryStringData: {},
26
+ toggleClassOnLoad: ''
27
+ },
28
+
29
+ plugin = this,
30
+ elements = [], // slides array [ { href:'...', title:'...' }, ...],
31
+ $elem,
32
+ selector = elem.selector,
33
+ $selector = $( selector ),
34
+ isMobile = navigator.userAgent.match( /(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i ),
35
+ isTouch = isMobile !== null || document.createTouch !== undefined || ( 'ontouchstart' in window ) || ( 'onmsgesturechange' in window ) || navigator.msMaxTouchPoints,
36
+ supportSVG = !! document.createElementNS && !! document.createElementNS( 'http://www.w3.org/2000/svg', 'svg').createSVGRect,
37
+ winWidth = window.innerWidth ? window.innerWidth : $( window ).width(),
38
+ winHeight = window.innerHeight ? window.innerHeight : $( window ).height(),
39
+ currentX = 0,
40
+ /* jshint multistr: true */
41
+ html = '<div id="swipebox-overlay">\
42
+ <div id="swipebox-container">\
43
+ <div id="swipebox-slider"></div>\
44
+ <div id="swipebox-top-bar">\
45
+ <div id="swipebox-title"></div>\
46
+ </div>\
47
+ <div id="swipebox-bottom-bar">\
48
+ <div id="swipebox-arrows">\
49
+ <a id="swipebox-prev"></a>\
50
+ <a id="swipebox-next"></a>\
51
+ </div>\
52
+ </div>\
53
+ <a id="swipebox-close"></a>\
54
+ </div>\
55
+ </div>';
51
56
 
52
57
  plugin.settings = {};
53
58
 
@@ -109,7 +114,7 @@
109
114
  $elem.each( function() {
110
115
 
111
116
  var title = null,
112
- href = null;
117
+ href = null;
113
118
 
114
119
  if ( $( this ).attr( 'title' ) ) {
115
120
  title = $( this ).attr( 'title' );
@@ -138,8 +143,8 @@
138
143
  ui = {
139
144
 
140
145
  /**
141
- * Initiate Swipebox
142
- */
146
+ * Initiate Swipebox
147
+ */
143
148
  init : function( index ) {
144
149
  if ( plugin.settings.beforeOpen ) {
145
150
  plugin.settings.beforeOpen();
@@ -157,8 +162,8 @@
157
162
  },
158
163
 
159
164
  /**
160
- * Built HTML containers and fire main functions
161
- */
165
+ * Built HTML containers and fire main functions
166
+ */
162
167
  build : function () {
163
168
  var $this = this, bg;
164
169
 
@@ -168,7 +173,7 @@
168
173
  $('#swipebox-prev, #swipebox-next, #swipebox-close').addClass('svg');
169
174
  }
170
175
 
171
- if ( isMobile ) {
176
+ if ( isMobile && plugin.settings.removeBarsOnMobile ) {
172
177
  $( '#swipebox-bottom-bar, #swipebox-top-bar' ).remove();
173
178
  }
174
179
 
@@ -192,8 +197,8 @@
192
197
  },
193
198
 
194
199
  /**
195
- * Set dimensions depending on windows width and height
196
- */
200
+ * Set dimensions depending on windows width and height
201
+ */
197
202
  setDim : function () {
198
203
 
199
204
  var width, height, sliderCss = {};
@@ -228,8 +233,8 @@
228
233
  },
229
234
 
230
235
  /**
231
- * Reset dimensions on window resize envent
232
- */
236
+ * Reset dimensions on window resize envent
237
+ */
233
238
  resize : function () {
234
239
  var $this = this;
235
240
 
@@ -239,12 +244,12 @@
239
244
  },
240
245
 
241
246
  /**
242
- * Check if device supports CSS transitions
243
- */
247
+ * Check if device supports CSS transitions
248
+ */
244
249
  supportTransition : function () {
245
250
 
246
251
  var prefixes = 'transition WebkitTransition MozTransition OTransition msTransition KhtmlTransition'.split( ' ' ),
247
- i;
252
+ i;
248
253
 
249
254
  for ( i = 0; i < prefixes.length; i++ ) {
250
255
  if ( document.createElement( 'div' ).style[ prefixes[i] ] !== undefined ) {
@@ -255,8 +260,8 @@
255
260
  },
256
261
 
257
262
  /**
258
- * Check if CSS transitions are allowed (options + devicesupport)
259
- */
263
+ * Check if CSS transitions are allowed (options + devicesupport)
264
+ */
260
265
  doCssTrans : function () {
261
266
  if ( plugin.settings.useCSS && this.supportTransition() ) {
262
267
  return true;
@@ -264,25 +269,25 @@
264
269
  },
265
270
 
266
271
  /**
267
- * Touch navigation
268
- */
272
+ * Touch navigation
273
+ */
269
274
  gesture : function () {
270
275
 
271
276
  var $this = this,
272
- index,
273
- hDistance,
274
- vDistance,
275
- hDistanceLast,
276
- vDistanceLast,
277
- hDistancePercent,
278
- vSwipe = false,
279
- hSwipe = false,
280
- hSwipMinDistance = 10,
281
- vSwipMinDistance = 50,
282
- startCoords = {},
283
- endCoords = {},
284
- bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' ),
285
- slider = $( '#swipebox-slider' );
277
+ index,
278
+ hDistance,
279
+ vDistance,
280
+ hDistanceLast,
281
+ vDistanceLast,
282
+ hDistancePercent,
283
+ vSwipe = false,
284
+ hSwipe = false,
285
+ hSwipMinDistance = 10,
286
+ vSwipMinDistance = 50,
287
+ startCoords = {},
288
+ endCoords = {},
289
+ bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' ),
290
+ slider = $( '#swipebox-slider' );
286
291
 
287
292
  bars.addClass( 'visible-bars' );
288
293
  $this.setTimeout();
@@ -348,7 +353,7 @@
348
353
  } );
349
354
  }
350
355
 
351
- // swipe rught
356
+ // swipe rught
352
357
  } else if ( 0 > hDistance ) {
353
358
 
354
359
  // last Slide
@@ -388,10 +393,10 @@
388
393
  if ( Math.abs( vDistance ) >= 2 * vSwipMinDistance && Math.abs( vDistance ) > Math.abs( vDistanceLast ) ) {
389
394
  var vOffset = vDistance > 0 ? slider.height() : - slider.height();
390
395
  slider.animate( { top: vOffset + 'px', 'opacity': 0 },
391
- 300,
392
- function () {
393
- $this.closeSlide();
394
- } );
396
+ 300,
397
+ function () {
398
+ $this.closeSlide();
399
+ } );
395
400
  } else {
396
401
  slider.animate( { top: 0, 'opacity': 1 }, 300 );
397
402
  }
@@ -405,7 +410,7 @@
405
410
 
406
411
  $this.getPrev();
407
412
 
408
- // swipeRight
413
+ // swipeRight
409
414
  } else if ( hDistance <= -hSwipMinDistance && hDistance <= hDistanceLast) {
410
415
 
411
416
  $this.getNext();
@@ -434,437 +439,508 @@
434
439
  },
435
440
 
436
441
  /**
437
- * Set timer to hide the action bars
438
- */
442
+ * Set timer to hide the action bars
443
+ */
439
444
  setTimeout: function () {
440
445
  if ( plugin.settings.hideBarsDelay > 0 ) {
441
446
  var $this = this;
442
447
  $this.clearTimeout();
443
448
  $this.timeout = window.setTimeout( function() {
444
- $this.hideBars();
445
- },
449
+ $this.hideBars();
450
+ },
446
451
 
447
- plugin.settings.hideBarsDelay
448
- );
449
- }
450
- },
451
-
452
- /**
453
- * Clear timer
454
- */
455
- clearTimeout: function () {
456
- window.clearTimeout( this.timeout );
457
- this.timeout = null;
458
- },
459
-
460
- /**
461
- * Show navigation and title bars
462
- */
463
- showBars : function () {
464
- var bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
465
- if ( this.doCssTrans() ) {
466
- bars.addClass( 'visible-bars' );
467
- } else {
468
- $( '#swipebox-top-bar' ).animate( { top : 0 }, 500 );
469
- $( '#swipebox-bottom-bar' ).animate( { bottom : 0 }, 500 );
470
- setTimeout( function() {
452
+ plugin.settings.hideBarsDelay
453
+ );
454
+ }
455
+ },
456
+
457
+ /**
458
+ * Clear timer
459
+ */
460
+ clearTimeout: function () {
461
+ window.clearTimeout( this.timeout );
462
+ this.timeout = null;
463
+ },
464
+
465
+ /**
466
+ * Show navigation and title bars
467
+ */
468
+ showBars : function () {
469
+ var bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
470
+ if ( this.doCssTrans() ) {
471
471
  bars.addClass( 'visible-bars' );
472
- }, 1000 );
473
- }
474
- },
475
-
476
- /**
477
- * Hide navigation and title bars
478
- */
479
- hideBars : function () {
480
- var bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
481
- if ( this.doCssTrans() ) {
482
- bars.removeClass( 'visible-bars' );
483
- } else {
484
- $( '#swipebox-top-bar' ).animate( { top : '-50px' }, 500 );
485
- $( '#swipebox-bottom-bar' ).animate( { bottom : '-50px' }, 500 );
486
- setTimeout( function() {
472
+ } else {
473
+ $( '#swipebox-top-bar' ).animate( { top : 0 }, 500 );
474
+ $( '#swipebox-bottom-bar' ).animate( { bottom : 0 }, 500 );
475
+ setTimeout( function() {
476
+ bars.addClass( 'visible-bars' );
477
+ }, 1000 );
478
+ }
479
+ },
480
+
481
+ /**
482
+ * Hide navigation and title bars
483
+ */
484
+ hideBars : function () {
485
+ var bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
486
+ if ( this.doCssTrans() ) {
487
487
  bars.removeClass( 'visible-bars' );
488
- }, 1000 );
489
- }
490
- },
488
+ } else {
489
+ $( '#swipebox-top-bar' ).animate( { top : '-50px' }, 500 );
490
+ $( '#swipebox-bottom-bar' ).animate( { bottom : '-50px' }, 500 );
491
+ setTimeout( function() {
492
+ bars.removeClass( 'visible-bars' );
493
+ }, 1000 );
494
+ }
495
+ },
496
+
497
+ /**
498
+ * Animate navigation and top bars
499
+ */
500
+ animBars : function () {
501
+ var $this = this,
502
+ bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
491
503
 
492
- /**
493
- * Animate navigation and top bars
494
- */
495
- animBars : function () {
496
- var $this = this,
497
- bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' );
504
+ bars.addClass( 'visible-bars' );
505
+ $this.setTimeout();
498
506
 
499
- bars.addClass( 'visible-bars' );
500
- $this.setTimeout();
507
+ $( '#swipebox-slider' ).click( function() {
508
+ if ( ! bars.hasClass( 'visible-bars' ) ) {
509
+ $this.showBars();
510
+ $this.setTimeout();
511
+ }
512
+ } );
501
513
 
502
- $( '#swipebox-slider' ).click( function() {
503
- if ( ! bars.hasClass( 'visible-bars' ) ) {
514
+ $( '#swipebox-bottom-bar' ).hover( function() {
504
515
  $this.showBars();
505
- $this.setTimeout();
506
- }
507
- } );
516
+ bars.addClass( 'visible-bars' );
517
+ $this.clearTimeout();
508
518
 
509
- $( '#swipebox-bottom-bar' ).hover( function() {
510
- $this.showBars();
511
- bars.addClass( 'visible-bars' );
512
- $this.clearTimeout();
519
+ }, function() {
520
+ if ( plugin.settings.hideBarsDelay > 0 ) {
521
+ bars.removeClass( 'visible-bars' );
522
+ $this.setTimeout();
523
+ }
513
524
 
514
- }, function() {
515
- if ( plugin.settings.hideBarsDelay > 0 ) {
516
- bars.removeClass( 'visible-bars' );
517
- $this.setTimeout();
518
- }
525
+ } );
526
+ },
519
527
 
520
- } );
521
- },
528
+ /**
529
+ * Keyboard navigation
530
+ */
531
+ keyboard : function () {
532
+ var $this = this;
533
+ $( window ).bind( 'keyup', function( event ) {
534
+ event.preventDefault();
535
+ event.stopPropagation();
522
536
 
523
- /**
524
- * Keyboard navigation
525
- */
526
- keyboard : function () {
527
- var $this = this;
528
- $( window ).bind( 'keyup', function( event ) {
529
- event.preventDefault();
530
- event.stopPropagation();
537
+ if ( event.keyCode === 37 ) {
531
538
 
532
- if ( event.keyCode === 37 ) {
539
+ $this.getPrev();
533
540
 
534
- $this.getPrev();
541
+ } else if ( event.keyCode === 39 ) {
535
542
 
536
- } else if ( event.keyCode === 39 ) {
543
+ $this.getNext();
537
544
 
538
- $this.getNext();
545
+ } else if ( event.keyCode === 27 ) {
539
546
 
540
- } else if ( event.keyCode === 27 ) {
547
+ $this.closeSlide();
548
+ }
549
+ } );
550
+ },
541
551
 
542
- $this.closeSlide();
543
- }
544
- } );
545
- },
552
+ /**
553
+ * Navigation events : go to next slide, go to prevous slide and close
554
+ */
555
+ actions : function () {
556
+ var $this = this,
557
+ action = 'touchend click'; // Just detect for both event types to allow for multi-input
546
558
 
547
- /**
548
- * Navigation events : go to next slide, go to prevous slide and close
549
- */
550
- actions : function () {
551
- var $this = this,
552
- action = 'touchend click'; // Just detect for both event types to allow for multi-input
559
+ if ( elements.length < 2 ) {
553
560
 
554
- if ( elements.length < 2 ) {
561
+ $( '#swipebox-bottom-bar' ).hide();
555
562
 
556
- $( '#swipebox-bottom-bar' ).hide();
563
+ if ( undefined === elements[ 1 ] ) {
564
+ $( '#swipebox-top-bar' ).hide();
565
+ }
557
566
 
558
- if ( undefined === elements[ 1 ] ) {
559
- $( '#swipebox-top-bar' ).hide();
567
+ } else {
568
+ $( '#swipebox-prev' ).bind( action, function( event ) {
569
+ event.preventDefault();
570
+ event.stopPropagation();
571
+ $this.getPrev();
572
+ $this.setTimeout();
573
+ } );
574
+
575
+ $( '#swipebox-next' ).bind( action, function( event ) {
576
+ event.preventDefault();
577
+ event.stopPropagation();
578
+ $this.getNext();
579
+ $this.setTimeout();
580
+ } );
560
581
  }
561
582
 
562
- } else {
563
- $( '#swipebox-prev' ).bind( action, function( event ) {
564
- event.preventDefault();
565
- event.stopPropagation();
566
- $this.getPrev();
567
- $this.setTimeout();
583
+ $( '#swipebox-close' ).bind( action, function() {
584
+ $this.closeSlide();
568
585
  } );
586
+ },
569
587
 
570
- $( '#swipebox-next' ).bind( action, function( event ) {
571
- event.preventDefault();
572
- event.stopPropagation();
573
- $this.getNext();
574
- $this.setTimeout();
575
- } );
576
- }
588
+ /**
589
+ * Set current slide
590
+ */
591
+ setSlide : function ( index, isFirst ) {
577
592
 
578
- $( '#swipebox-close' ).bind( action, function() {
579
- $this.closeSlide();
580
- } );
581
- },
593
+ isFirst = isFirst || false;
582
594
 
583
- /**
584
- * Set current slide
585
- */
586
- setSlide : function ( index, isFirst ) {
595
+ var slider = $( '#swipebox-slider' );
587
596
 
588
- isFirst = isFirst || false;
597
+ currentX = -index*100;
589
598
 
590
- var slider = $( '#swipebox-slider' );
599
+ if ( this.doCssTrans() ) {
600
+ slider.css( {
601
+ '-webkit-transform' : 'translate3d(' + (-index*100)+'%, 0, 0)',
602
+ 'transform' : 'translate3d(' + (-index*100)+'%, 0, 0)'
603
+ } );
604
+ } else {
605
+ slider.animate( { left : ( -index*100 )+'%' } );
606
+ }
591
607
 
592
- currentX = -index*100;
608
+ $( '#swipebox-slider .slide' ).removeClass( 'current' );
609
+ $( '#swipebox-slider .slide' ).eq( index ).addClass( 'current' );
610
+ this.setTitle( index );
593
611
 
594
- if ( this.doCssTrans() ) {
595
- slider.css( {
596
- '-webkit-transform' : 'translate3d(' + (-index*100)+'%, 0, 0)',
597
- 'transform' : 'translate3d(' + (-index*100)+'%, 0, 0)'
598
- } );
599
- } else {
600
- slider.animate( { left : ( -index*100 )+'%' } );
601
- }
612
+ if ( isFirst ) {
613
+ slider.fadeIn();
614
+ }
602
615
 
603
- $( '#swipebox-slider .slide' ).removeClass( 'current' );
604
- $( '#swipebox-slider .slide' ).eq( index ).addClass( 'current' );
605
- this.setTitle( index );
616
+ $( '#swipebox-prev, #swipebox-next' ).removeClass( 'disabled' );
606
617
 
607
- if ( isFirst ) {
608
- slider.fadeIn();
609
- }
618
+ if ( index === 0 ) {
619
+ $( '#swipebox-prev' ).addClass( 'disabled' );
620
+ } else if ( index === elements.length - 1 && plugin.settings.loopAtEnd !== true ) {
621
+ $( '#swipebox-next' ).addClass( 'disabled' );
622
+ }
623
+ },
610
624
 
611
- $( '#swipebox-prev, #swipebox-next' ).removeClass( 'disabled' );
625
+ /**
626
+ * Open slide
627
+ */
628
+ openSlide : function ( index ) {
629
+ $( 'html' ).addClass( 'swipebox-html' );
630
+ if ( isTouch ) {
631
+ $( 'html' ).addClass( 'swipebox-touch' );
612
632
 
613
- if ( index === 0 ) {
614
- $( '#swipebox-prev' ).addClass( 'disabled' );
615
- } else if ( index === elements.length - 1 && plugin.settings.loopAtEnd !== true ) {
616
- $( '#swipebox-next' ).addClass( 'disabled' );
617
- }
618
- },
633
+ if ( plugin.settings.hideCloseButtonOnMobile ) {
634
+ $( 'html' ).addClass( 'swipebox-no-close-button' );
635
+ }
636
+ } else {
637
+ $( 'html' ).addClass( 'swipebox-no-touch' );
638
+ }
639
+ $( window ).trigger( 'resize' ); // fix scroll bar visibility on desktop
640
+ this.setSlide( index, true );
641
+ },
619
642
 
620
- /**
621
- * Open slide
622
- */
623
- openSlide : function ( index ) {
624
- $( 'html' ).addClass( 'swipebox-html' );
625
- if ( isTouch ) {
626
- $( 'html' ).addClass( 'swipebox-touch' );
643
+ /**
644
+ * Set a time out if the media is a video
645
+ */
646
+ preloadMedia : function ( index ) {
647
+ var $this = this,
648
+ src = null;
627
649
 
628
- if ( plugin.settings.hideCloseButtonOnMobile ) {
629
- $( 'html' ).addClass( 'swipebox-no-close-button' );
650
+ if ( elements[ index ] !== undefined ) {
651
+ src = elements[ index ].href;
630
652
  }
631
- } else {
632
- $( 'html' ).addClass( 'swipebox-no-touch' );
633
- }
634
- $( window ).trigger( 'resize' ); // fix scroll bar visibility on desktop
635
- this.setSlide( index, true );
636
- },
637
-
638
- /**
639
- * Set a time out if the media is a video
640
- */
641
- preloadMedia : function ( index ) {
642
- var $this = this,
643
- src = null;
644
-
645
- if ( elements[ index ] !== undefined ) {
646
- src = elements[ index ].href;
647
- }
648
653
 
649
- if ( ! $this.isVideo( src ) ) {
650
- setTimeout( function() {
654
+ if ( ! $this.isVideo( src ) ) {
655
+ setTimeout( function() {
656
+ $this.openMedia( index );
657
+ }, 1000);
658
+ } else {
651
659
  $this.openMedia( index );
652
- }, 1000);
653
- } else {
654
- $this.openMedia( index );
655
- }
656
- },
657
-
658
- /**
659
- * Open
660
- */
661
- openMedia : function ( index ) {
662
- var $this = this,
663
- src,
664
- slide;
665
-
666
- if ( elements[ index ] !== undefined ) {
667
- src = elements[ index ].href;
668
- }
660
+ }
661
+ },
669
662
 
670
- if ( index < 0 || index >= elements.length ) {
671
- return false;
672
- }
663
+ /**
664
+ * Open
665
+ */
666
+ openMedia : function ( index ) {
667
+ var $this = this,
668
+ src,
669
+ slide;
673
670
 
674
- slide = $( '#swipebox-slider .slide' ).eq( index );
671
+ if ( elements[ index ] !== undefined ) {
672
+ src = elements[ index ].href;
673
+ }
675
674
 
676
- if ( ! $this.isVideo( src ) ) {
677
- slide.addClass( 'slide-loading' );
678
- $this.loadMedia( src, function() {
679
- slide.removeClass( 'slide-loading' );
680
- slide.html( this );
681
- } );
682
- } else {
683
- slide.html( $this.getVideo( src ) );
684
- }
675
+ if ( index < 0 || index >= elements.length ) {
676
+ return false;
677
+ }
685
678
 
686
- },
679
+ slide = $( '#swipebox-slider .slide' ).eq( index );
687
680
 
688
- /**
689
- * Set link title attribute as caption
690
- */
691
- setTitle : function ( index ) {
692
- var title = null;
681
+ if ( ! $this.isVideo( src ) ) {
682
+ slide.addClass( 'slide-loading' );
683
+ $this.loadMedia( src, function() {
684
+ slide.removeClass( 'slide-loading' );
685
+ slide.html( this );
686
+ } );
687
+ } else {
688
+ slide.html( $this.getVideo( src ) );
689
+ }
693
690
 
694
- $( '#swipebox-title' ).empty();
691
+ },
695
692
 
696
- if ( elements[ index ] !== undefined ) {
697
- title = elements[ index ].title;
698
- }
693
+ /**
694
+ * Set link title attribute as caption
695
+ */
696
+ setTitle : function ( index ) {
697
+ var title = null;
699
698
 
700
- if ( title ) {
701
- $( '#swipebox-top-bar' ).show();
702
- $( '#swipebox-title' ).append( title );
703
- } else {
704
- $( '#swipebox-top-bar' ).hide();
705
- }
706
- },
699
+ $( '#swipebox-title' ).empty();
707
700
 
708
- /**
709
- * Check if the URL is a video
710
- */
711
- isVideo : function ( src ) {
701
+ if ( elements[ index ] !== undefined ) {
702
+ title = elements[ index ].title;
703
+ }
712
704
 
713
- if ( src ) {
714
- if ( src.match( /youtube\.com\/watch\?v=([a-zA-Z0-9\-_]+)/) || src.match( /vimeo\.com\/([0-9]*)/ ) || src.match( /youtu\.be\/([a-zA-Z0-9\-_]+)/ ) ) {
715
- return true;
705
+ if ( title ) {
706
+ $( '#swipebox-top-bar' ).show();
707
+ $( '#swipebox-title' ).append( title );
708
+ } else {
709
+ $( '#swipebox-top-bar' ).hide();
716
710
  }
711
+ },
717
712
 
718
- if ( src.toLowerCase().indexOf( 'swipeboxvideo=1' ) >= 0 ) {
713
+ /**
714
+ * Check if the URL is a video
715
+ */
716
+ isVideo : function ( src ) {
719
717
 
720
- return true;
721
- }
722
- }
718
+ if ( src ) {
719
+ if ( src.match( /(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/) || src.match( /vimeo\.com\/([0-9]*)/ ) || src.match( /youtu\.be\/([a-zA-Z0-9\-_]+)/ ) ) {
720
+ return true;
721
+ }
723
722
 
724
- },
723
+ if ( src.toLowerCase().indexOf( 'swipeboxvideo=1' ) >= 0 ) {
725
724
 
726
- /**
727
- * Get video iframe code from URL
728
- */
729
- getVideo : function( url ) {
730
- var iframe = '',
731
- youtubeUrl = url.match( /watch\?v=([a-zA-Z0-9\-_]+)/ ),
732
- youtubeShortUrl = url.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/),
733
- vimeoUrl = url.match( /vimeo\.com\/([0-9]*)/ );
734
- if ( youtubeUrl || youtubeShortUrl) {
735
- if ( youtubeShortUrl ) {
736
- youtubeUrl = youtubeShortUrl;
725
+ return true;
726
+ }
737
727
  }
738
- iframe = '<iframe width="560" height="315" src="//www.youtube.com/embed/' + youtubeUrl[1] + '?autoplay='+ plugin.settings.autoplayVideos + '" frameborder="0" allowfullscreen></iframe>';
739
728
 
740
- } else if ( vimeoUrl ) {
729
+ },
730
+
731
+ /**
732
+ * Parse URI querystring and:
733
+ * - overrides value provided via dictionary
734
+ * - rebuild it again returning a string
735
+ */
736
+ parseUri : function (uri, customData) {
737
+ var a = document.createElement('a'),
738
+ qs = {};
739
+
740
+ // Decode the URI
741
+ a.href = decodeURIComponent( uri );
742
+
743
+ // QueryString to Object
744
+ if ( a.search ) {
745
+ qs = JSON.parse( '{"' + a.search.toLowerCase().replace('?','').replace(/&/g,'","').replace(/=/g,'":"') + '"}' );
746
+ }
741
747
 
742
- iframe = '<iframe width="560" height="315" src="//player.vimeo.com/video/' + vimeoUrl[1] + '?byline=0&amp;portrait=0&amp;color=' + plugin.settings.vimeoColor + '&autoplay=' + plugin.settings.autoplayVideos + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
748
+ // Extend with custom data
749
+ if ( $.isPlainObject( customData ) ) {
750
+ qs = $.extend( qs, customData, plugin.settings.queryStringData ); // The dev has always the final word
751
+ }
743
752
 
744
- }
753
+ // Return querystring as a string
754
+ return $
755
+ .map( qs, function (val, key) {
756
+ if ( val && val > '' ) {
757
+ return encodeURIComponent( key ) + '=' + encodeURIComponent( val );
758
+ }
759
+ })
760
+ .join('&');
761
+ },
745
762
 
746
- if ( youtubeUrl || youtubeShortUrl || vimeoUrl ) {
763
+ /**
764
+ * Get video iframe code from URL
765
+ */
766
+ getVideo : function( url ) {
767
+ var iframe = '',
768
+ youtubeUrl = url.match( /((?:www\.)?youtube\.com|(?:www\.)?youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/ ),
769
+ youtubeShortUrl = url.match(/(?:www\.)?youtu\.be\/([a-zA-Z0-9\-_]+)/),
770
+ vimeoUrl = url.match( /(?:www\.)?vimeo\.com\/([0-9]*)/ ),
771
+ qs = '';
772
+ if ( youtubeUrl || youtubeShortUrl) {
773
+ if ( youtubeShortUrl ) {
774
+ youtubeUrl = youtubeShortUrl;
775
+ }
776
+ qs = ui.parseUri( url, {
777
+ 'autoplay' : ( plugin.settings.autoplayVideos ? '1' : '0' ),
778
+ 'v' : ''
779
+ });
780
+ iframe = '<iframe width="560" height="315" src="//' + youtubeUrl[1] + '/embed/' + youtubeUrl[2] + '?' + qs + '" frameborder="0" allowfullscreen></iframe>';
781
+
782
+ } else if ( vimeoUrl ) {
783
+ qs = ui.parseUri( url, {
784
+ 'autoplay' : ( plugin.settings.autoplayVideos ? '1' : '0' ),
785
+ 'byline' : '0',
786
+ 'portrait' : '0',
787
+ 'color': plugin.settings.vimeoColor
788
+ });
789
+ iframe = '<iframe width="560" height="315" src="//player.vimeo.com/video/' + vimeoUrl[1] + '?' + qs + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
747
790
 
748
- } else {
749
- iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>';
750
- }
791
+ } else {
792
+ iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>';
793
+ }
751
794
 
752
- return '<div class="swipebox-video-container" style="max-width:' + plugin.settings.videomaxWidth + 'px"><div class="swipebox-video">' + iframe + '</div></div>';
753
- },
795
+ return '<div class="swipebox-video-container" style="max-width:' + plugin.settings.videoMaxWidth + 'px"><div class="swipebox-video">' + iframe + '</div></div>';
796
+ },
754
797
 
755
- /**
756
- * Load image
757
- */
758
- loadMedia : function ( src, callback ) {
759
- if ( ! this.isVideo( src ) ) {
760
- var img = $( '<img>' ).on( 'load', function() {
761
- callback.call( img );
762
- } );
798
+ /**
799
+ * Load image
800
+ */
801
+ loadMedia : function ( src, callback ) {
802
+ // Inline content
803
+ if ( src.trim().indexOf('#') === 0 ) {
804
+ callback.call(
805
+ $('<div>', {
806
+ 'class' : 'swipebox-inline-container'
807
+ })
808
+ .append(
809
+ $(src)
810
+ .clone()
811
+ .toggleClass( plugin.settings.toggleClassOnLoad )
812
+ )
813
+ );
814
+ }
815
+ // Everything else
816
+ else {
817
+ if ( ! this.isVideo( src ) ) {
818
+ var img = $( '<img>' ).on( 'load', function() {
819
+ callback.call( img );
820
+ } );
821
+
822
+ img.attr( 'src', src );
823
+ }
824
+ }
825
+ },
763
826
 
764
- img.attr( 'src', src );
765
- }
766
- },
767
-
768
- /**
769
- * Get next slide
770
- */
771
- getNext : function () {
772
- var $this = this,
773
- src,
774
- index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) );
775
- if ( index + 1 < elements.length ) {
776
-
777
- src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' );
778
- $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
779
- index++;
780
- $this.setSlide( index );
781
- $this.preloadMedia( index+1 );
782
- } else {
827
+ /**
828
+ * Get next slide
829
+ */
830
+ getNext : function () {
831
+ var $this = this,
832
+ src,
833
+ index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) );
834
+ if ( index + 1 < elements.length ) {
783
835
 
784
- if ( plugin.settings.loopAtEnd === true ) {
785
836
  src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' );
786
837
  $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
787
- index = 0;
788
- $this.preloadMedia( index );
838
+ index++;
789
839
  $this.setSlide( index );
790
- $this.preloadMedia( index + 1 );
840
+ $this.preloadMedia( index+1 );
841
+ if ( plugin.settings.nextSlide ) {
842
+ plugin.settings.nextSlide();
843
+ }
791
844
  } else {
792
- $( '#swipebox-overlay' ).addClass( 'rightSpring' );
845
+
846
+ if ( plugin.settings.loopAtEnd === true ) {
847
+ src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' );
848
+ $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
849
+ index = 0;
850
+ $this.preloadMedia( index );
851
+ $this.setSlide( index );
852
+ $this.preloadMedia( index + 1 );
853
+ if ( plugin.settings.nextSlide ) {
854
+ plugin.settings.nextSlide();
855
+ }
856
+ } else {
857
+ $( '#swipebox-overlay' ).addClass( 'rightSpring' );
858
+ setTimeout( function() {
859
+ $( '#swipebox-overlay' ).removeClass( 'rightSpring' );
860
+ }, 500 );
861
+ }
862
+ }
863
+ },
864
+
865
+ /**
866
+ * Get previous slide
867
+ */
868
+ getPrev : function () {
869
+ var index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) ),
870
+ src;
871
+ if ( index > 0 ) {
872
+ src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe').attr( 'src' );
873
+ $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
874
+ index--;
875
+ this.setSlide( index );
876
+ this.preloadMedia( index-1 );
877
+ if ( plugin.settings.prevSlide ) {
878
+ plugin.settings.prevSlide();
879
+ }
880
+ } else {
881
+ $( '#swipebox-overlay' ).addClass( 'leftSpring' );
793
882
  setTimeout( function() {
794
- $( '#swipebox-overlay' ).removeClass( 'rightSpring' );
883
+ $( '#swipebox-overlay' ).removeClass( 'leftSpring' );
795
884
  }, 500 );
796
885
  }
797
- }
798
- },
799
-
800
- /**
801
- * Get previous slide
802
- */
803
- getPrev : function () {
804
- var index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) ),
805
- src;
806
- if ( index > 0 ) {
807
- src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe').attr( 'src' );
808
- $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src );
809
- index--;
810
- this.setSlide( index );
811
- this.preloadMedia( index-1 );
812
- } else {
813
- $( '#swipebox-overlay' ).addClass( 'leftSpring' );
814
- setTimeout( function() {
815
- $( '#swipebox-overlay' ).removeClass( 'leftSpring' );
816
- }, 500 );
817
- }
818
- },
819
-
820
- /**
821
- * Close
822
- */
823
- closeSlide : function () {
824
- $( 'html' ).removeClass( 'swipebox-html' );
825
- $( 'html' ).removeClass( 'swipebox-touch' );
826
- $( window ).trigger( 'resize' );
827
- this.destroy();
828
- },
829
-
830
- /**
831
- * Destroy the whole thing
832
- */
833
- destroy : function () {
834
- $( window ).unbind( 'keyup' );
835
- $( 'body' ).unbind( 'touchstart' );
836
- $( 'body' ).unbind( 'touchmove' );
837
- $( 'body' ).unbind( 'touchend' );
838
- $( '#swipebox-slider' ).unbind();
839
- $( '#swipebox-overlay' ).remove();
840
-
841
- if ( ! $.isArray( elem ) ) {
842
- elem.removeData( '_swipebox' );
843
- }
886
+ },
844
887
 
845
- if ( this.target ) {
846
- this.target.trigger( 'swipebox-destroy' );
847
- }
888
+ nextSlide : function () {
889
+ // Callback for next slide
890
+ },
891
+
892
+ prevSlide : function () {
893
+ // Callback for prev slide
894
+ },
895
+
896
+ /**
897
+ * Close
898
+ */
899
+ closeSlide : function () {
900
+ $( 'html' ).removeClass( 'swipebox-html' );
901
+ $( 'html' ).removeClass( 'swipebox-touch' );
902
+ $( window ).trigger( 'resize' );
903
+ this.destroy();
904
+ },
848
905
 
849
- $.swipebox.isOpen = false;
906
+ /**
907
+ * Destroy the whole thing
908
+ */
909
+ destroy : function () {
910
+ $( window ).unbind( 'keyup' );
911
+ $( 'body' ).unbind( 'touchstart' );
912
+ $( 'body' ).unbind( 'touchmove' );
913
+ $( 'body' ).unbind( 'touchend' );
914
+ $( '#swipebox-slider' ).unbind();
915
+ $( '#swipebox-overlay' ).remove();
916
+
917
+ if ( ! $.isArray( elem ) ) {
918
+ elem.removeData( '_swipebox' );
919
+ }
920
+
921
+ if ( this.target ) {
922
+ this.target.trigger( 'swipebox-destroy' );
923
+ }
924
+
925
+ $.swipebox.isOpen = false;
850
926
 
851
- if ( plugin.settings.afterClose ) {
852
- plugin.settings.afterClose();
927
+ if ( plugin.settings.afterClose ) {
928
+ plugin.settings.afterClose();
929
+ }
853
930
  }
854
- }
855
- };
931
+ };
856
932
 
857
- plugin.init();
858
- };
933
+ plugin.init();
934
+ };
859
935
 
860
- $.fn.swipebox = function( options ) {
936
+ $.fn.swipebox = function( options ) {
861
937
 
862
- if ( ! $.data( this, '_swipebox' ) ) {
863
- var swipebox = new $.swipebox( this, options );
864
- this.data( '_swipebox', swipebox );
865
- }
866
- return this.data( '_swipebox' );
938
+ if ( ! $.data( this, '_swipebox' ) ) {
939
+ var swipebox = new $.swipebox( this, options );
940
+ this.data( '_swipebox', swipebox );
941
+ }
942
+ return this.data( '_swipebox' );
867
943
 
868
- };
944
+ };
869
945
 
870
946
  }( window, document, jQuery ) );
@@ -1,4 +1,4 @@
1
- /*! Swipebox v1.3.0.2 | Constantin Saguin csag.co | MIT License | github.com/brutaldesign/swipebox */
1
+ /*! Swipebox v1.4.1 | Constantin Saguin csag.co | MIT License | github.com/brutaldesign/swipebox */
2
2
 
3
3
  html.swipebox-html.swipebox-touch {
4
4
  overflow: hidden !important;
@@ -51,7 +51,7 @@ html.swipebox-html.swipebox-touch {
51
51
  width: 1px;
52
52
  margin-right: -1px;
53
53
  }
54
- img {
54
+ img, .swipebox-video-container, .swipebox-inline-container {
55
55
  display: inline-block;
56
56
  max-height: 100%;
57
57
  max-width: 100%;
@@ -62,14 +62,6 @@ html.swipebox-html.swipebox-touch {
62
62
  vertical-align: middle;
63
63
  }
64
64
  .swipebox-video-container {
65
- display: inline-block;
66
- max-height: 100%;
67
- max-width: 100%;
68
- margin: 0;
69
- padding: 0;
70
- width: auto;
71
- height: auto;
72
- vertical-align: middle;
73
65
  background: none;
74
66
  max-width: 1140px;
75
67
  max-height: 100%;
@@ -225,9 +217,11 @@ html.swipebox-html.swipebox-touch {
225
217
  0% {
226
218
  left: 0;
227
219
  }
220
+
228
221
  50% {
229
222
  left: -30px;
230
223
  }
224
+
231
225
  100% {
232
226
  left: 0;
233
227
  }
@@ -238,9 +232,11 @@ html.swipebox-html.swipebox-touch {
238
232
  0% {
239
233
  left: 0;
240
234
  }
235
+
241
236
  50% {
242
237
  left: -30px;
243
238
  }
239
+
244
240
  100% {
245
241
  left: 0;
246
242
  }
@@ -251,9 +247,11 @@ html.swipebox-html.swipebox-touch {
251
247
  0% {
252
248
  left: 0;
253
249
  }
250
+
254
251
  50% {
255
252
  left: 30px;
256
253
  }
254
+
257
255
  100% {
258
256
  left: 0;
259
257
  }
@@ -264,9 +262,11 @@ html.swipebox-html.swipebox-touch {
264
262
  0% {
265
263
  left: 0;
266
264
  }
265
+
267
266
  50% {
268
267
  left: 30px;
269
268
  }
269
+
270
270
  100% {
271
271
  left: 0;
272
272
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swipebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.2
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miha Rekar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-02 00:00:00.000000000 Z
11
+ date: 2015-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project:
168
- rubygems_version: 2.2.2
168
+ rubygems_version: 2.4.8
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: Wrapper for Swipebox by @brutaldesign