materialize-sass 0.99.0 → 0.100.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/app/assets/javascripts/materialize.js +6015 -5060
  4. data/app/assets/javascripts/materialize/animation.js +4 -5
  5. data/app/assets/javascripts/materialize/buttons.js +24 -38
  6. data/app/assets/javascripts/materialize/cards.js +13 -21
  7. data/app/assets/javascripts/materialize/carousel.js +122 -110
  8. data/app/assets/javascripts/materialize/character_counter.js +14 -22
  9. data/app/assets/javascripts/materialize/chips.js +41 -44
  10. data/app/assets/javascripts/materialize/collapsible.js +41 -46
  11. data/app/assets/javascripts/materialize/date_picker/picker.date.js +965 -1167
  12. data/app/assets/javascripts/materialize/date_picker/picker.js +546 -634
  13. data/app/assets/javascripts/materialize/date_picker/picker.time.js +166 -212
  14. data/app/assets/javascripts/materialize/dropdown.js +53 -68
  15. data/app/assets/javascripts/materialize/extras/nouislider.js +3 -1
  16. data/app/assets/javascripts/materialize/extras/nouislider.min.js +1 -1
  17. data/app/assets/javascripts/materialize/forms.js +156 -154
  18. data/app/assets/javascripts/materialize/global.js +34 -43
  19. data/app/assets/javascripts/materialize/hammer.min.js +424 -1
  20. data/app/assets/javascripts/materialize/initial.js +3 -3
  21. data/app/assets/javascripts/materialize/jquery.easing.1.4.js +120 -142
  22. data/app/assets/javascripts/materialize/jquery.hammer.js +9 -9
  23. data/app/assets/javascripts/materialize/materialbox.js +81 -107
  24. data/app/assets/javascripts/materialize/modal.js +373 -162
  25. data/app/assets/javascripts/materialize/parallax.js +11 -15
  26. data/app/assets/javascripts/materialize/pushpin.js +2 -5
  27. data/app/assets/javascripts/materialize/scrollFire.js +9 -11
  28. data/app/assets/javascripts/materialize/scrollspy.js +84 -92
  29. data/app/assets/javascripts/materialize/sideNav.js +128 -139
  30. data/app/assets/javascripts/materialize/slider.js +83 -112
  31. data/app/assets/javascripts/materialize/tabs.js +196 -196
  32. data/app/assets/javascripts/materialize/tapTarget.js +170 -173
  33. data/app/assets/javascripts/materialize/toasts.js +330 -112
  34. data/app/assets/javascripts/materialize/tooltip.js +134 -145
  35. data/app/assets/javascripts/materialize/transitions.js +43 -49
  36. data/app/assets/javascripts/materialize/velocity.min.js +623 -2
  37. data/app/assets/javascripts/materialize/waves.js +42 -47
  38. data/app/assets/stylesheets/materialize/components/_buttons.scss +1 -1
  39. data/app/assets/stylesheets/materialize/components/_carousel.scss +4 -5
  40. data/app/assets/stylesheets/materialize/components/_chips.scss +1 -0
  41. data/app/assets/stylesheets/materialize/components/_collapsible.scss +4 -7
  42. data/app/assets/stylesheets/materialize/components/_color.scss +1 -1
  43. data/app/assets/stylesheets/materialize/components/_global.scss +8 -14
  44. data/app/assets/stylesheets/materialize/components/_navbar.scss +0 -1
  45. data/app/assets/stylesheets/materialize/components/_tabs.scss +1 -7
  46. data/app/assets/stylesheets/materialize/components/_toast.scss +6 -12
  47. data/app/assets/stylesheets/materialize/components/_variables.scss +55 -43
  48. data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +1 -0
  49. data/app/assets/stylesheets/materialize/components/forms/_checkboxes.scss +2 -12
  50. data/app/assets/stylesheets/materialize/components/forms/_file-input.scss +6 -0
  51. data/app/assets/stylesheets/materialize/components/forms/_input-fields.scss +67 -37
  52. data/app/assets/stylesheets/materialize/components/forms/_radio-buttons.scss +1 -3
  53. data/app/assets/stylesheets/materialize/components/forms/_select.scss +72 -11
  54. data/app/assets/stylesheets/materialize/components/forms/_switches.scss +2 -4
  55. data/app/assets/stylesheets/materialize/extras/nouislider.css +8 -1
  56. data/lib/materialize-sass/version.rb +1 -1
  57. metadata +2 -5
  58. data/app/assets/javascripts/materialize/init.js +0 -214
  59. data/app/assets/javascripts/materialize/jquery.timeago.min.js +0 -1
  60. data/app/assets/javascripts/materialize/prism.js +0 -8
