materialize-sass 0.100.2.1 → 1.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +18 -42
  3. data/Rakefile +17 -17
  4. data/{app/assets → assets}/javascripts/materialize-sprockets.js +8 -12
  5. data/assets/javascripts/materialize.js +11877 -0
  6. data/assets/javascripts/materialize/autocomplete.js +420 -0
  7. data/assets/javascripts/materialize/buttons.js +388 -0
  8. data/assets/javascripts/materialize/cards.js +28 -0
  9. data/assets/javascripts/materialize/carousel.js +791 -0
  10. data/assets/javascripts/materialize/cash.js +992 -0
  11. data/assets/javascripts/materialize/characterCounter.js +180 -0
  12. data/assets/javascripts/materialize/chips.js +555 -0
  13. data/assets/javascripts/materialize/collapsible.js +275 -0
  14. data/assets/javascripts/materialize/datepicker.js +898 -0
  15. data/assets/javascripts/materialize/dropdown.js +530 -0
  16. data/{app/assets → assets}/javascripts/materialize/extras/nouislider.js +1 -1
  17. data/{app/assets → assets}/javascripts/materialize/extras/nouislider.min.js +1 -1
  18. data/assets/javascripts/materialize/forms.js +223 -0
  19. data/assets/javascripts/materialize/global.js +353 -0
  20. data/assets/javascripts/materialize/materialbox.js +432 -0
  21. data/{app/assets → assets}/javascripts/materialize/modal.js +82 -113
  22. data/assets/javascripts/materialize/parallax.js +135 -0
  23. data/assets/javascripts/materialize/pushpin.js +158 -0
  24. data/assets/javascripts/materialize/range.js +305 -0
  25. data/assets/javascripts/materialize/scrollspy.js +322 -0
  26. data/assets/javascripts/materialize/select.js +426 -0
  27. data/assets/javascripts/materialize/sidenav.js +584 -0
  28. data/assets/javascripts/materialize/slider.js +383 -0
  29. data/assets/javascripts/materialize/tabs.js +460 -0
  30. data/assets/javascripts/materialize/tapTarget.js +347 -0
  31. data/assets/javascripts/materialize/timepicker.js +616 -0
  32. data/{app/assets → assets}/javascripts/materialize/toasts.js +42 -46
  33. data/assets/javascripts/materialize/tooltip.js +325 -0
  34. data/assets/javascripts/materialize/velocity.min.js +782 -0
  35. data/{app/assets → assets}/javascripts/materialize/waves.js +0 -0
  36. data/{app/assets → assets}/stylesheets/materialize.scss +5 -6
  37. data/{app/assets → assets}/stylesheets/materialize/components/_badges.scss +1 -1
  38. data/{app/assets → assets}/stylesheets/materialize/components/_buttons.scss +34 -2
  39. data/{app/assets → assets}/stylesheets/materialize/components/_cards.scss +0 -0
  40. data/{app/assets → assets}/stylesheets/materialize/components/_carousel.scss +1 -1
  41. data/{app/assets → assets}/stylesheets/materialize/components/_chips.scss +6 -5
  42. data/{app/assets → assets}/stylesheets/materialize/components/_collapsible.scss +3 -3
  43. data/{app/assets → assets}/stylesheets/materialize/components/_color.scss +0 -0
  44. data/assets/stylesheets/materialize/components/_datepicker.scss +180 -0
  45. data/{app/assets → assets}/stylesheets/materialize/components/_dropdown.scss +16 -15
  46. data/{app/assets → assets}/stylesheets/materialize/components/_global.scss +49 -14
  47. data/{app/assets → assets}/stylesheets/materialize/components/_grid.scss +1 -1
  48. data/{app/assets → assets}/stylesheets/materialize/components/_icons-material-design.scss +0 -0
  49. data/{app/assets → assets}/stylesheets/materialize/components/_materialbox.scss +0 -0
  50. data/assets/stylesheets/materialize/components/_mixins.scss +5 -0
  51. data/{app/assets → assets}/stylesheets/materialize/components/_modal.scss +1 -1
  52. data/{app/assets → assets}/stylesheets/materialize/components/_navbar.scss +0 -0
  53. data/assets/stylesheets/materialize/components/_normalize.scss +447 -0
  54. data/{app/assets → assets}/stylesheets/materialize/components/_preloader.scss +0 -0
  55. data/{app/assets → assets}/stylesheets/materialize/components/_pulse.scss +0 -0
  56. data/{app/assets/stylesheets/materialize/components/_sideNav.scss → assets/stylesheets/materialize/components/_sidenav.scss} +23 -21
  57. data/{app/assets → assets}/stylesheets/materialize/components/_slider.scss +0 -0
  58. data/{app/assets → assets}/stylesheets/materialize/components/_table_of_contents.scss +3 -3
  59. data/{app/assets → assets}/stylesheets/materialize/components/_tabs.scss +2 -2
  60. data/{app/assets → assets}/stylesheets/materialize/components/_tapTarget.scss +0 -0
  61. data/assets/stylesheets/materialize/components/_timepicker.scss +182 -0
  62. data/{app/assets → assets}/stylesheets/materialize/components/_toast.scss +0 -0
  63. data/{app/assets → assets}/stylesheets/materialize/components/_tooltip.scss +1 -0
  64. data/{app/assets → assets}/stylesheets/materialize/components/_transitions.scss +0 -0
  65. data/{app/assets → assets}/stylesheets/materialize/components/_typography.scss +8 -8
  66. data/{app/assets → assets}/stylesheets/materialize/components/_variables.scss +42 -44
  67. data/{app/assets → assets}/stylesheets/materialize/components/_waves.scss +0 -0
  68. data/{app/assets → assets}/stylesheets/materialize/components/forms/_checkboxes.scss +24 -24
  69. data/{app/assets → assets}/stylesheets/materialize/components/forms/_file-input.scss +0 -0
  70. data/{app/assets → assets}/stylesheets/materialize/components/forms/_forms.scss +0 -0
  71. data/{app/assets → assets}/stylesheets/materialize/components/forms/_input-fields.scss +49 -35
  72. data/{app/assets → assets}/stylesheets/materialize/components/forms/_radio-buttons.scss +29 -29
  73. data/{app/assets → assets}/stylesheets/materialize/components/forms/_range.scss +32 -31
  74. data/{app/assets → assets}/stylesheets/materialize/components/forms/_select.scss +20 -11
  75. data/{app/assets → assets}/stylesheets/materialize/components/forms/_switches.scss +0 -0
  76. data/{app/assets → assets}/stylesheets/materialize/extras/nouislider.css +1 -1
  77. data/lib/materialize-sass.rb +13 -23
  78. data/lib/materialize-sass/engine.rb +6 -9
  79. data/lib/materialize-sass/version.rb +1 -1
  80. data/materialize-sass.gemspec +2 -1
  81. metadata +97 -97
  82. data/app/assets/fonts/roboto/Roboto-Bold.woff +0 -0
  83. data/app/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
  84. data/app/assets/fonts/roboto/Roboto-Light.woff +0 -0
  85. data/app/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
  86. data/app/assets/fonts/roboto/Roboto-Medium.woff +0 -0
  87. data/app/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
  88. data/app/assets/fonts/roboto/Roboto-Regular.woff +0 -0
  89. data/app/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
  90. data/app/assets/fonts/roboto/Roboto-Thin.woff +0 -0
  91. data/app/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
  92. data/app/assets/javascripts/materialize.js +0 -10021
  93. data/app/assets/javascripts/materialize/animation.js +0 -7
  94. data/app/assets/javascripts/materialize/buttons.js +0 -253
  95. data/app/assets/javascripts/materialize/cards.js +0 -28
  96. data/app/assets/javascripts/materialize/carousel.js +0 -543
  97. data/app/assets/javascripts/materialize/character_counter.js +0 -64
  98. data/app/assets/javascripts/materialize/chips.js +0 -315
  99. data/app/assets/javascripts/materialize/collapsible.js +0 -178
  100. data/app/assets/javascripts/materialize/date_picker/picker.date.js +0 -1399
  101. data/app/assets/javascripts/materialize/date_picker/picker.js +0 -1196
  102. data/app/assets/javascripts/materialize/date_picker/picker.time.js +0 -646
  103. data/app/assets/javascripts/materialize/dropdown.js +0 -257
  104. data/app/assets/javascripts/materialize/forms.js +0 -806
  105. data/app/assets/javascripts/materialize/global.js +0 -170
  106. data/app/assets/javascripts/materialize/hammer.min.js +0 -424
  107. data/app/assets/javascripts/materialize/initial.js +0 -10
  108. data/app/assets/javascripts/materialize/jquery.easing.1.4.js +0 -144
  109. data/app/assets/javascripts/materialize/jquery.hammer.js +0 -33
  110. data/app/assets/javascripts/materialize/materialbox.js +0 -263
  111. data/app/assets/javascripts/materialize/parallax.js +0 -54
  112. data/app/assets/javascripts/materialize/pushpin.js +0 -68
  113. data/app/assets/javascripts/materialize/scrollFire.js +0 -49
  114. data/app/assets/javascripts/materialize/scrollspy.js +0 -230
  115. data/app/assets/javascripts/materialize/sideNav.js +0 -395
  116. data/app/assets/javascripts/materialize/slider.js +0 -295
  117. data/app/assets/javascripts/materialize/tabs.js +0 -244
  118. data/app/assets/javascripts/materialize/tapTarget.js +0 -184
  119. data/app/assets/javascripts/materialize/tooltip.js +0 -227
  120. data/app/assets/javascripts/materialize/transitions.js +0 -163
  121. data/app/assets/javascripts/materialize/velocity.min.js +0 -626
  122. data/app/assets/stylesheets/materialize/components/_normalize.scss +0 -424
  123. data/app/assets/stylesheets/materialize/components/_roboto.scss +0 -39
  124. data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +0 -469
  125. data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +0 -216
  126. data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +0 -267
