@materializecss/materialize 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/Gruntfile.js +722 -712
  2. package/LICENSE +21 -21
  3. package/README.md +91 -91
  4. package/dist/css/materialize.css +78 -137
  5. package/dist/css/materialize.min.css +12 -12
  6. package/dist/js/materialize.js +1502 -1378
  7. package/dist/js/materialize.min.js +6 -6
  8. package/extras/noUiSlider/nouislider.css +403 -403
  9. package/extras/noUiSlider/nouislider.js +2147 -2147
  10. package/js/anime.min.js +34 -34
  11. package/js/autocomplete.js +479 -479
  12. package/js/buttons.js +354 -354
  13. package/js/cards.js +40 -40
  14. package/js/carousel.js +732 -732
  15. package/js/cash.js +960 -960
  16. package/js/characterCounter.js +136 -136
  17. package/js/chips.js +486 -486
  18. package/js/collapsible.js +275 -275
  19. package/js/component.js +44 -44
  20. package/js/datepicker.js +983 -983
  21. package/js/dropdown.js +669 -669
  22. package/js/forms.js +285 -285
  23. package/js/global.js +428 -428
  24. package/js/materialbox.js +453 -453
  25. package/js/modal.js +382 -382
  26. package/js/parallax.js +138 -138
  27. package/js/pushpin.js +148 -148
  28. package/js/range.js +263 -263
  29. package/js/scrollspy.js +295 -295
  30. package/js/select.js +391 -391
  31. package/js/sidenav.js +583 -583
  32. package/js/slider.js +497 -359
  33. package/js/tabs.js +402 -402
  34. package/js/tapTarget.js +315 -315
  35. package/js/timepicker.js +712 -712
  36. package/js/toasts.js +325 -325
  37. package/js/tooltip.js +320 -320
  38. package/js/waves.js +614 -614
  39. package/package.json +87 -84
  40. package/sass/components/_badges.scss +55 -55
  41. package/sass/components/_buttons.scss +322 -322
  42. package/sass/components/_cards.scss +195 -195
  43. package/sass/components/_carousel.scss +90 -90
  44. package/sass/components/_chips.scss +96 -96
  45. package/sass/components/_collapsible.scss +91 -91
  46. package/sass/components/_collection.scss +106 -106
  47. package/sass/components/_color-classes.scss +32 -32
  48. package/sass/components/_color-variables.scss +370 -370
  49. package/sass/components/_datepicker.scss +191 -191
  50. package/sass/components/_dropdown.scss +84 -84
  51. package/sass/components/_global.scss +646 -646
  52. package/sass/components/_grid.scss +158 -158
  53. package/sass/components/_icons-material-design.scss +5 -5
  54. package/sass/components/_materialbox.scss +42 -42
  55. package/sass/components/_modal.scss +97 -97
  56. package/sass/components/_navbar.scss +208 -208
  57. package/sass/components/_normalize.scss +447 -447
  58. package/sass/components/_preloader.scss +334 -334
  59. package/sass/components/_pulse.scss +34 -34
  60. package/sass/components/_sidenav.scss +214 -214
  61. package/sass/components/_slider.scss +100 -91
  62. package/sass/components/_table_of_contents.scss +33 -33
  63. package/sass/components/_tabs.scss +99 -99
  64. package/sass/components/_tapTarget.scss +103 -103
  65. package/sass/components/_timepicker.scss +199 -199
  66. package/sass/components/_toast.scss +58 -58
  67. package/sass/components/_tooltip.scss +32 -32
  68. package/sass/components/_transitions.scss +12 -12
  69. package/sass/components/_typography.scss +62 -62
  70. package/sass/components/_variables.scss +352 -352
  71. package/sass/components/_waves.scss +187 -187
  72. package/sass/components/forms/_checkboxes.scss +200 -200
  73. package/sass/components/forms/_file-input.scss +44 -44
  74. package/sass/components/forms/_forms.scss +22 -22
  75. package/sass/components/forms/_input-fields.scss +388 -388
  76. package/sass/components/forms/_radio-buttons.scss +115 -115
  77. package/sass/components/forms/_range.scss +161 -161
  78. package/sass/components/forms/_select.scss +199 -199
  79. package/sass/components/forms/_switches.scss +91 -91
  80. package/sass/materialize.scss +42 -42
  81. package/sass/_style.scss +0 -929
  82. package/sass/ghpages-materialize.scss +0 -7
