materialize-sass 0.97.0 → 1.0.0.1

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