jquery-slick-rails 1.5.2 → 1.5.3

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: 533738ae6c1493c8d180c97a8e6f554c7fd9ae24
4
- data.tar.gz: bb334b1b5456a62a85d66f29ad8b2c2ecf02e35c
3
+ metadata.gz: d67e983b7606223671c5310cd03917072cde8947
4
+ data.tar.gz: d744af417f8362f850df41e8ffac1bb55f7c8caf
5
5
  SHA512:
6
- metadata.gz: 82898a6640ebecccb8d8a296bfd2ebb4a75bdf929ef121db0062cef15dfc051fb91016a79c19b7b9872f413145129a915502908830e4548ed9c3cde93610c0f2
7
- data.tar.gz: a805cc52e1d738838214e7db8dfcf8ec0ad6eb8fcf05b9885c7470b6ec1972ad58d18e99fcf7996abab9fc308c985eb84734f3e6aadb5b0768b1b096058c457a
6
+ metadata.gz: f465915f9ac2a166a86b352ccb273c0a185d17884a9826dfe69e60a498ee3c5b15825d96ef7535e67fff17d8937c78057d61d0e82aacfbad5252a8966655b4c1
7
+ data.tar.gz: e0973f777b084cab27577fcb1c81c970e46cda81c13e8df98a338e7b680948d5cdf94cf1b9c237ffc8f13ae5356fbcf5f8918e3689a0895c01b8c70068a53b09
@@ -6,7 +6,7 @@
6
6
  |___/_|_|\___|_|\_(_)/ |___/
7
7
  |__/
8
8
 
9
- Version: 1.5.2
9
+ Version: 1.5.3
10
10
  Author: Ken Wheeler
11
11
  Website: http://kenwheeler.github.io
12
12
  Docs: http://kenwheeler.github.io/slick
@@ -111,7 +111,8 @@
111
111
  swipeLeft: null,
112
112
  $list: null,
113
113
  touchObject: {},
114
- transformsEnabled: false
114
+ transformsEnabled: false,
115
+ unslicked: false
115
116
  };
116
117
 
117
118
  $.extend(_, _.initials);
@@ -191,7 +192,7 @@
191
192
  // Extracted from jQuery v1.11 source
192
193
  _.htmlExpr = /^(?:\s*(<[\w\W]+>)[^>]*)$/;
193
194
 
194
- _.init();
195
+ _.init(true);
195
196
 
196
197
  _.checkResponsive(true);
197
198
 
@@ -294,11 +295,11 @@
294
295
  now = Math.ceil(now);
295
296
  if (_.options.vertical === false) {
296
297
  animProps[_.animType] = 'translate(' +
297
- now + 'px, 0px)';
298
+ now + 'px, 0px)';
298
299
  _.$slideTrack.css(animProps);
299
300
  } else {
300
301
  animProps[_.animType] = 'translate(0px,' +
301
- now + 'px)';
302
+ now + 'px)';
302
303
  _.$slideTrack.css(animProps);
303
304
  }
304
305
  },
@@ -337,9 +338,23 @@
337
338
  };
338
339
 
339
340
  Slick.prototype.asNavFor = function(index) {
341
+
340
342
  var _ = this,
341
- asNavFor = _.options.asNavFor !== null ? $(_.options.asNavFor).slick('getSlick') : null;
342
- if (asNavFor !== null) asNavFor.slideHandler(index, true);
343
+ asNavFor = _.options.asNavFor;
344
+
345
+ if ( asNavFor && asNavFor !== null ) {
346
+ asNavFor = $(asNavFor).not(_.$slider);
347
+ }
348
+
349
+ if ( asNavFor !== null && typeof asNavFor === "object" ) {
350
+ asNavFor.each(function() {
351
+ var target = $(this).slick('getSlick');
352
+ if(!target.unslicked) {
353
+ target.slideHandler(index, true);
354
+ }
355
+ });
356
+ }
357
+
343
358
  };
344
359
 