@@ -1,8 +1,7 @@
1
1
  // Custom Easing
2
- jQuery.extend( jQuery.easing,
3
- {
2
+ jQuery.extend(jQuery.easing, {
4
3
  easeInOutMaterial: function (x, t, b, c, d) {
5
- if ((t/=d/2) < 1) return c/2*t*t + b;
6
- return c/4*((t-=2)*t*t + 2) + b;
4
+ if ((t /= d / 2) < 1) return c / 2 * t * t + b;
5
+ return c / 4 * ((t -= 2) * t * t + 2) + b;
7
6
  }
8
- });
7
+ });
@@ -1,21 +1,21 @@
1
1
  (function ($) {
2
- $(document).on('ready turbolinks:load', function() {
2
+ $(document).on('ready turbolinks:load', function () {
3
3
 
4
4
  // jQuery reverse
5
5
  $.fn.reverse = [].reverse;
6
6
 
7
7
  // Hover behaviour: make sure this doesn't work on .click-to-toggle FABs!
8
- $(document).on('mouseenter.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle):not(.toolbar)', function(e) {
8
+ $(document).on('mouseenter.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle):not(.toolbar)', function (e) {
9
9
  var $this = $(this);
10
10
  openFABMenu($this);
11
11
  });
12
- $(document).on('mouseleave.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle):not(.toolbar)', function(e) {
12
+ $(document).on('mouseleave.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle):not(.toolbar)', function (e) {
13
13
  var $this = $(this);
14
14
  closeFABMenu($this);
15
15
  });
16
16
 
17
17
  // Toggle-on-click behaviour.
18
- $(document).on('click.fabClickToggle', '.fixed-action-btn.click-to-toggle > a', function(e) {
18
+ $(document).on('click.fabClickToggle', '.fixed-action-btn.click-to-toggle > a', function (e) {
19
19
  var $this = $(this);
20
20
  var $menu = $this.parent();
21
21
  if ($menu.hasClass('active')) {
@@ -26,30 +26,28 @@
26
26
  });
27
27
 
28
28
  // Toolbar transition behaviour.
29
- $(document).on('click.fabToolbar', '.fixed-action-btn.toolbar > a', function(e) {
29
+ $(document).on('click.fabToolbar', '.fixed-action-btn.toolbar > a', function (e) {
30
30
  var $this = $(this);
31
31
  var $menu = $this.parent();
32
32
  FABtoToolbar($menu);
33
33
  });
34
-
35
34
  });
36
35
 
37
36
  $.fn.extend({
38
- openFAB: function() {
37
+ openFAB: function () {
39
38
  openFABMenu($(this));
40
39
  },
41
- closeFAB: function() {
40
+ closeFAB: function () {
42
41
  closeFABMenu($(this));
43
42
  },
44
- openToolbar: function() {
43
+ openToolbar: function () {
45
44
  FABtoToolbar($(this));
46
45
  },
47
- closeToolbar: function() {
46
+ closeToolbar: function () {
48
47
  toolbarToFAB($(this));
49
48
  }
50
49
  });
51
50
 
52
-
53
51
  var openFABMenu = function (btn) {
54
52
  var $this = btn;
55
53
  if ($this.hasClass('active') === false) {
@@ -65,15 +63,11 @@
65
63
  }
66
64
 
67
65
  $this.addClass('active');
68
- $this.find('ul .btn-floating').velocity(
69
- { scaleY: ".4", scaleX: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px'},
70
- { duration: 0 });
66
+ $this.find('ul .btn-floating').velocity({ scaleY: ".4", scaleX: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px' }, { duration: 0 });
71
67
 
72
68
  var time = 0;
73
- $this.find('ul .btn-floating').reverse().each( function () {
74
- $(this).velocity(
75
- { opacity: "1", scaleX: "1", scaleY: "1", translateY: "0", translateX: '0'},
76
- { duration: 80, delay: time });
69
+ $this.find('ul .btn-floating').reverse().each(function () {
70
+ $(this).velocity({ opacity: "1", scaleX: "1", scaleY: "1", translateY: "0", translateX: '0' }, { duration: 80, delay: time });
77
71
  time += 40;
78
72
  });
79
73
  }
@@ -94,18 +88,14 @@
94
88
  $this.removeClass('active');
95
89
  var time = 0;
96
90
  $this.find('ul .btn-floating').velocity("stop", true);
97
- $this.find('ul .btn-floating').velocity(
98
- { opacity: "0", scaleX: ".4", scaleY: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px'},
99
- { duration: 80 }
100
- );
91
+ $this.find('ul .btn-floating').velocity({ opacity: "0", scaleX: ".4", scaleY: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px' }, { duration: 80 });
101
92
  };
102
93
 
103
-
104
94
  /**
105
95
  * Transform FAB into toolbar
106
96
  * @param {Object} object jQuery object
107
97
  */
108
- var FABtoToolbar = function(btn) {
98
+ var FABtoToolbar = function (btn) {
109
99
  if (btn.attr('data-open') === "true") {
110
100
  return;
111
101
  }
@@ -120,7 +110,7 @@
120
110
  var fabColor = anchor.css('background-color');
121
111
  anchor.append(backdrop);
122
112
 
123
- offsetX = btnRect.left - (windowWidth / 2) + (btnRect.width / 2);
113
+ offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2;
124
114
  offsetY = windowHeight - btnRect.bottom;
125
115
  scaleFactor = windowWidth / backdrop.width();
126
116
  btn.attr('data-origin-bottom', btnRect.bottom);
@@ -146,8 +136,7 @@
146
136
  'background-color': fabColor
147
137
  });
148
138
 
149
-
150
- setTimeout(function() {
139
+ setTimeout(function () {
151
140
  btn.css({
152
141
  transform: '',
153
142
  transition: 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s'
@@ -158,7 +147,7 @@
158
147
  transition: 'transform .2s'
159
148
  });
160
149
 
161
- setTimeout(function() {
150
+ setTimeout(function () {
162
151
  btn.css({
163
152
  overflow: 'hidden',
164
153
  'background-color': fabColor
@@ -172,13 +161,13 @@
172
161
  });
173
162
 
174
163
  // Scroll to close.
175
- $(window).on('scroll.fabToolbarClose', function() {
164
+ $(window).on('scroll.fabToolbarClose', function () {
176
165
  toolbarToFAB(btn);
177
166
  $(window).off('scroll.fabToolbarClose');
178
167
  $(document).off('click.fabToolbarClose');
179
168
  });
180
169
 
181
- $(document).on('click.fabToolbarClose', function(e) {
170
+ $(document).on('click.fabToolbarClose', function (e) {
182
171
  if (!$(e.target).closest(menu).length) {
183
172
  toolbarToFAB(btn);
184
173
  $(window).off('scroll.fabToolbarClose');
@@ -193,7 +182,7 @@
193
182
  * Transform toolbar back into FAB
194
183
  * @param {Object} object jQuery object
195
184
  */
196
- var toolbarToFAB = function(btn) {
185
+ var toolbarToFAB = function (btn) {
197
186
  if (btn.attr('data-open') !== "true") {
198
187
  return;
199
188
  }
@@ -209,11 +198,10 @@
209
198
  var backdrop = btn.find('.fab-backdrop');
210
199
  var fabColor = anchor.css('background-color');
211
200
 
212
- offsetX = btnLeft - (windowWidth / 2) + (btnWidth / 2);
201
+ offsetX = btnLeft - windowWidth / 2 + btnWidth / 2;
213
202
  offsetY = windowHeight - btnBottom;
214
203
  scaleFactor = windowWidth / backdrop.width();
215
204
 
216
-
217
205
  // Hide backdrop
218
206
  btn.removeClass('active');
219
207
  btn.attr('data-open', false);
@@ -232,7 +220,7 @@
232
220
  opacity: ''
233
221
  });
234
222
 
235
- setTimeout(function() {
223
+ setTimeout(function () {
236
224
  backdrop.remove();
237
225
 
238
226
  // Set initial state.
@@ -250,7 +238,7 @@
250
238
  transform: 'translate3d(0,' + offsetY + 'px,0)'
251
239
  });
252
240
 
253
- setTimeout(function() {
241
+ setTimeout(function () {
254
242
  btn.css({
255
243
  transform: 'translate3d(0,0,0)',
256
244
  transition: 'transform .2s'
@@ -262,6 +250,4 @@
262
250
  }, 20);
263
251
  }, 200);
264
252
  };
265
-
266
-
267
- }( jQuery ));
253
+ })(jQuery);
@@ -1,36 +1,28 @@
1
1
  (function ($) {
2
- $(document).on('ready turbolinks:load', function() {
2
+ $(document).on('ready turbolinks:load', function () {
3
3
 
4
4
  $(document).on('click.card', '.card', function (e) {
5
5
  if ($(this).find('> .card-reveal').length) {
6
6
  var $card = $(e.target).closest('.card');
7
7
  if ($card.data('initialOverflow') === undefined) {
8
- $card.data(
9
- 'initialOverflow',
10
- $card.css('overflow') === undefined ? '' : $card.css('overflow')
11
- );
8
+ $card.data('initialOverflow', $card.css('overflow') === undefined ? '' : $card.css('overflow'));
12
9
  }
13
10
  if ($(e.target).is($('.card-reveal .card-title')) || $(e.target).is($('.card-reveal .card-title i'))) {
14
11
  // Make Reveal animate down and display none
15
- $(this).find('.card-reveal').velocity(
16
- {translateY: 0}, {
17
- duration: 225,
18
- queue: false,
19
- easing: 'easeInOutQuad',
20
- complete: function() {
21
- $(this).css({ display: 'none'});
22
- $card.css('overflow', $card.data('initialOverflow'));
23
- }
12
+ $(this).find('.card-reveal').velocity({ translateY: 0 }, {
13
+ duration: 225,
14
+ queue: false,
15
+ easing: 'easeInOutQuad',
16
+ complete: function () {
17
+ $(this).css({ display: 'none' });
18
+ $card.css('overflow', $card.data('initialOverflow'));
24
19
  }
25
- );
26
- }
27
- else if ($(e.target).is($('.card .activator')) ||
28
- $(e.target).is($('.card .activator i')) ) {
20
+ });
21
+ } else if ($(e.target).is($('.card .activator')) || $(e.target).is($('.card .activator i'))) {
29
22
  $card.css('overflow', 'hidden');
30
- $(this).find('.card-reveal').css({ display: 'block'}).velocity("stop", false).velocity({translateY: '-100%'}, {duration: 300, queue: false, easing: 'easeInOutQuad'});
23
+ $(this).find('.card-reveal').css({ display: 'block' }).velocity("stop", false).velocity({ translateY: '-100%' }, { duration: 300, queue: false, easing: 'easeInOutQuad' });
31
24
  }
32
25
  }
33
26
  });
34
-
35
27
  });
36
- }( jQuery ));
28
+ })(jQuery);
@@ -2,7 +2,7 @@
2
2
 
3
3
  var methods = {
4
4
 
5
- init : function(options) {
5
+ init: function (options) {
6
6
  var defaults = {
7
7
  duration: 200, // ms
8
8
  dist: -100, // zoom scale TODO: make this more intuitive as an option
@@ -16,36 +16,47 @@
16
16
  options = $.extend(defaults, options);
17
17
  var namespace = Materialize.objectSelectorString($(this));
18
18
 
19
- return this.each(function(i) {
19
+ return this.each(function (i) {
20
20
 
21
- var uniqueNamespace = namespace+i;
22
- var images, item_width, item_height, offset, center, pressed, dim, count,
23
- reference, referenceY, amplitude, target, velocity, scrolling,
24
- xform, frame, timestamp, ticker, dragged, vertical_dragged;
21
+ var images, item_width, item_height, offset, center, pressed, dim, count, reference, referenceY, amplitude, target, velocity, scrolling, xform, frame, timestamp, ticker, dragged, vertical_dragged;
25
22
  var $indicators = $('<ul class="indicators"></ul>');
26
23
  var scrollingTimeout = null;
27
24
  var oneTimeCallback = null;
28
25
 
29
-
30
26
  // Initialize
31
27
  var view = $(this);
32
- var showIndicators = view.attr('data-indicators') || options.indicators;
33
-
28
+ var hasMultipleSlides = view.find('.carousel-item').length > 1;
29
+ var showIndicators = (view.attr('data-indicators') || options.indicators) && hasMultipleSlides;
30
+ var noWrap = view.attr('data-no-wrap') || options.noWrap || !hasMultipleSlides;
31
+ var uniqueNamespace = view.attr('data-namespace') || namespace + i;
32
+ view.attr('data-namespace', uniqueNamespace);
34
33
 
35
34
  // Options
36
- var setCarouselHeight = function() {
37
- var firstImage = view.find('.carousel-item img').first();
35
+ var setCarouselHeight = function (imageOnly) {
36
+ var firstSlide = view.find('.carousel-item.active').length ? view.find('.carousel-item.active').first() : view.find('.carousel-item').first();
37
+ var firstImage = firstSlide.find('img').first();
38
38
  if (firstImage.length) {
39
- if (firstImage.prop('complete')) {
40
- view.css('height', firstImage.height());
39
+ if (firstImage[0].complete) {
40
+ // If image won't trigger the load event
41
+ var imageHeight = firstImage.height();
42
+ if (imageHeight > 0) {
43
+ view.css('height', firstImage.height());
44
+ } else {
45
+ // If image still has no height, use the natural dimensions to calculate
46
+ var naturalWidth = firstImage[0].naturalWidth;
47
+ var naturalHeight = firstImage[0].naturalHeight;
48
+ var adjustedHeight = view.width() / naturalWidth * naturalHeight;
49
+ view.css('height', adjustedHeight);
50
+ }
41
51
  } else {
42
- firstImage.on('load', function(){
52
+ // Get height when image is loaded normally
53
+ firstImage.on('load', function () {
43
54
  view.css('height', $(this).height());
44
55
  });
45
56
  }
46
- } else {
47
- var imageHeight = view.find('.carousel-item').first().height();
48
- view.css('height', imageHeight);
57
+ } else if (!imageOnly) {
58
+ var slideHeight = firstSlide.height();
59
+ view.css('height', slideHeight);
49
60
  }
50
61
  };
51
62
 
@@ -59,18 +70,16 @@
59
70
  }
60
71
  }
61
72
 
62
-
63
73
  // Don't double initialize.
64
74
  if (view.hasClass('initialized')) {
65
75
  // Recalculate variables
66
76
  $(window).trigger('resize');
67
77
 
68
78
  // Redraw carousel.
69
- $(this).trigger('carouselNext', [0.000001]);
79
+ view.trigger('carouselNext', [0.000001]);
70
80
  return true;
71
81
  }
72
82
 
73
-
74
83
  view.addClass('initialized');
75
84
  pressed = false;
76
85
  offset = target = 0;
@@ -105,23 +114,22 @@
105
114
  }
106
115
  count = images.length;
107
116
 
108
-
109
117
  function setupEvents() {
110
118
  if (typeof window.ontouchstart !== 'undefined') {
111
- view[0].addEventListener('touchstart', tap);
112
- view[0].addEventListener('touchmove', drag);
113
- view[0].addEventListener('touchend', release);
114
- }
115
- view[0].addEventListener('mousedown', tap);
116
- view[0].addEventListener('mousemove', drag);
117
- view[0].addEventListener('mouseup', release);
118
- view[0].addEventListener('mouseleave', release);
119
- view[0].addEventListener('click', click);
119
+ view.on('touchstart.carousel', tap);
120
+ view.on('touchmove.carousel', drag);
121
+ view.on('touchend.carousel', release);
122
+ }
123
+ view.on('mousedown.carousel', tap);
124
+ view.on('mousemove.carousel', drag);
125
+ view.on('mouseup.carousel', release);
126
+ view.on('mouseleave.carousel', release);
127
+ view.on('click.carousel', click);
120
128
  }
121
129
 
122
130
  function xpos(e) {
123
131
  // touch event
124
- if (e.targetTouches && (e.targetTouches.length >= 1)) {
132
+ if (e.targetTouches && e.targetTouches.length >= 1) {
125
133
  return e.targetTouches[0].clientX;
126
134
  }
127
135
 
@@ -131,7 +139,7 @@
131
139
 
132
140
  function ypos(e) {
133
141
  // touch event
134
- if (e.targetTouches && (e.targetTouches.length >= 1)) {
142
+ if (e.targetTouches && e.targetTouches.length >= 1) {
135
143
  return e.targetTouches[0].clientY;
136
144
  }
137
145
 
@@ -140,7 +148,7 @@
140
148
  }
141
149
 
142
150
  function wrap(x) {
143
- return (x >= count) ? (x % count) : (x < 0) ? wrap(count + (x % count)) : x;
151
+ return x >= count ? x % count : x < 0 ? wrap(count + x % count) : x;
144
152
  }
145
153
 
146
154
  function scroll(x) {
@@ -152,7 +160,7 @@
152
160
  if (scrollingTimeout != null) {
153
161
  window.clearTimeout(scrollingTimeout);
154
162
  }
155
- scrollingTimeout = window.setTimeout(function() {
163
+ scrollingTimeout = window.setTimeout(function () {
156
164
  scrolling = false;
157
165
  view.removeClass('scrolling');
158
166
  }, options.duration);
@@ -161,10 +169,10 @@
161
169
  var i, half, delta, dir, tween, el, alignment, xTranslation;
162
170
  var lastCenter = center;
163
171
 
164
- offset = (typeof x === 'number') ? x : offset;
172
+ offset = typeof x === 'number' ? x : offset;
165
173
  center = Math.floor((offset + dim / 2) / dim);
166
174
  delta = offset - center * dim;
167
- dir = (delta < 0) ? 1 : -1;
175
+ dir = delta < 0 ? 1 : -1;
168
176
  tween = -dir * delta * 2 / dim;
169
177
  half = count >> 1;
170
178
 
@@ -177,7 +185,7 @@
177
185
 
178
186
  // Set indicator active
179
187
  if (showIndicators) {
180
- var diff = (center % count);
188
+ var diff = center % count;
181
189
  var activeIndicator = $indicators.find('.indicator-item.active');
182
190
  if (activeIndicator.index() !== diff) {
183
191
  activeIndicator.removeClass('active');
@@ -187,7 +195,7 @@
187
195
 
188
196
  // center
189
197
  // Don't show wrapped items.
190
- if (!options.noWrap || (center >= 0 && center < count)) {
198
+ if (!noWrap || center >= 0 && center < count) {
191
199
  el = images[wrap(center)];
192
200
 
193
201
  // Add active class to center item.
@@ -195,13 +203,13 @@
195
203
  view.find('.carousel-item').removeClass('active');
196
204
  $(el).addClass('active');
197
205
  }
198
- el.style[xform] = alignment +
199
- ' translateX(' + (-delta / 2) + 'px)' +
200
- ' translateX(' + (dir * options.shift * tween * i) + 'px)' +
201
- ' translateZ(' + (options.dist * tween) + 'px)';
206
+ el.style[xform] = alignment + ' translateX(' + -delta / 2 + 'px)' + ' translateX(' + dir * options.shift * tween * i + 'px)' + ' translateZ(' + options.dist * tween + 'px)';
202
207
  el.style.zIndex = 0;
203
- if (options.fullWidth) { tweenedOpacity = 1; }
204
- else { tweenedOpacity = 1 - 0.2 * tween; }
208
+ if (options.fullWidth) {
209
+ tweenedOpacity = 1;
210
+ } else {
211
+ tweenedOpacity = 1 - 0.2 * tween;
212
+ }
205
213
  el.style.opacity = tweenedOpacity;
206
214
  el.style.display = 'block';
207
215
  }
@@ -210,37 +218,32 @@
210
218
  // right side
211
219
  if (options.fullWidth) {
212
220
  zTranslation = options.dist;
213
- tweenedOpacity = (i === half && delta < 0) ? 1 - tween : 1;
221
+ tweenedOpacity = i === half && delta < 0 ? 1 - tween : 1;
214
222
  } else {
215
223
  zTranslation = options.dist * (i * 2 + tween * dir);
216
224
  tweenedOpacity = 1 - 0.2 * (i * 2 + tween * dir);
217
225
  }
218
226
  // Don't show wrapped items.
219
- if (!options.noWrap || center + i < count) {
227
+ if (!noWrap || center + i < count) {
220
228
  el = images[wrap(center + i)];
221
- el.style[xform] = alignment +
222
- ' translateX(' + (options.shift + (dim * i - delta) / 2) + 'px)' +
223
- ' translateZ(' + zTranslation + 'px)';
229
+ el.style[xform] = alignment + ' translateX(' + (options.shift + (dim * i - delta) / 2) + 'px)' + ' translateZ(' + zTranslation + 'px)';
224
230
  el.style.zIndex = -i;
225
231
  el.style.opacity = tweenedOpacity;
226
232
  el.style.display = 'block';
227
233
  }
228
234
 
229
-
230
235
  // left side
231
236
  if (options.fullWidth) {
232
237
  zTranslation = options.dist;
233
- tweenedOpacity = (i === half && delta > 0) ? 1 - tween : 1;
238
+ tweenedOpacity = i === half && delta > 0 ? 1 - tween : 1;
234
239
  } else {
235
240
  zTranslation = options.dist * (i * 2 - tween * dir);
236
241
  tweenedOpacity = 1 - 0.2 * (i * 2 - tween * dir);
237
242
  }
238
243
  // Don't show wrapped items.
239
- if (!options.noWrap || center - i >= 0) {
244
+ if (!noWrap || center - i >= 0) {
240
245
  el = images[wrap(center - i)];
241
- el.style[xform] = alignment +
242
- ' translateX(' + (-options.shift + (-dim * i - delta) / 2) + 'px)' +
243
- ' translateZ(' + zTranslation + 'px)';
246
+ el.style[xform] = alignment + ' translateX(' + (-options.shift + (-dim * i - delta) / 2) + 'px)' + ' translateZ(' + zTranslation + 'px)';
244
247
  el.style.zIndex = -i;
245
248
  el.style.opacity = tweenedOpacity;
246
249
  el.style.display = 'block';
@@ -249,28 +252,27 @@
249
252
 
250
253
  // center
251
254
  // Don't show wrapped items.
252
- if (!options.noWrap || (center >= 0 && center < count)) {
255
+ if (!noWrap || center >= 0 && center < count) {
253
256
  el = images[wrap(center)];
254
- el.style[xform] = alignment +
255
- ' translateX(' + (-delta / 2) + 'px)' +
256
- ' translateX(' + (dir * options.shift * tween) + 'px)' +
257
- ' translateZ(' + (options.dist * tween) + 'px)';
257
+ el.style[xform] = alignment + ' translateX(' + -delta / 2 + 'px)' + ' translateX(' + dir * options.shift * tween + 'px)' + ' translateZ(' + options.dist * tween + 'px)';
258
258
  el.style.zIndex = 0;
259
- if (options.fullWidth) { tweenedOpacity = 1; }
260
- else { tweenedOpacity = 1 - 0.2 * tween; }
259
+ if (options.fullWidth) {
260
+ tweenedOpacity = 1;
261
+ } else {
262
+ tweenedOpacity = 1 - 0.2 * tween;
263
+ }
261
264
  el.style.opacity = tweenedOpacity;
262
265
  el.style.display = 'block';
263
266
  }
264
267
 
265
268
  // onCycleTo callback
266
- if (lastCenter !== center &&
267
- typeof(options.onCycleTo) === "function") {
269
+ if (lastCenter !== center && typeof options.onCycleTo === "function") {
268
270
  var $curr_item = view.find('.carousel-item').eq(wrap(center));
269
271
  options.onCycleTo.call(this, $curr_item, dragged);
270
272
  }
271
273
 
272
274
  // One time callback
273
- if (typeof(oneTimeCallback) === "function") {
275
+ if (typeof oneTimeCallback === "function") {
274
276
  oneTimeCallback.call(this, $curr_item, dragged);
275
277
  oneTimeCallback = null;
276
278
  }
@@ -296,10 +298,10 @@
296
298
  elapsed = Date.now() - timestamp;
297
299
  delta = amplitude * Math.exp(-elapsed / options.duration);
298
300
  if (delta > 2 || delta < -2) {
299
- scroll(target - delta);
300
- requestAnimationFrame(autoScroll);
301
+ scroll(target - delta);
302
+ requestAnimationFrame(autoScroll);
301
303
  } else {
302
- scroll(target);
304
+ scroll(target);
303
305
  }
304
306
  }
305
307
  }
@@ -310,7 +312,6 @@
310
312
  e.preventDefault();
311
313
  e.stopPropagation();
312
314
  return false;
313
-
314
315
  } else if (!options.fullWidth) {
315
316
  var clickedIndex = $(e.target).closest('.carousel-item').index();
316
317
  var diff = wrap(center) - clickedIndex;
@@ -325,29 +326,32 @@
325
326
  }
326
327
 
327
328
  function cycleTo(n) {
328
- var diff = (center % count) - n;
329
+ var diff = center % count - n;
329
330
 
330
331
  // Account for wraparound.
331
- if (!options.noWrap) {
332
+ if (!noWrap) {
332
333
  if (diff < 0) {
333
- if (Math.abs(diff + count) < Math.abs(diff)) { diff += count; }
334
-
334
+ if (Math.abs(diff + count) < Math.abs(diff)) {
335
+ diff += count;
336
+ }
335
337
  } else if (diff > 0) {
336
- if (Math.abs(diff - count) < diff) { diff -= count; }
338
+ if (Math.abs(diff - count) < diff) {
339
+ diff -= count;
340
+ }
337
341
  }
338
342
  }
339
343
 
340
344
  // Call prev or next accordingly.
341
345
  if (diff < 0) {
342
346
  view.trigger('carouselNext', [Math.abs(diff)]);
343
-
344
347
  } else if (diff > 0) {
345
348
  view.trigger('carouselPrev', [diff]);
346
349
  }
347
350
  }
348
351
 
349
352
  function tap(e) {
350
- if (e.type === 'mousedown') {
353
+ // Fixes firefox draggable image bug
354
+ if (e.type === 'mousedown' && $(e.target).is('img')) {
351
355
  e.preventDefault();
352
356
  }
353
357
  pressed = true;
@@ -377,13 +381,11 @@
377
381
  reference = x;
378
382
  scroll(offset + delta);
379
383
  }
380
-
381
384
  } else if (dragged) {
382
385
  // If dragging don't allow vertical scroll.
383
386
  e.preventDefault();
384
387
  e.stopPropagation();
385
388
  return false;
386
-
387
389
  } else {
388
390
  // Vertical scrolling.
389
391
  vertical_dragged = true;
@@ -414,7 +416,7 @@
414
416
  target = Math.round(target / dim) * dim;
415
417
 
416
418
  // No wrap of items.
417
- if (options.noWrap) {
419
+ if (noWrap) {
418
420
  if (target >= dim * (count - 1)) {
419
421
  target = dim * (count - 1);
420
422
  } else if (target < 0) {
@@ -442,31 +444,32 @@
442
444
  return true;
443
445
  });
444
446
 
445
-
446
- $(window).off('resize.carousel-'+uniqueNamespace).on('resize.carousel-'+uniqueNamespace, function() {
447
+ var throttledResize = Materialize.throttle(function () {
447
448
  if (options.fullWidth) {
448
449
  item_width = view.find('.carousel-item').first().innerWidth();
449
- item_height = view.find('.carousel-item').first().innerHeight();
450
+ var imageHeight = view.find('.carousel-item.active').height();
450
451
  dim = item_width * 2 + options.padding;
451
452
  offset = center * 2 * item_width;
452
453
  target = offset;
454
+ setCarouselHeight(true);
453
455
  } else {
454
456
  scroll();
455
457
  }
456
- });
458
+ }, 200);
459
+ $(window).off('resize.carousel-' + uniqueNamespace).on('resize.carousel-' + uniqueNamespace, throttledResize);
457
460
 
458
461
  setupEvents();
459
462
  scroll(offset);
460
463
 
461
- $(this).on('carouselNext', function(e, n, callback) {
464
+ $(this).on('carouselNext', function (e, n, callback) {
462
465
  if (n === undefined) {
463
466
  n = 1;
464
467
  }
465
- if (typeof(callback) === "function") {
468
+ if (typeof callback === "function") {
466
469
  oneTimeCallback = callback;
467
470
  }
468
471
 
469
- target = (dim * Math.round(offset / dim)) + (dim * n);
472
+ target = dim * Math.round(offset / dim) + dim * n;
470
473
  if (offset !== target) {
471
474
  amplitude = target - offset;
472
475
  timestamp = Date.now();
@@ -474,15 +477,15 @@
474
477
  }
475
478
  });
476
479
 
477
- $(this).on('carouselPrev', function(e, n, callback) {
480
+ $(this).on('carouselPrev', function (e, n, callback) {
478
481
  if (n === undefined) {
479
482
  n = 1;
480
483
  }
481
- if (typeof(callback) === "function") {
484
+ if (typeof callback === "function") {
482
485
  oneTimeCallback = callback;
483
486
  }
484
487
 
485
- target = (dim * Math.round(offset / dim)) - (dim * n);
488
+ target = dim * Math.round(offset / dim) - dim * n;
486
489
  if (offset !== target) {
487
490
  amplitude = target - offset;
488
491
  timestamp = Date.now();
@@ -490,42 +493,51 @@
490
493
  }
491
494
  });
492
495
 
493
- $(this).on('carouselSet', function(e, n, callback) {
496
+ $(this).on('carouselSet', function (e, n, callback) {
494
497
  if (n === undefined) {
495
498
  n = 0;
496
499
  }
497
- if (typeof(callback) === "function") {
500
+ if (typeof callback === "function") {
498
501
  oneTimeCallback = callback;
499
502
  }
500
503
 
501
504
  cycleTo(n);
502
505
  });
503
-
504
506
  });
505
-
506
-
507
-
508
507
  },
509
- next : function(n, callback) {
508
+ next: function (n, callback) {
510
509
  $(this).trigger('carouselNext', [n, callback]);
511
510
  },
512
- prev : function(n, callback) {
511
+ prev: function (n, callback) {
513
512
  $(this).trigger('carouselPrev', [n, callback]);
514
513
  },
515
- set : function(n, callback) {
514
+ set: function (n, callback) {
516
515
  $(this).trigger('carouselSet', [n, callback]);
516
+ },
517
+ destroy: function () {
518
+ var uniqueNamespace = $(this).attr('data-namespace');
519
+ $(this).removeAttr('data-namespace');
520
+ $(this).removeClass('initialized');
521
+ $(this).find('.indicators').remove();
522
+
523
+ // Remove event handlers
524
+ $(this).off('carouselNext carouselPrev carouselSet');
525
+ $(window).off('resize.carousel-' + uniqueNamespace);
526
+ if (typeof window.ontouchstart !== 'undefined') {
527
+ $(this).off('touchstart.carousel touchmove.carousel touchend.carousel');
528
+ }
529
+ $(this).off('mousedown.carousel mousemove.carousel mouseup.carousel mouseleave.carousel click.carousel');
517
530
  }
518
531
  };
519
532
 
520
-
521
- $.fn.carousel = function(methodOrOptions) {
522
- if ( methods[methodOrOptions] ) {
523
- return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
524
- } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
525
- // Default to "init"
526
- return methods.init.apply( this, arguments );
527
- } else {
528
- $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.carousel' );
529
- }
530
- }; // Plugin end
531
- }( jQuery ));
533
+ $.fn.carousel = function (methodOrOptions) {
534
+ if (methods[methodOrOptions]) {
535
+ return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
536
+ } else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
537
+ // Default to "init"
538
+ return methods.init.apply(this, arguments);
539
+ } else {
540
+ $.error('Method ' + methodOrOptions + ' does not exist on jQuery.carousel');
541
+ }
542
+ }; // Plugin end
543
+ })(jQuery);