@@ -0,0 +1,28 @@
1
+ (function ($, Vel) {
2
+ $(document).on('click', '.card', function (e) {
3
+ if ($(this).children('.card-reveal').length) {
4
+ var $card = $(e.target).closest('.card');
5
+ if ($card.data('initialOverflow') === undefined) {
6
+ $card.data('initialOverflow', $card.css('overflow') === undefined ? '' : $card.css('overflow'));
7
+ }
8
+ var $cardReveal = $(this).find('.card-reveal');
9
+ if ($(e.target).is($('.card-reveal .card-title')) || $(e.target).is($('.card-reveal .card-title i'))) {
10
+ // Make Reveal animate down and display none
11
+ Vel($cardReveal, { translateY: 0 }, {
12
+ duration: 225,
13
+ queue: false,
14
+ easing: 'easeInOutQuad',
15
+ complete: function () {
16
+ $(this).css({ display: 'none' });
17
+ $card.css('overflow', $card.data('initialOverflow'));
18
+ }
19
+ });
20
+ } else if ($(e.target).is($('.card .activator')) || $(e.target).is($('.card .activator i'))) {
21
+ $card.css('overflow', 'hidden');
22
+ $cardReveal.css({ display: 'block' });
23
+ Vel($cardReveal, 'stop');
24
+ Vel($cardReveal, { translateY: '-100%' }, { duration: 300, queue: false, easing: 'easeInOutQuad' });
25
+ }
26
+ }
27
+ });
28
+ })(cash, M.Vel);
@@ -0,0 +1,791 @@
1
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2
+
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
+
5
+ (function ($) {
6
+ 'use strict';
7
+
8
+ var _defaults = {
9
+ duration: 200, // ms
10
+ dist: -100, // zoom scale TODO: make this more intuitive as an option
11
+ shift: 0, // spacing for center image
12
+ padding: 0, // Padding between non center items
13
+ fullWidth: false, // Change to full width styles
14
+ indicators: false, // Toggle indicators
15
+ noWrap: false, // Don't wrap around and cycle through items.
16
+ onCycleTo: null // Callback for when a new slide is cycled to.
17
+ };
18
+
19
+ /**
20
+ * @class
21
+ *
22
+ */
23
+
24
+ var Carousel = function () {
25
+ /**
26
+ * Construct Carousel instance
27
+ * @constructor
28
+ * @param {Element} el
29
+ * @param {Object} options
30
+ */
31
+ function Carousel(el, options) {
32
+ var _this = this;
33
+
34
+ _classCallCheck(this, Carousel);
35
+
36
+ // If exists, destroy and reinitialize
37
+ if (!!el.M_Carousel) {
38
+ el.M_Carousel.destroy();
39
+ }
40
+
41
+ this.el = el;
42
+ this.$el = $(el);
43
+ this.el.M_Carousel = this;
44
+
45
+ /**
46
+ * Options for the carousel
47
+ * @member Carousel#options
48
+ * @prop {Number} duration
49
+ * @prop {Number} dist
50
+ * @prop {number} shift
51
+ * @prop {number} padding
52
+ * @prop {Boolean} fullWidth
53
+ * @prop {Boolean} indicators
54
+ * @prop {Boolean} noWrap
55
+ * @prop {Function} onCycleTo
56
+ */
57
+ this.options = $.extend({}, Carousel.defaults, options);
58
+
59
+ // Setup
60
+ this.hasMultipleSlides = this.$el.find('.carousel-item').length > 1;
61
+ this.showIndicators = this.options.indicators && this.hasMultipleSlides;
62
+ this.noWrap = this.options.noWrap || !this.hasMultipleSlides;
63
+ this.pressed = false;
64
+ this.dragged = false;
65
+ this.offset = this.target = 0;
66
+ this.images = [];
67
+ this.itemWidth = this.$el.find('.carousel-item').first().innerWidth();
68
+ this.itemHeight = this.$el.find('.carousel-item').first().innerHeight();
69
+ this.dim = this.itemWidth * 2 + this.options.padding || 1; // Make sure dim is non zero for divisions.
70
+ this._autoScrollBound = this._autoScroll.bind(this);
71
+ this._trackBound = this._track.bind(this);
72
+
73
+ // Full Width carousel setup
74
+ if (this.options.fullWidth) {
75
+ this.options.dist = 0;
76
+ this._setCarouselHeight();
77
+
78
+ // Offset fixed items when indicators.
79
+ if (this.showIndicators) {
80
+ this.$el.find('.carousel-fixed-item').addClass('with-indicators');
81
+ }
82
+ }
83
+
84
+ // Iterate through slides
85
+ this.$indicators = $('<ul class="indicators"></ul>');
86
+ this.$el.find('.carousel-item').each(function (el, i) {
87
+ _this.images.push(el);
88
+ if (_this.showIndicators) {
89
+ var $indicator = $('<li class="indicator-item"></li>');
90
+
91
+ // Add active to first by default.
92
+ if (i === 0) {
93
+ $indicator[0].classList.add('active');
94
+ }
95
+
96
+ _this.$indicators.append($indicator);
97
+ }
98
+ });
99
+ if (this.showIndicators) {
100
+ this.$el.append(this.$indicators);
101
+ }
102
+ this.count = this.images.length;
103
+
104
+ // Setup cross browser string
105
+ this.xform = 'transform';
106
+ ['webkit', 'Moz', 'O', 'ms'].every(function (prefix) {
107
+ var e = prefix + 'Transform';
108
+ if (typeof document.body.style[e] !== 'undefined') {
109
+ _this.xform = e;
110
+ return false;
111
+ }
112
+ return true;
113
+ });
114
+
115
+ this._setupEventHandlers();
116
+ this._scroll(this.offset);
117
+ }
118
+
119
+ _createClass(Carousel, [{
120
+ key: 'destroy',
121
+
122
+
123
+ /**
124
+ * Teardown component
125
+ */
126
+ value: function destroy() {
127
+ this._removeEventHandlers();
128
+ this.el.M_Carousel = undefined;
129
+ }
130
+
131
+ /**
132
+ * Setup Event Handlers
133
+ */
134
+
135
+ }, {
136
+ key: '_setupEventHandlers',
137
+ value: function _setupEventHandlers() {
138
+ var _this2 = this;
139
+
140
+ this._handleCarouselTapBound = this._handleCarouselTap.bind(this);
141
+ this._handleCarouselDragBound = this._handleCarouselDrag.bind(this);
142
+ this._handleCarouselReleaseBound = this._handleCarouselRelease.bind(this);
143
+ this._handleCarouselClickBound = this._handleCarouselClick.bind(this);
144
+
145
+ if (typeof window.ontouchstart !== 'undefined') {
146
+ this.el.addEventListener('touchstart', this._handleCarouselTapBound);
147
+ this.el.addEventListener('touchmove', this._handleCarouselDragBound);
148
+ this.el.addEventListener('touchend', this._handleCarouselReleaseBound);
149
+ }
150
+
151
+ this.el.addEventListener('mousedown', this._handleCarouselTapBound);
152
+ this.el.addEventListener('mousemove', this._handleCarouselDragBound);
153
+ this.el.addEventListener('mouseup', this._handleCarouselReleaseBound);
154
+ this.el.addEventListener('mouseleave', this._handleCarouselReleaseBound);
155
+ this.el.addEventListener('click', this._handleCarouselClickBound);
156
+
157
+ if (this.showIndicators && this.$indicators) {
158
+ this._handleIndicatorClickBound = this._handleIndicatorClick.bind(this);
159
+ this.$indicators.find('.indicator-item').each(function (el, i) {
160
+ el.addEventListener('click', _this2._handleIndicatorClickBound);
161
+ });
162
+ }
163
+
164
+ // Resize
165
+ var throttledResize = M.throttle(this._handleResize, 200);
166
+ this._handleThrottledResizeBound = throttledResize.bind(this);
167
+
168
+ window.addEventListener('resize', this._handleThrottledResizeBound);
169
+ }
170
+
171
+ /**
172
+ * Remove Event Handlers
173
+ */
174
+
175
+ }, {
176
+ key: '_removeEventHandlers',
177
+ value: function _removeEventHandlers() {
178
+ var _this3 = this;
179
+
180
+ if (typeof window.ontouchstart !== 'undefined') {
181
+ this.el.removeEventListener('touchstart', this._handleCarouselTapBound);
182
+ this.el.removeEventListener('touchmove', this._handleCarouselDragBound);
183
+ this.el.removeEventListener('touchend', this._handleCarouselReleaseBound);
184
+ }
185
+ this.el.removeEventListener('mousedown', this._handleCarouselTapBound);
186
+ this.el.removeEventListener('mousemove', this._handleCarouselDragBound);
187
+ this.el.removeEventListener('mouseup', this._handleCarouselReleaseBound);
188
+ this.el.removeEventListener('mouseleave', this._handleCarouselReleaseBound);
189
+ this.el.removeEventListener('click', this._handleCarouselClickBound);
190
+
191
+ if (this.showIndicators && this.$indicators) {
192
+ this.$indicators.find('.indicator-item').each(function (el, i) {
193
+ el.removeEventListener('click', _this3._handleIndicatorClickBound);
194
+ });
195
+ }
196
+
197
+ window.removeEventListener('resize', this._handleThrottledResizeBound);
198
+ }
199
+
200
+ /**
201
+ * Handle Carousel Tap
202
+ * @param {Event} e
203
+ */
204
+
205
+ }, {
206
+ key: '_handleCarouselTap',
207
+ value: function _handleCarouselTap(e) {
208
+ // Fixes firefox draggable image bug
209
+ if (e.type === 'mousedown' && $(e.target).is('img')) {
210
+ e.preventDefault();
211
+ }
212
+ this.pressed = true;
213
+ this.dragged = false;
214
+ this.verticalDragged = false;
215
+ this.reference = this._xpos(e);
216
+ this.referenceY = this._ypos(e);
217
+
218
+ this.velocity = this.amplitude = 0;
219
+ this.frame = this.offset;
220
+ this.timestamp = Date.now();
221
+ clearInterval(this.ticker);
222
+ this.ticker = setInterval(this._trackBound, 100);
223
+ }
224
+
225
+ /**
226
+ * Handle Carousel Drag
227
+ * @param {Event} e
228
+ */
229
+
230
+ }, {
231
+ key: '_handleCarouselDrag',
232
+ value: function _handleCarouselDrag(e) {
233
+ var x = void 0,
234
+ y = void 0,
235
+ delta = void 0,
236
+ deltaY = void 0;
237
+ if (this.pressed) {
238
+ x = this._xpos(e);
239
+ y = this._ypos(e);
240
+ delta = this.reference - x;
241
+ deltaY = Math.abs(this.referenceY - y);
242
+ if (deltaY < 30 && !this.verticalDragged) {
243
+ // If vertical scrolling don't allow dragging.
244
+ if (delta > 2 || delta < -2) {
245
+ this.dragged = true;
246
+ this.reference = x;
247
+ this._scroll(this.offset + delta);
248
+ }
249
+ } else if (this.dragged) {
250
+ // If dragging don't allow vertical scroll.
251
+ e.preventDefault();
252
+ e.stopPropagation();
253
+ return false;
254
+ } else {
255
+ // Vertical scrolling.
256
+ this.verticalDragged = true;
257
+ }
258
+ }
259
+
260
+ if (this.dragged) {
261
+ // If dragging don't allow vertical scroll.
262
+ e.preventDefault();
263
+ e.stopPropagation();
264
+ return false;
265
+ }
266
+ }
267
+
268
+ /**
269
+ * Handle Carousel Release
270
+ * @param {Event} e
271
+ */
272
+
273
+ }, {
274
+ key: '_handleCarouselRelease',
275
+ value: function _handleCarouselRelease(e) {
276
+ if (this.pressed) {
277
+ this.pressed = false;
278
+ } else {
279
+ return;
280
+ }
281
+
282
+ clearInterval(this.ticker);
283
+ this.target = this.offset;
284
+ if (this.velocity > 10 || this.velocity < -10) {
285
+ this.amplitude = 0.9 * this.velocity;
286
+ this.target = this.offset + this.amplitude;
287
+ }
288
+ this.target = Math.round(this.target / this.dim) * this.dim;
289
+
290
+ // No wrap of items.
291
+ if (this.noWrap) {
292
+ if (this.target >= this.dim * (this.count - 1)) {
293
+ this.target = this.dim * (this.count - 1);
294
+ } else if (this.target < 0) {
295
+ this.target = 0;
296
+ }
297
+ }
298
+ this.amplitude = this.target - this.offset;
299
+ this.timestamp = Date.now();
300
+ requestAnimationFrame(this._autoScrollBound);
301
+
302
+ if (this.dragged) {
303
+ e.preventDefault();
304
+ e.stopPropagation();
305
+ }
306
+ return false;
307
+ }
308
+
309
+ /**
310
+ * Handle Carousel CLick
311
+ * @param {Event} e
312
+ */
313
+
314
+ }, {
315
+ key: '_handleCarouselClick',
316
+ value: function _handleCarouselClick(e) {
317
+ // Disable clicks if carousel was dragged.
318
+ if (this.dragged) {
319
+ e.preventDefault();
320
+ e.stopPropagation();
321
+ return false;
322
+ } else if (!this.options.fullWidth) {
323
+ var clickedIndex = $(e.target).closest('.carousel-item').index();
324
+ var diff = this._wrap(this.center) - clickedIndex;
325
+
326
+ // Disable clicks if carousel was shifted by click
327
+ if (diff !== 0) {
328
+ e.preventDefault();
329
+ e.stopPropagation();
330
+ }
331
+ this._cycleTo(clickedIndex);
332
+ }
333
+ }
334
+
335
+ /**
336
+ * Handle Indicator CLick
337
+ * @param {Event} e
338
+ */
339
+
340
+ }, {
341
+ key: '_handleIndicatorClick',
342
+ value: function _handleIndicatorClick(e) {
343
+ e.stopPropagation();
344
+
345
+ var indicator = $(e.target).closest('.indicator-item');
346
+ if (indicator.length) {
347
+ this._cycleTo(indicator.index());
348
+ }
349
+ }
350
+
351
+ /**
352
+ * Handle Throttle Resize
353
+ * @param {Event} e
354
+ */
355
+
356
+ }, {
357
+ key: '_handleResize',
358
+ value: function _handleResize(e) {
359
+ if (this.options.fullWidth) {
360
+ this.itemWidth = this.$el.find('.carousel-item').first().innerWidth();
361
+ this.imageHeight = this.$el.find('.carousel-item.active').height();
362
+ this.dim = this.itemWidth * 2 + this.options.padding;
363
+ this.offset = this.center * 2 * this.itemWidth;
364
+ this.target = this.offset;
365
+ this._setCarouselHeight(true);
366
+ } else {
367
+ this._scroll();
368
+ }
369
+ }
370
+
371
+ /**
372
+ * Set carousel height based on first slide
373
+ * @param {Booleam} imageOnly - true for image slides
374
+ */
375
+
376
+ }, {
377
+ key: '_setCarouselHeight',
378
+ value: function _setCarouselHeight(imageOnly) {
379
+ var _this4 = this;
380
+
381
+ var firstSlide = this.$el.find('.carousel-item.active').length ? this.$el.find('.carousel-item.active').first() : this.$el.find('.carousel-item').first();
382
+ var firstImage = firstSlide.find('img').first();
383
+ if (firstImage.length) {
384
+ if (firstImage[0].complete) {
385
+ // If image won't trigger the load event
386
+ var imageHeight = firstImage.height();
387
+ if (imageHeight > 0) {
388
+ this.$el.css('height', imageHeight + 'px');
389
+ } else {
390
+ // If image still has no height, use the natural dimensions to calculate
391
+ var naturalWidth = firstImage[0].naturalWidth;
392
+ var naturalHeight = firstImage[0].naturalHeight;
393
+ var adjustedHeight = this.$el.width() / naturalWidth * naturalHeight;
394
+ this.$el.css('height', adjustedHeight + 'px');
395
+ }
396
+ } else {
397
+ // Get height when image is loaded normally
398
+ firstImage.one('load', function (el, i) {
399
+ _this4.$el.css('height', el.offsetHeight + 'px');
400
+ });
401
+ }
402
+ } else if (!imageOnly) {
403
+ var slideHeight = firstSlide.height();
404
+ this.$el.css('height', slideHeight + 'px');
405
+ }
406
+ }
407
+
408
+ /**
409
+ * Get x position from event
410
+ * @param {Event} e
411
+ */
412
+
413
+ }, {
414
+ key: '_xpos',
415
+ value: function _xpos(e) {
416
+ // touch event
417
+ if (e.targetTouches && e.targetTouches.length >= 1) {
418
+ return e.targetTouches[0].clientX;
419
+ }
420
+
421
+ // mouse event
422
+ return e.clientX;
423
+ }
424
+
425
+ /**
426
+ * Get y position from event
427
+ * @param {Event} e
428
+ */
429
+
430
+ }, {
431
+ key: '_ypos',
432
+ value: function _ypos(e) {
433
+ // touch event
434
+ if (e.targetTouches && e.targetTouches.length >= 1) {
435
+ return e.targetTouches[0].clientY;
436
+ }
437
+
438
+ // mouse event
439
+ return e.clientY;
440
+ }
441
+
442
+ /**
443
+ * Wrap index
444
+ * @param {Number} x
445
+ */
446
+
447
+ }, {
448
+ key: '_wrap',
449
+ value: function _wrap(x) {
450
+ return x >= this.count ? x % this.count : x < 0 ? this._wrap(this.count + x % this.count) : x;
451
+ }
452
+
453
+ /**
454
+ * Tracks scrolling information
455
+ */
456
+
457
+ }, {
458
+ key: '_track',
459
+ value: function _track() {
460
+ var now = void 0,
461
+ elapsed = void 0,
462
+ delta = void 0,
463
+ v = void 0;
464
+
465
+ now = Date.now();
466
+ elapsed = now - this.timestamp;
467
+ this.timestamp = now;
468
+ delta = this.offset - this.frame;
469
+ this.frame = this.offset;
470
+
471
+ v = 1000 * delta / (1 + elapsed);
472
+ this.velocity = 0.8 * v + 0.2 * this.velocity;
473
+ }
474
+
475
+ /**
476
+ * Auto scrolls to nearest carousel item.
477
+ */
478
+
479
+ }, {
480
+ key: '_autoScroll',
481
+ value: function _autoScroll() {
482
+ var elapsed = void 0,
483
+ delta = void 0;
484
+
485
+ if (this.amplitude) {
486
+ elapsed = Date.now() - this.timestamp;
487
+ delta = this.amplitude * Math.exp(-elapsed / this.options.duration);
488
+ if (delta > 2 || delta < -2) {
489
+ this._scroll(this.target - delta);
490
+ requestAnimationFrame(this._autoScrollBound);
491
+ } else {
492
+ this._scroll(this.target);
493
+ }
494
+ }
495
+ }
496
+
497
+ /**
498
+ * Scroll to target
499
+ * @param {Number} x
500
+ */
501
+
502
+ }, {
503
+ key: '_scroll',
504
+ value: function _scroll(x) {
505
+ var _this5 = this;
506
+
507
+ // Track scrolling state
508
+ if (!this.$el.hasClass('scrolling')) {
509
+ this.el.classList.add('scrolling');
510
+ }
511
+ if (this.scrollingTimeout != null) {
512
+ window.clearTimeout(this.scrollingTimeout);
513
+ }
514
+ this.scrollingTimeout = window.setTimeout(function () {
515
+ _this5.$el.removeClass('scrolling');
516
+ }, this.options.duration);
517
+
518
+ // Start actual scroll
519
+ var i = void 0,
520
+ half = void 0,
521
+ delta = void 0,
522
+ dir = void 0,
523
+ tween = void 0,
524
+ el = void 0,
525
+ alignment = void 0,
526
+ zTranslation = void 0,
527
+ tweenedOpacity = void 0;
528
+ var lastCenter = this.center;
529
+
530
+ this.offset = typeof x === 'number' ? x : this.offset;
531
+ this.center = Math.floor((this.offset + this.dim / 2) / this.dim);
532
+ delta = this.offset - this.center * this.dim;
533
+ dir = delta < 0 ? 1 : -1;
534
+ tween = -dir * delta * 2 / this.dim;
535
+ half = this.count >> 1;
536
+
537
+ if (!this.options.fullWidth) {
538
+ alignment = 'translateX(' + (this.el.clientWidth - this.itemWidth) / 2 + 'px) ';
539
+ alignment += 'translateY(' + (this.el.clientHeight - this.itemHeight) / 2 + 'px)';
540
+ } else {
541
+ alignment = 'translateX(0)';
542
+ }
543
+
544
+ // Set indicator active
545
+ if (this.showIndicators) {
546
+ var diff = this.center % this.count;
547
+ var activeIndicator = this.$indicators.find('.indicator-item.active');
548
+ if (activeIndicator.index() !== diff) {
549
+ activeIndicator.removeClass('active');
550
+ this.$indicators.find('.indicator-item').eq(diff)[0].classList.add('active');
551
+ }
552
+ }
553
+
554
+ // center
555
+ // Don't show wrapped items.
556
+ if (!this.noWrap || this.center >= 0 && this.center < this.count) {
557
+ el = this.images[this._wrap(this.center)];
558
+
559
+ // Add active class to center item.
560
+ if (!$(el).hasClass('active')) {
561
+ this.$el.find('.carousel-item').removeClass('active');
562
+ el.classList.add('active');
563
+ }
564
+ el.style[this.xform] = alignment + ' translateX(' + -delta / 2 + 'px)' + ' translateX(' + dir * this.options.shift * tween * i + 'px)' + ' translateZ(' + this.options.dist * tween + 'px)';
565
+ el.style.zIndex = 0;
566
+ if (this.options.fullWidth) {
567
+ tweenedOpacity = 1;
568
+ } else {
569
+ tweenedOpacity = 1 - 0.2 * tween;
570
+ }
571
+ el.style.opacity = tweenedOpacity;
572
+ el.style.visibility = 'visible';
573
+ }
574
+
575
+ for (i = 1; i <= half; ++i) {
576
+ // right side
577
+ if (this.options.fullWidth) {
578
+ zTranslation = this.options.dist;
579
+ tweenedOpacity = i === half && delta < 0 ? 1 - tween : 1;
580
+ } else {
581
+ zTranslation = this.options.dist * (i * 2 + tween * dir);
582
+ tweenedOpacity = 1 - 0.2 * (i * 2 + tween * dir);
583
+ }
584
+ // Don't show wrapped items.
585
+ if (!this.noWrap || this.center + i < this.count) {
586
+ el = this.images[this._wrap(this.center + i)];
587
+ el.style[this.xform] = alignment + ' translateX(' + (this.options.shift + (this.dim * i - delta) / 2) + 'px)' + ' translateZ(' + zTranslation + 'px)';
588
+ el.style.zIndex = -i;
589
+ el.style.opacity = tweenedOpacity;
590
+ el.style.visibility = 'visible';
591
+ }
592
+
593
+ // left side
594
+ if (this.options.fullWidth) {
595
+ zTranslation = this.options.dist;
596
+ tweenedOpacity = i === half && delta > 0 ? 1 - tween : 1;
597
+ } else {
598
+ zTranslation = this.options.dist * (i * 2 - tween * dir);
599
+ tweenedOpacity = 1 - 0.2 * (i * 2 - tween * dir);
600
+ }
601
+ // Don't show wrapped items.
602
+ if (!this.noWrap || this.center - i >= 0) {
603
+ el = this.images[this._wrap(this.center - i)];
604
+ el.style[this.xform] = alignment + ' translateX(' + (-this.options.shift + (-this.dim * i - delta) / 2) + 'px)' + ' translateZ(' + zTranslation + 'px)';
605
+ el.style.zIndex = -i;
606
+ el.style.opacity = tweenedOpacity;
607
+ el.style.visibility = 'visible';
608
+ }
609
+ }
610
+
611
+ // center
612
+ // Don't show wrapped items.
613
+ if (!this.noWrap || this.center >= 0 && this.center < this.count) {
614
+ el = this.images[this._wrap(this.center)];
615
+ el.style[this.xform] = alignment + ' translateX(' + -delta / 2 + 'px)' + ' translateX(' + dir * this.options.shift * tween + 'px)' + ' translateZ(' + this.options.dist * tween + 'px)';
616
+ el.style.zIndex = 0;
617
+ if (this.options.fullWidth) {
618
+ tweenedOpacity = 1;
619
+ } else {
620
+ tweenedOpacity = 1 - 0.2 * tween;
621
+ }
622
+ el.style.opacity = tweenedOpacity;
623
+ el.style.visibility = 'visible';
624
+ }
625
+
626
+ // onCycleTo callback
627
+ var $currItem = this.$el.find('.carousel-item').eq(this._wrap(this.center));
628
+ if (lastCenter !== this.center && typeof this.options.onCycleTo === "function") {
629
+ this.options.onCycleTo.call(this, $currItem[0], this.dragged);
630
+ }
631
+
632
+ // One time callback
633
+ if (typeof this.oneTimeCallback === "function") {
634
+ this.oneTimeCallback.call(this, $currItem[0], this.dragged);
635
+ this.oneTimeCallback = null;
636
+ }
637
+ }
638
+
639
+ /**
640
+ * Cycle to target
641
+ * @param {Number} n
642
+ * @param {Function} callback
643
+ */
644
+
645
+ }, {
646
+ key: '_cycleTo',
647
+ value: function _cycleTo(n, callback) {
648
+ var diff = this.center % this.count - n;
649
+
650
+ // Account for wraparound.
651
+ if (!this.noWrap) {
652
+ if (diff < 0) {
653
+ if (Math.abs(diff + this.count) < Math.abs(diff)) {
654
+ diff += this.count;
655
+ }
656
+ } else if (diff > 0) {
657
+ if (Math.abs(diff - this.count) < diff) {
658
+ diff -= this.count;
659
+ }
660
+ }
661
+ }
662
+
663
+ this.target = this.dim * Math.round(this.offset / this.dim);
664
+ // Next
665
+ if (diff < 0) {
666
+ this.target += this.dim * Math.abs(diff);
667
+
668
+ // Prev
669
+ } else if (diff > 0) {
670
+ this.target -= this.dim * diff;
671
+ }
672
+
673
+ // Set one time callback
674
+ if (typeof callback === "function") {
675
+ this.oneTimeCallback = callback;
676
+ }
677
+
678
+ // Scroll
679
+ if (this.offset !== this.target) {
680
+ this.amplitude = this.target - this.offset;
681
+ this.timestamp = Date.now();
682
+ requestAnimationFrame(this._autoScrollBound);
683
+ }
684
+ }
685
+
686
+ /**
687
+ * Cycle to next item
688
+ * @param {Number} [n]
689
+ */
690
+
691
+ }, {
692
+ key: 'next',
693
+ value: function next(n) {
694
+ if (n === undefined || isNaN(n)) {
695
+ n = 1;
696
+ }
697
+
698
+ var index = this.center + n;
699
+ if (index > this.count || index < 0) {
700
+ if (this.noWrap) {
701
+ return;
702
+ } else {
703
+ index = this._wrap(index);
704
+ }
705
+ }
706
+ this._cycleTo(index);
707
+ }
708
+
709
+ /**
710
+ * Cycle to previous item
711
+ * @param {Number} [n]
712
+ */
713
+
714
+ }, {
715
+ key: 'prev',
716
+ value: function prev(n) {
717
+ if (n === undefined || isNaN(n)) {
718
+ n = 1;
719
+ }
720
+
721
+ var index = this.center - n;
722
+ if (index > this.count || index < 0) {
723
+ if (this.noWrap) {
724
+ return;
725
+ } else {
726
+ index = this._wrap(index);
727
+ }
728
+ }
729
+
730
+ this._cycleTo(index);
731
+ }
732
+
733
+ /**
734
+ * Cycle to nth item
735
+ * @param {Number} [n]
736
+ * @param {Function} callback
737
+ */
738
+
739
+ }, {
740
+ key: 'set',
741
+ value: function set(n, callback) {
742
+ if (n === undefined || isNaN(n)) {
743
+ n = 0;
744
+ }
745
+
746
+ if (n > this.count || n < 0) {
747
+ if (this.noWrap) {
748
+ return;
749
+ } else {
750
+ n = this._wrap(n);
751
+ }
752
+ }
753
+
754
+ this._cycleTo(n, callback);
755
+ }
756
+ }], [{
757
+ key: 'init',
758
+ value: function init($els, options) {
759
+ var arr = [];
760
+ $els.each(function () {
761
+ arr.push(new Carousel(this, options));
762
+ });
763
+ return arr;
764
+ }
765
+
766
+ /**
767
+ * Get Instance
768
+ */
769
+
770
+ }, {
771
+ key: 'getInstance',
772
+ value: function getInstance(el) {
773
+ var domElem = !!el.jquery ? el[0] : el;
774
+ return domElem.M_Carousel;
775
+ }
776
+ }, {
777
+ key: 'defaults',
778
+ get: function () {
779
+ return _defaults;
780
+ }
781
+ }]);
782
+
783
+ return Carousel;
784
+ }();
785
+
786
+ M.Carousel = Carousel;
787
+
788
+ if (M.jQueryLoaded) {
789
+ M.initializeJqueryWrapper(Carousel, 'carousel', 'M_Carousel');
790
+ }
791
+ })(cash);