345
360
  Slick.prototype.applyTransition = function(slide) {
@@ -479,7 +494,9 @@
479
494
  _.slideCount = _.$slides.length;
480
495
 
481
496
  _.$slides.each(function(index, element) {
482
- $(element).attr('data-slick-index', index);
497
+ $(element)
498
+ .attr('data-slick-index', index)
499
+ .data('originalStyling', $(element).attr('style') || '');
483
500
  });
484
501
 
485
502
  _.$slidesCache = _.$slides;
@@ -558,9 +575,10 @@
558
575
  Slick.prototype.checkResponsive = function(initial) {
559
576
 
560
577
  var _ = this,
561
- breakpoint, targetBreakpoint, respondToWidth;
578
+ breakpoint, targetBreakpoint, respondToWidth, triggerBreakpoint = false;
562
579
  var sliderWidth = _.$slider.width();
563
580
  var windowWidth = window.innerWidth || $(window).width();
581
+
564
582
  if (_.respondTo === 'window') {
565
583
  respondToWidth = windowWidth;
566
584
  } else if (_.respondTo === 'slider') {
@@ -594,42 +612,49 @@
594
612
  _.activeBreakpoint =
595
613
  targetBreakpoint;
596
614
  if (_.breakpointSettings[targetBreakpoint] === 'unslick') {
597
- _.unslick();
615
+ _.unslick(targetBreakpoint);
598
616
  } else {
599
617
  _.options = $.extend({}, _.originalSettings,
600
618
  _.breakpointSettings[
601
619
  targetBreakpoint]);
602
- if (initial === true)
620
+ if (initial === true) {
603
621
  _.currentSlide = _.options.initialSlide;
604
- _.refresh();
622
+ }
623
+ _.refresh(initial);
605
624
  }
606
- _.$slider.trigger('breakpoint', [_, targetBreakpoint]);
625
+ triggerBreakpoint = targetBreakpoint;
607
626
  }
608
627
  } else {
609
628
  _.activeBreakpoint = targetBreakpoint;
610
629
  if (_.breakpointSettings[targetBreakpoint] === 'unslick') {
611
- _.unslick();
630
+ _.unslick(targetBreakpoint);
612
631
  } else {
613
632
  _.options = $.extend({}, _.originalSettings,
614
633
  _.breakpointSettings[
615
634
  targetBreakpoint]);
616
- if (initial === true)
635
+ if (initial === true) {
617
636
  _.currentSlide = _.options.initialSlide;
618
- _.refresh();
637
+ }
638
+ _.refresh(initial);
619
639
  }
620
- _.$slider.trigger('breakpoint', [_, targetBreakpoint]);
640
+ triggerBreakpoint = targetBreakpoint;
621
641
  }
622
642
  } else {
623
643
  if (_.activeBreakpoint !== null) {
624
644
  _.activeBreakpoint = null;
625
645
  _.options = _.originalSettings;
626
- if (initial === true)
646
+ if (initial === true) {
627
647
  _.currentSlide = _.options.initialSlide;
628
- _.refresh();
629
- _.$slider.trigger('breakpoint', [_, targetBreakpoint]);
648
+ }
649
+ _.refresh(initial);
650
+ triggerBreakpoint = targetBreakpoint;
630
651
  }
631
652
  }
632
653
 
654
+ // only trigger breakpoints during an actual break. not on initialize.
655
+ if( !initial && triggerBreakpoint !== false ) {
656
+ _.$slider.trigger('breakpoint', [_, triggerBreakpoint]);
657
+ }
633
658
  }
634
659
 
635
660
  };
@@ -641,7 +666,14 @@
641
666
  indexOffset, slideOffset, unevenOffset;
642
667
 
643
668
  // If target is a link, prevent default action.
644
- $target.is('a') && event.preventDefault();
669
+ if($target.is('a')) {
670
+ event.preventDefault();
671
+ }
672
+
673
+ // If target is not the <li> element (ie: a child), find the <li>.
674
+ if(!$target.is('li')) {
675
+ $target = $target.closest('li');
676
+ }
645
677
 
646
678
  unevenOffset = (_.slideCount % _.options.slidesToScroll !== 0);
647
679
  indexOffset = unevenOffset ? 0 : (_.slideCount - _.currentSlide) % _.options.slidesToScroll;
@@ -664,9 +696,10 @@
664
696
 
665
697
  case 'index':
666
698
  var index = event.data.index === 0 ? 0 :
667
- event.data.index || $(event.target).parent().index() * _.options.slidesToScroll;
699
+ event.data.index || $target.index() * _.options.slidesToScroll;
668
700
 
669
701
  _.slideHandler(_.checkNavigable(index), false, dontAnimate);
702
+ $target.children().trigger("focus");
670
703
  break;
671
704
 
672
705
  default:
@@ -701,14 +734,18 @@
701
734
 
702
735
  var _ = this;
703
736
 
704
- if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
737
+ if (_.options.dots && _.$dots !== null) {
738
+
705
739
  $('li', _.$dots).off('click.slick', _.changeSlide);
706
- }
707
740
 
708
- if (_.options.dots === true && _.options.pauseOnDotsHover === true && _.options.autoplay === true) {
709
- $('li', _.$dots)
710
- .off('mouseenter.slick', $.proxy(_.setPaused, _, true))
711
- .off('mouseleave.slick', $.proxy(_.setPaused, _, false));
741
+ if (_.options.pauseOnDotsHover === true && _.options.autoplay === true) {
742
+
743
+ $('li', _.$dots)
744
+ .off('mouseenter.slick', $.proxy(_.setPaused, _, true))
745
+ .off('mouseleave.slick', $.proxy(_.setPaused, _, false));
746
+
747
+ }
748
+
712
749
  }
713
750
 
714
751
  if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
@@ -770,7 +807,7 @@
770
807
 
771
808
  };
772
809
 