package/js/slider.js CHANGED
@@ -1,359 +1,497 @@
1
- (function($, anim) {
2
- 'use strict';
3
-
4
- let _defaults = {
5
- indicators: true,
6
- height: 400,
7
- duration: 500,
8
- interval: 6000
9
- };
10
-
11
- /**
12
- * @class
13
- *
14
- */
15
- class Slider extends Component {
16
- /**
17
- * Construct Slider instance and set up overlay
18
- * @constructor
19
- * @param {Element} el
20
- * @param {Object} options
21
- */
22
- constructor(el, options) {
23
- super(Slider, el, options);
24
-
25
- this.el.M_Slider = this;
26
-
27
- /**
28
- * Options for the modal
29
- * @member Slider#options
30
- * @prop {Boolean} [indicators=true] - Show indicators
31
- * @prop {Number} [height=400] - height of slider
32
- * @prop {Number} [duration=500] - Length in ms of slide transition
33
- * @prop {Number} [interval=6000] - Length in ms of slide interval
34
- */
35
- this.options = $.extend({}, Slider.defaults, options);
36
-
37
- // setup
38
- this.$slider = this.$el.find('.slides');
39
- this.$slides = this.$slider.children('li');
40
- this.activeIndex = this.$slides
41
- .filter(function(item) {
42
- return $(item).hasClass('active');
43
- })
44
- .first()
45
- .index();
46
- if (this.activeIndex != -1) {
47
- this.$active = this.$slides.eq(this.activeIndex);
48
- }
49
-
50
- this._setSliderHeight();
51
-
52
- // Set initial positions of captions
53
- this.$slides.find('.caption').each((el) => {
54
- this._animateCaptionIn(el, 0);
55
- });
56
-
57
- // Move img src into background-image
58
- this.$slides.find('img').each((el) => {
59
- let placeholderBase64 =
60
- 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
61
- if ($(el).attr('src') !== placeholderBase64) {
62
- $(el).css('background-image', 'url("' + $(el).attr('src') + '")');
63
- $(el).attr('src', placeholderBase64);
64
- }
65
- });
66
-
67
- this._setupIndicators();
68
-
69
- // Show active slide
70
- if (this.$active) {
71
- this.$active.css('display', 'block');
72
- } else {
73
- this.$slides.first().addClass('active');
74
- anim({
75
- targets: this.$slides.first()[0],
76
- opacity: 1,
77
- duration: this.options.duration,
78
- easing: 'easeOutQuad'
79
- });
80
-
81
- this.activeIndex = 0;
82
- this.$active = this.$slides.eq(this.activeIndex);
83
-
84
- // Update indicators
85
- if (this.options.indicators) {
86
- this.$indicators.eq(this.activeIndex).addClass('active');
87
- }
88
- }
89
-
90
- // Adjust height to current slide
91
- this.$active.find('img').each((el) => {
92
- anim({
93
- targets: this.$active.find('.caption')[0],
94
- opacity: 1,
95
- translateX: 0,
96
- translateY: 0,
97
- duration: this.options.duration,
98
- easing: 'easeOutQuad'
99
- });
100
- });
101
-
102
- this._setupEventHandlers();
103
-
104
- // auto scroll
105
- this.start();
106
- }
107
-
108
- static get defaults() {
109
- return _defaults;
110
- }
111
-
112
- static init(els, options) {
113
- return super.init(this, els, options);
114
- }
115
-
116
- /**
117
- * Get Instance
118
- */
119
- static getInstance(el) {
120
- let domElem = !!el.jquery ? el[0] : el;
121
- return domElem.M_Slider;
122
- }
123
-
124
- /**
125
- * Teardown component
126
- */
127
- destroy() {
128
- this.pause();
129
- this._removeIndicators();
130
- this._removeEventHandlers();
131
- this.el.M_Slider = undefined;
132
- }
133
-
134
- /**
135
- * Setup Event Handlers
136
- */
137
- _setupEventHandlers() {
138
- this._handleIntervalBound = this._handleInterval.bind(this);
139
- this._handleIndicatorClickBound = this._handleIndicatorClick.bind(this);
140
-
141
- if (this.options.indicators) {
142
- this.$indicators.each((el) => {
143
- el.addEventListener('click', this._handleIndicatorClickBound);
144
- });
145
- }
146
- }
147
-
148
- /**
149
- * Remove Event Handlers
150
- */
151
- _removeEventHandlers() {
152
- if (this.options.indicators) {
153
- this.$indicators.each((el) => {
154
- el.removeEventListener('click', this._handleIndicatorClickBound);
155
- });
156
- }
157
- }
158
-
159
- /**
160
- * Handle indicator click
161
- * @param {Event} e
162
- */
163
- _handleIndicatorClick(e) {
164
- let currIndex = $(e.target).index();
165
- this.set(currIndex);
166
- }
167
-
168
- /**
169
- * Handle Interval
170
- */
171
- _handleInterval() {
172
- let newActiveIndex = this.$slider.find('.active').index();
173
- if (this.$slides.length === newActiveIndex + 1) newActiveIndex = 0;
174
- // loop to start
175
- else newActiveIndex += 1;
176
-
177
- this.set(newActiveIndex);
178
- }
179
-
180
- /**
181
- * Animate in caption
182
- * @param {Element} caption
183
- * @param {Number} duration
184
- */
185
- _animateCaptionIn(caption, duration) {
186
- let animOptions = {
187
- targets: caption,
188
- opacity: 0,
189
- duration: duration,
190
- easing: 'easeOutQuad'
191
- };
192
-
193
- if ($(caption).hasClass('center-align')) {
194
- animOptions.translateY = -100;
195
- } else if ($(caption).hasClass('right-align')) {
196
- animOptions.translateX = 100;
197
- } else if ($(caption).hasClass('left-align')) {
198
- animOptions.translateX = -100;
199
- }
200
-
201
- anim(animOptions);
202
- }
203
-
204
- /**
205
- * Set height of slider
206
- */
207
- _setSliderHeight() {
208
- // If fullscreen, do nothing
209
- if (!this.$el.hasClass('fullscreen')) {
210
- if (this.options.indicators) {
211
- // Add height if indicators are present
212
- this.$el.css('height', this.options.height + 40 + 'px');
213
- } else {
214
- this.$el.css('height', this.options.height + 'px');
215
- }
216
- this.$slider.css('height', this.options.height + 'px');
217
- }
218
- }
219
-
220
- /**
221
- * Setup indicators
222
- */
223
- _setupIndicators() {
224
- if (this.options.indicators) {
225
- this.$indicators = $('<ul class="indicators"></ul>');
226
- this.$slides.each((el, index) => {
227
- let $indicator = $('<li class="indicator-item"></li>');
228
- this.$indicators.append($indicator[0]);
229
- });
230
- this.$el.append(this.$indicators[0]);
231
- this.$indicators = this.$indicators.children('li.indicator-item');
232
- }
233
- }
234
-
235
- /**
236
- * Remove indicators
237
- */
238
- _removeIndicators() {
239
- this.$el.find('ul.indicators').remove();
240
- }
241
-
242
- /**
243
- * Cycle to nth item
244
- * @param {Number} index
245
- */
246
- set(index) {
247
- // Wrap around indices.
248
- if (index >= this.$slides.length) index = 0;
249
- else if (index < 0) index = this.$slides.length - 1;
250
-
251
- // Only do if index changes
252
- if (this.activeIndex != index) {
253
- this.$active = this.$slides.eq(this.activeIndex);
254
- let $caption = this.$active.find('.caption');
255
- this.$active.removeClass('active');
256
-
257
- anim({
258
- targets: this.$active[0],
259
- opacity: 0,
260
- duration: this.options.duration,
261
- easing: 'easeOutQuad',
262
- complete: () => {
263
- this.$slides.not('.active').each((el) => {
264
- anim({
265
- targets: el,
266
- opacity: 0,
267
- translateX: 0,
268
- translateY: 0,
269
- duration: 0,
270
- easing: 'easeOutQuad'
271
- });
272
- });
273
- }
274
- });
275
-
276
- this._animateCaptionIn($caption[0], this.options.duration);
277
-
278
- // Update indicators
279
- if (this.options.indicators) {
280
- this.$indicators.eq(this.activeIndex).removeClass('active');
281
- this.$indicators.eq(index).addClass('active');
282
- }
283
-
284
- anim({
285
- targets: this.$slides.eq(index)[0],
286
- opacity: 1,
287
- duration: this.options.duration,
288
- easing: 'easeOutQuad'
289
- });
290
-
291
- anim({
292
- targets: this.$slides.eq(index).find('.caption')[0],
293
- opacity: 1,
294
- translateX: 0,
295
- translateY: 0,
296
- duration: this.options.duration,
297
- delay: this.options.duration,
298
- easing: 'easeOutQuad'
299
- });
300
-
301
- this.$slides.eq(index).addClass('active');
302
- this.activeIndex = index;
303
-
304
- // Reset interval
305
- this.start();
306
- }
307
- }
308
-
309
- /**
310
- * Pause slider interval
311
- */
312
- pause() {
313
- clearInterval(this.interval);
314
- }
315
-
316
- /**
317
- * Start slider interval
318
- */
319
- start() {
320
- clearInterval(this.interval);
321
- this.interval = setInterval(
322
- this._handleIntervalBound,
323
- this.options.duration + this.options.interval
324
- );
325
- }
326
-
327
- /**
328
- * Move to next slide
329
- */
330
- next() {
331
- let newIndex = this.activeIndex + 1;
332
-
333
- // Wrap around indices.
334
- if (newIndex >= this.$slides.length) newIndex = 0;
335
- else if (newIndex < 0) newIndex = this.$slides.length - 1;
336
-
337
- this.set(newIndex);
338
- }
339
-
340
- /**
341
- * Move to previous slide
342
- */
343
- prev() {
344
- let newIndex = this.activeIndex - 1;
345
-
346
- // Wrap around indices.
347
- if (newIndex >= this.$slides.length) newIndex = 0;
348
- else if (newIndex < 0) newIndex = this.$slides.length - 1;
349
-
350
- this.set(newIndex);
351
- }
352
- }
353
-
354
- M.Slider = Slider;
355
-
356
- if (M.jQueryLoaded) {
357
- M.initializeJqueryWrapper(Slider, 'slider', 'M_Slider');
358
- }
359
- })(cash, M.anime);
1
+ (function($, anim) {
2
+ 'use strict';
3
+
4
+ let _defaults = {
5
+ indicators: true,
6
+ height: 400,
7
+ duration: 500,
8
+ interval: 6000,
9
+ pauseOnFocus: true,
10
+ pauseOnHover: true,
11
+ indicatorLabelFunc: null // Function which will generate a label for the indicators (ARIA)
12
+ };
13
+
14
+ /**
15
+ * @class
16
+ *
17
+ */
18
+ class Slider extends Component {
19
+ /**
20
+ * Construct Slider instance and set up overlay
21
+ * @constructor
22
+ * @param {Element} el
23
+ * @param {Object} options
24
+ */
25
+ constructor(el, options) {
26
+ super(Slider, el, options);
27
+
28
+ this.el.M_Slider = this;
29
+
30
+ /**
31
+ * Options for the modal
32
+ * @member Slider#options
33
+ * @prop {Boolean} [indicators=true] - Show indicators
34
+ * @prop {Number} [height=400] - height of slider
35
+ * @prop {Number} [duration=500] - Length in ms of slide transition
36
+ * @prop {Number} [interval=6000] - Length in ms of slide interval
37
+ * @prop {Boolean} [pauseOnFocus=true] - Pauses transition when slider receives keyboard focus
38
+ * @prop {Boolean} [pauseOnHover=true] - Pauses transition while mouse hovers the slider
39
+ * @prop {Function} [indicatorLabelFunc=null] - Function used to generate ARIA label to indicators (for accessibility purposes).
40
+ */
41
+ this.options = $.extend({}, Slider.defaults, options);
42
+
43
+ // init props
44
+ this.interval = null;
45
+ this.eventPause = false;
46
+ this._hovered = false;
47
+ this._focused = false;
48
+ this._focusCurrent = false;
49
+
50
+ // setup
51
+ this.$slider = this.$el.find('.slides');
52
+ this.$slides = this.$slider.children('li');
53
+ this.activeIndex = this.$slides
54
+ .filter(function(item) {
55
+ return $(item).hasClass('active');
56
+ })
57
+ .first()
58
+ .index();
59
+ if (this.activeIndex != -1) {
60
+ this.$active = this.$slides.eq(this.activeIndex);
61
+ }
62
+
63
+ this._setSliderHeight();
64
+
65
+ // Sets element id if it does not have one
66
+ if (this.$slider.attr('id')) this._sliderId = this.$slider.attr('id');
67
+ else {
68
+ this._sliderId = 'slider-' + M.guid();
69
+ this.$slider.attr('id', this._sliderId);
70
+ }
71
+
72
+ // Set initial positions of captions
73
+ this.$slides.find('.caption').each((el) => {
74
+ this._animateCaptionIn(el, 0);
75
+ });
76
+
77
+ // Move img src into background-image
78
+ this.$slides.find('img').each((el) => {
79
+ let placeholderBase64 =
80
+ 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
81
+ if ($(el).attr('src') !== placeholderBase64) {
82
+ $(el).css('background-image', 'url("' + $(el).attr('src') + '")');
83
+ $(el).attr('src', placeholderBase64);
84
+ }
85
+ });
86
+ this.$slides.each((el) => {
87
+ // Sets slide as focusable by code
88
+ if (!el.hasAttribute('tabindex')) el.setAttribute('tabindex', -1);
89
+ // Removes initial visibility from "inactive" slides
90
+ el.style.visibility = 'hidden';
91
+ });
92
+
93
+ this._setupIndicators();
94
+
95
+ // Show active slide
96
+ if (this.$active) {
97
+ this.$active.css('display', 'block').css('visibility', 'visible');
98
+ } else {
99
+ this.$slides.first().addClass('active');
100
+ anim({
101
+ targets: this.$slides.first()[0],
102
+ opacity: 1,
103
+ duration: this.options.duration,
104
+ easing: 'easeOutQuad'
105
+ });
106
+ this.$slides.first().css('visibility', 'visible');
107
+
108
+ this.activeIndex = 0;
109
+ this.$active = this.$slides.eq(this.activeIndex);
110
+
111
+ // Update indicators
112
+ if (this.options.indicators) {
113
+ this.$indicators.eq(this.activeIndex).children().first().addClass('active');
114
+ }
115
+ }
116
+
117
+ // Adjust height to current slide
118
+ this.$active.find('img').each((el) => {
119
+ anim({
120
+ targets: this.$active.find('.caption')[0],
121
+ opacity: 1,
122
+ translateX: 0,
123
+ translateY: 0,
124
+ duration: this.options.duration,
125
+ easing: 'easeOutQuad'
126
+ });
127
+ });
128
+
129
+ this._setupEventHandlers();
130
+
131
+ // auto scroll
132
+ this.start();
133
+ }
134
+
135
+ static get defaults() {
136
+ return _defaults;
137
+ }
138
+
139
+ static init(els, options) {
140
+ return super.init(this, els, options);
141
+ }
142
+
143
+ /**
144
+ * Get Instance
145
+ */
146
+ static getInstance(el) {
147
+ let domElem = !!el.jquery ? el[0] : el;
148
+ return domElem.M_Slider;
149
+ }
150
+
151
+ /**
152
+ * Teardown component
153
+ */
154
+ destroy() {
155
+ this.pause();
156
+ this._removeIndicators();
157
+ this._removeEventHandlers();
158
+ this.el.M_Slider = undefined;
159
+ }
160
+
161
+ /**
162
+ * Setup Event Handlers
163
+ */
164
+ _setupEventHandlers() {
165
+ this._handleIntervalBound = this._handleInterval.bind(this);
166
+ this._handleIndicatorClickBound = this._handleIndicatorClick.bind(this);
167
+ this._handleAutoPauseFocusBound = this._handleAutoPauseFocus.bind(this);
168
+ this._handleAutoStartFocusBound = this._handleAutoStartFocus.bind(this);
169
+ this._handleAutoPauseHoverBound = this._handleAutoPauseHover.bind(this);
170
+ this._handleAutoStartHoverBound = this._handleAutoStartHover.bind(this);
171
+
172
+ if (this.options.pauseOnFocus) {
173
+ this.el.addEventListener('focusin', this._handleAutoPauseFocusBound);
174
+ this.el.addEventListener('focusout', this._handleAutoStartFocusBound);
175
+ }
176
+ if (this.options.pauseOnHover) {
177
+ this.el.addEventListener('mouseenter', this._handleAutoPauseHoverBound);
178
+ this.el.addEventListener('mouseleave', this._handleAutoStartHoverBound);
179
+ }
180
+
181
+ if (this.options.indicators) {
182
+ this.$indicators.children().on('click', this._handleIndicatorClickBound);
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Remove Event Handlers
188
+ */
189
+ _removeEventHandlers() {
190
+ if (this.options.pauseOnFocus) {
191
+ this.el.removeEventListener('focusin', this._handleAutoPauseFocusBound);
192
+ this.el.removeEventListener('focusout', this._handleAutoStartFocusBound);
193
+ }
194
+ if (this.options.pauseOnHover) {
195
+ this.el.removeEventListener('mouseenter', this._handleAutoPauseHoverBound);
196
+ this.el.removeEventListener('mouseleave', this._handleAutoStartHoverBound);
197
+ }
198
+ if (this.options.indicators) {
199
+ this.$indicators.children().off('click', this._handleIndicatorClickBound);
200
+ }
201
+ }
202
+
203
+ /**
204
+ * Handle indicator click
205
+ * @param {Event} e
206
+ */
207
+ _handleIndicatorClick(e) {
208
+ let currIndex = $(e.target).parent().index();
209
+ this._focusCurrent = true;
210
+ this.set(currIndex);
211
+ }
212
+
213
+ /**
214
+ * Mouse enter event handler
215
+ */
216
+ _handleAutoPauseHover() {
217
+ this._hovered = true;
218
+ if (this.interval != null) {
219
+ this._pause(true);
220
+ }
221
+ }
222
+
223
+ /**
224
+ * Focus in event handler
225
+ */
226
+ _handleAutoPauseFocus() {
227
+ this._focused = true;
228
+ if (this.interval != null) {
229
+ this._pause(true);
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Mouse enter event handler
235
+ */
236
+ _handleAutoStartHover() {
237
+ this._hovered = false;
238
+ if (!(this.options.pauseOnFocus && this._focused) && this.eventPause) {
239
+ this.start();
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Focus out leave event handler
245
+ */
246
+ _handleAutoStartFocus() {
247
+ this._focused = false;
248
+ if (!(this.options.pauseOnHover && this._hovered) && this.eventPause) {
249
+ this.start();
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Handle Interval
255
+ */
256
+ _handleInterval() {
257
+ let newActiveIndex = this.$slider.find('.active').index();
258
+ if (this.$slides.length === newActiveIndex + 1) newActiveIndex = 0;
259
+ // loop to start
260
+ else newActiveIndex += 1;
261
+
262
+ this.set(newActiveIndex);
263
+ }
264
+
265
+ /**
266
+ * Animate in caption
267
+ * @param {Element} caption
268
+ * @param {Number} duration
269
+ */
270
+ _animateCaptionIn(caption, duration) {
271
+ let animOptions = {
272
+ targets: caption,
273
+ opacity: 0,
274
+ duration: duration,
275
+ easing: 'easeOutQuad'
276
+ };
277
+
278
+ if ($(caption).hasClass('center-align')) {
279
+ animOptions.translateY = -100;
280
+ } else if ($(caption).hasClass('right-align')) {
281
+ animOptions.translateX = 100;
282
+ } else if ($(caption).hasClass('left-align')) {
283
+ animOptions.translateX = -100;
284
+ }
285
+
286
+ anim(animOptions);
287
+ }
288
+
289
+ /**
290
+ * Set height of slider
291
+ */
292
+ _setSliderHeight() {
293
+ // If fullscreen, do nothing
294
+ if (!this.$el.hasClass('fullscreen')) {
295
+ if (this.options.indicators) {
296
+ // Add height if indicators are present
297
+ this.$el.css('height', this.options.height + 40 + 'px');
298
+ } else {
299
+ this.$el.css('height', this.options.height + 'px');
300
+ }
301
+ this.$slider.css('height', this.options.height + 'px');
302
+ }
303
+ }
304
+
305
+ /**
306
+ * Setup indicators
307
+ */
308
+ _setupIndicators() {
309
+ if (this.options.indicators) {
310
+ this.$indicators = $('<ul class="indicators"></ul>');
311
+ this.$slides.each((el, i) => {
312
+ let label = this.options.indicatorLabelFunc
313
+ ? this.options.indicatorLabelFunc.call(this, i + 1, i === 0)
314
+ : `${i + 1}`;
315
+ let $indicator = $(`<li class="indicator-item">
316
+ <button type="button" class="indicator-item-btn" aria-label="${label}" aria-controls="${this._sliderId}"></button>
317
+ </li>`);
318
+ this.$indicators.append($indicator[0]);
319
+ });
320
+ this.$el.append(this.$indicators[0]);
321
+ this.$indicators = this.$indicators.children('li.indicator-item');
322
+ }
323
+ }
324
+
325
+ /**
326
+ * Remove indicators
327
+ */
328
+ _removeIndicators() {
329
+ this.$el.find('ul.indicators').remove();
330
+ }
331
+
332
+ /**
333
+ * Cycle to nth item
334
+ * @param {Number} index
335
+ */
336
+ set(index) {
337
+ // Wrap around indices.
338
+ if (index >= this.$slides.length) index = 0;
339
+ else if (index < 0) index = this.$slides.length - 1;
340
+
341
+ // Only do if index changes
342
+ if (this.activeIndex != index) {
343
+ this.$active = this.$slides.eq(this.activeIndex);
344
+ let $caption = this.$active.find('.caption');
345
+ this.$active.removeClass('active');
346
+ // Enables every slide
347
+ this.$slides.css('visibility', 'visible');
348
+
349
+ anim({
350
+ targets: this.$active[0],
351
+ opacity: 0,
352
+ duration: this.options.duration,
353
+ easing: 'easeOutQuad',
354
+ complete: () => {
355
+ this.$slides.not('.active').each((el) => {
356
+ anim({
357
+ targets: el,
358
+ opacity: 0,
359
+ translateX: 0,
360
+ translateY: 0,
361
+ duration: 0,
362
+ easing: 'easeOutQuad'
363
+ });
364
+ // Disables invisible slides (for assistive technologies)
365
+ el.style.visibility = 'hidden';
366
+ });
367
+ }
368
+ });
369
+
370
+ this._animateCaptionIn($caption[0], this.options.duration);
371
+
372
+ // Update indicators
373
+ if (this.options.indicators) {
374
+ let activeIndicator = this.$indicators
375
+ .eq(this.activeIndex)
376
+ .children()
377
+ .first();
378
+ let nextIndicator = this.$indicators
379
+ .eq(index)
380
+ .children()
381
+ .first();
382
+ activeIndicator.removeClass('active');
383
+ nextIndicator.addClass('active');
384
+ if (typeof this.options.indicatorLabelFunc === "function"){
385
+ activeIndicator.attr(
386
+ 'aria-label',
387
+ this.options.indicatorLabelFunc.call(
388
+ this,
389
+ this.$indicators.eq(this.activeIndex).index(),
390
+ false
391
+ )
392
+ );
393
+ nextIndicator.attr(
394
+ 'aria-label',
395
+ this.options.indicatorLabelFunc.call(
396
+ this,
397
+ this.$indicators.eq(index).index(),
398
+ true
399
+ )
400
+ );
401
+ }
402
+ }
403
+
404
+ anim({
405
+ targets: this.$slides.eq(index)[0],
406
+ opacity: 1,
407
+ duration: this.options.duration,
408
+ easing: 'easeOutQuad'
409
+ });
410
+
411
+ anim({
412
+ targets: this.$slides.eq(index).find('.caption')[0],
413
+ opacity: 1,
414
+ translateX: 0,
415
+ translateY: 0,
416
+ duration: this.options.duration,
417
+ delay: this.options.duration,
418
+ easing: 'easeOutQuad'
419
+ });
420
+
421
+ this.$slides.eq(index).addClass('active');
422
+ if (this._focusCurrent) {
423
+ this.$slides.eq(index)[0].focus();
424
+ this._focusCurrent = false;
425
+ }
426
+ this.activeIndex = index;
427
+
428
+ // Reset interval, if allowed. This check prevents autostart
429
+ // when slider is paused, since it can be changed though indicators.
430
+ if (this.interval != null) {
431
+ this.start();
432
+ }
433
+ }
434
+ }
435
+
436
+ /**
437
+ * "Protected" function which pauses current interval
438
+ * @param {boolean} fromEvent Specifies if request came from event
439
+ */
440
+ _pause(fromEvent) {
441
+ clearInterval(this.interval);
442
+ this.eventPause = fromEvent;
443
+ this.interval = null;
444
+ }
445
+
446
+ /**
447
+ * Pause slider interval
448
+ */
449
+ pause() {
450
+ this._pause(false);
451
+ }
452
+
453
+ /**
454
+ * Start slider interval
455
+ */
456
+ start() {
457
+ clearInterval(this.interval);
458
+ this.interval = setInterval(
459
+ this._handleIntervalBound,
460
+ this.options.duration + this.options.interval
461
+ );
462
+ this.eventPause = false;
463
+ }
464
+
465
+ /**
466
+ * Move to next slide
467
+ */
468
+ next() {
469
+ let newIndex = this.activeIndex + 1;
470
+
471
+ // Wrap around indices.
472
+ if (newIndex >= this.$slides.length) newIndex = 0;
473
+ else if (newIndex < 0) newIndex = this.$slides.length - 1;
474
+
475
+ this.set(newIndex);
476
+ }
477
+
478
+ /**
479
+ * Move to previous slide
480
+ */
481
+ prev() {
482
+ let newIndex = this.activeIndex - 1;
483
+
484
+ // Wrap around indices.
485
+ if (newIndex >= this.$slides.length) newIndex = 0;
486
+ else if (newIndex < 0) newIndex = this.$slides.length - 1;
487
+
488
+ this.set(newIndex);
489
+ }
490
+ }
491
+
492
+ M.Slider = Slider;
493
+
494
+ if (M.jQueryLoaded) {
495
+ M.initializeJqueryWrapper(Slider, 'slider', 'M_Slider');
496
+ }
497
+ })(cash, M.anime);