773
- Slick.prototype.destroy = function() {
810
+ Slick.prototype.destroy = function(refresh) {
774
811
 
775
812
  var _ = this;
776
813
 
@@ -793,16 +830,13 @@
793
830
  }
794
831
 
795
832
  if (_.$slides) {
796
- _.$slides.removeClass('slick-slide slick-active slick-center slick-visible')
833
+
834
+ _.$slides
835
+ .removeClass('slick-slide slick-active slick-center slick-visible')
797
836
  .removeAttr('aria-hidden')
798
837
  .removeAttr('data-slick-index')
799
- .css({
800
- position: '',
801
- left: '',
802
- top: '',
803
- zIndex: '',
804
- opacity: '',
805
- width: ''
838
+ .each(function(){
839
+ $(this).attr('style', $(this).data('originalStyling'));
806
840
  });
807
841
 
808
842
  _.$slideTrack.children(this.options.slide).detach();
@@ -819,6 +853,12 @@
819
853
  _.$slider.removeClass('slick-slider');
820
854
  _.$slider.removeClass('slick-initialized');
821
855
 
856
+ _.unslicked = true;
857
+
858
+ if(!refresh) {
859
+ _.$slider.trigger('destroy', [_]);
860
+ }
861
+
822
862
  };
823
863
 
824
864
  Slick.prototype.disableTransition = function(slide) {
@@ -1019,8 +1059,7 @@
1019
1059
  max;
1020
1060
 
1021
1061
  if (_.options.infinite === false) {
1022
- max = _.slideCount - _.options.slidesToShow + 1;
1023
- if (_.options.centerMode === true) max = _.slideCount;
1062
+ max = _.slideCount;
1024
1063
  } else {
1025
1064
  breakPoint = _.options.slidesToScroll * -1;
1026
1065
  counter = _.options.slidesToScroll * -1;
@@ -1081,7 +1120,7 @@
1081
1120
 
1082
1121
  };
1083
1122
 
1084
- Slick.prototype.init = function() {
1123
+ Slick.prototype.init = function(creation) {
1085
1124
 
1086
1125
  var _ = this;
1087
1126
 
@@ -1098,7 +1137,9 @@
1098
1137
  _.updateDots();
1099
1138
  }
1100
1139
 
1101
- _.$slider.trigger('init', [_]);
1140
+ if (creation) {
1141
+ _.$slider.trigger('init', [_]);
1142
+ }
1102
1143
 
1103
1144
  };
1104
1145
 
@@ -1407,23 +1448,27 @@
1407
1448
 
1408
1449
  };
1409
1450
 
1410
- Slick.prototype.refresh = function() {
1451
+ Slick.prototype.refresh = function( initializing ) {
1411
1452
 
1412
1453
  var _ = this,
1413
1454
  currentSlide = _.currentSlide;
1414
1455
 
1415
- _.destroy();
1456
+ _.destroy(true);
1416
1457
 
1417
1458
  $.extend(_, _.initials);
1418
1459
 
1419
1460
  _.init();
1420
1461
 
1421
- _.changeSlide({
1422
- data: {
1423
- message: 'index',
1424
- index: currentSlide
1425
- }
1426
- }, false);
1462
+ if( !initializing ) {
1463
+
1464
+ _.changeSlide({
1465
+ data: {
1466
+ message: 'index',
1467
+ index: currentSlide
1468
+ }
1469
+ }, false);
1470
+
1471
+ }
1427
1472
 
1428
1473
  };
1429
1474
 
@@ -1481,7 +1526,7 @@
1481
1526
  _.windowDelay = window.setTimeout(function() {
1482
1527
  _.windowWidth = $(window).width();
1483
1528
  _.checkResponsive();
1484
- _.setPosition();
1529
+ if( !_.unslicked ) { _.setPosition(); }
1485
1530
  }, 50);
1486
1531
  }
1487
1532
  };
@@ -2080,11 +2125,11 @@
2080
2125
  event.originalEvent.touches.length : 1;
2081
2126
 
2082
2127
  _.touchObject.minSwipe = _.listWidth / _.options
2083
- .touchThreshold;
2128
+ .touchThreshold;
2084
2129
 
2085
2130
  if (_.options.verticalSwiping === true) {
2086
2131
  _.touchObject.minSwipe = _.listHeight / _.options
2087
- .touchThreshold;
2132
+ .touchThreshold;
2088
2133
  }
2089
2134
 
2090
2135
  switch (event.data.action) {
@@ -2236,9 +2281,10 @@
2236
2281
 
2237
2282
  };
2238
2283
 
2239
- Slick.prototype.unslick = function() {
2284
+ Slick.prototype.unslick = function(fromBreakpoint) {
2240
2285
 
2241
2286
  var _ = this;
2287
+ _.$slider.trigger('unslick', [_, fromBreakpoint]);
2242
2288
  _.destroy();
2243
2289
 
2244
2290
  };
@@ -1,3 +1,3 @@
1
1
  module JquerySlickRails
2
- VERSION = "1.5.2"
2
+ VERSION = "1.5.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-slick-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bodrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-25 00:00:00.000000000 Z
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties