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.
- checksums.yaml +5 -5
- data/README.md +18 -42
- data/Rakefile +17 -17
- data/{app/assets → assets}/javascripts/materialize-sprockets.js +8 -12
- data/assets/javascripts/materialize.js +11877 -0
- data/assets/javascripts/materialize/autocomplete.js +420 -0
- data/assets/javascripts/materialize/buttons.js +388 -0
- data/assets/javascripts/materialize/cards.js +28 -0
- data/assets/javascripts/materialize/carousel.js +791 -0
- data/assets/javascripts/materialize/cash.js +992 -0
- data/assets/javascripts/materialize/characterCounter.js +180 -0
- data/assets/javascripts/materialize/chips.js +555 -0
- data/assets/javascripts/materialize/collapsible.js +275 -0
- data/assets/javascripts/materialize/datepicker.js +898 -0
- data/assets/javascripts/materialize/dropdown.js +530 -0
- data/{app/assets → assets}/javascripts/materialize/extras/nouislider.js +1 -1
- data/{app/assets → assets}/javascripts/materialize/extras/nouislider.min.js +1 -1
- data/assets/javascripts/materialize/forms.js +223 -0
- data/assets/javascripts/materialize/global.js +353 -0
- data/assets/javascripts/materialize/materialbox.js +432 -0
- data/{app/assets → assets}/javascripts/materialize/modal.js +82 -113
- data/assets/javascripts/materialize/parallax.js +135 -0
- data/assets/javascripts/materialize/pushpin.js +158 -0
- data/assets/javascripts/materialize/range.js +305 -0
- data/assets/javascripts/materialize/scrollspy.js +322 -0
- data/assets/javascripts/materialize/select.js +426 -0
- data/assets/javascripts/materialize/sidenav.js +584 -0
- data/assets/javascripts/materialize/slider.js +383 -0
- data/assets/javascripts/materialize/tabs.js +460 -0
- data/assets/javascripts/materialize/tapTarget.js +347 -0
- data/assets/javascripts/materialize/timepicker.js +616 -0
- data/{app/assets → assets}/javascripts/materialize/toasts.js +42 -46
- data/assets/javascripts/materialize/tooltip.js +325 -0
- data/assets/javascripts/materialize/velocity.min.js +782 -0
- data/{app/assets → assets}/javascripts/materialize/waves.js +0 -0
- data/{app/assets → assets}/stylesheets/materialize.scss +5 -6
- data/{app/assets → assets}/stylesheets/materialize/components/_badges.scss +1 -1
- data/{app/assets → assets}/stylesheets/materialize/components/_buttons.scss +34 -2
- data/{app/assets → assets}/stylesheets/materialize/components/_cards.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_carousel.scss +1 -1
- data/{app/assets → assets}/stylesheets/materialize/components/_chips.scss +6 -5
- data/{app/assets → assets}/stylesheets/materialize/components/_collapsible.scss +3 -3
- data/{app/assets → assets}/stylesheets/materialize/components/_color.scss +0 -0
- data/assets/stylesheets/materialize/components/_datepicker.scss +180 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_dropdown.scss +16 -15
- data/{app/assets → assets}/stylesheets/materialize/components/_global.scss +49 -14
- data/{app/assets → assets}/stylesheets/materialize/components/_grid.scss +1 -1
- data/{app/assets → assets}/stylesheets/materialize/components/_icons-material-design.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_materialbox.scss +0 -0
- data/assets/stylesheets/materialize/components/_mixins.scss +5 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_modal.scss +1 -1
- data/{app/assets → assets}/stylesheets/materialize/components/_navbar.scss +0 -0
- data/assets/stylesheets/materialize/components/_normalize.scss +447 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_preloader.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_pulse.scss +0 -0
- data/{app/assets/stylesheets/materialize/components/_sideNav.scss → assets/stylesheets/materialize/components/_sidenav.scss} +23 -21
- data/{app/assets → assets}/stylesheets/materialize/components/_slider.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_table_of_contents.scss +3 -3
- data/{app/assets → assets}/stylesheets/materialize/components/_tabs.scss +2 -2
- data/{app/assets → assets}/stylesheets/materialize/components/_tapTarget.scss +0 -0
- data/assets/stylesheets/materialize/components/_timepicker.scss +182 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_toast.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_tooltip.scss +1 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_transitions.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_typography.scss +8 -8
- data/{app/assets → assets}/stylesheets/materialize/components/_variables.scss +42 -44
- data/{app/assets → assets}/stylesheets/materialize/components/_waves.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_checkboxes.scss +24 -24
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_file-input.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_forms.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_input-fields.scss +49 -35
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_radio-buttons.scss +29 -29
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_range.scss +32 -31
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_select.scss +20 -11
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_switches.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/extras/nouislider.css +1 -1
- data/lib/materialize-sass.rb +13 -23
- data/lib/materialize-sass/engine.rb +6 -9
- data/lib/materialize-sass/version.rb +1 -1
- data/materialize-sass.gemspec +2 -1
- metadata +97 -97
- data/app/assets/fonts/roboto/Roboto-Bold.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Light.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Medium.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Regular.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Thin.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
- data/app/assets/javascripts/materialize.js +0 -10021
- data/app/assets/javascripts/materialize/animation.js +0 -7
- data/app/assets/javascripts/materialize/buttons.js +0 -253
- data/app/assets/javascripts/materialize/cards.js +0 -28
- data/app/assets/javascripts/materialize/carousel.js +0 -543
- data/app/assets/javascripts/materialize/character_counter.js +0 -64
- data/app/assets/javascripts/materialize/chips.js +0 -315
- data/app/assets/javascripts/materialize/collapsible.js +0 -178
- data/app/assets/javascripts/materialize/date_picker/picker.date.js +0 -1399
- data/app/assets/javascripts/materialize/date_picker/picker.js +0 -1196
- data/app/assets/javascripts/materialize/date_picker/picker.time.js +0 -646
- data/app/assets/javascripts/materialize/dropdown.js +0 -257
- data/app/assets/javascripts/materialize/forms.js +0 -806
- data/app/assets/javascripts/materialize/global.js +0 -170
- data/app/assets/javascripts/materialize/hammer.min.js +0 -424
- data/app/assets/javascripts/materialize/initial.js +0 -10
- data/app/assets/javascripts/materialize/jquery.easing.1.4.js +0 -144
- data/app/assets/javascripts/materialize/jquery.hammer.js +0 -33
- data/app/assets/javascripts/materialize/materialbox.js +0 -263
- data/app/assets/javascripts/materialize/parallax.js +0 -54
- data/app/assets/javascripts/materialize/pushpin.js +0 -68
- data/app/assets/javascripts/materialize/scrollFire.js +0 -49
- data/app/assets/javascripts/materialize/scrollspy.js +0 -230
- data/app/assets/javascripts/materialize/sideNav.js +0 -395
- data/app/assets/javascripts/materialize/slider.js +0 -295
- data/app/assets/javascripts/materialize/tabs.js +0 -244
- data/app/assets/javascripts/materialize/tapTarget.js +0 -184
- data/app/assets/javascripts/materialize/tooltip.js +0 -227
- data/app/assets/javascripts/materialize/transitions.js +0 -163
- data/app/assets/javascripts/materialize/velocity.min.js +0 -626
- data/app/assets/stylesheets/materialize/components/_normalize.scss +0 -424
- data/app/assets/stylesheets/materialize/components/_roboto.scss +0 -39
- data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +0 -469
- data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +0 -216
- data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +0 -267
@@ -0,0 +1,383 @@
|
|
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 ($, Vel) {
|
6
|
+
'use strict';
|
7
|
+
|
8
|
+
var _defaults = {
|
9
|
+
indicators: true,
|
10
|
+
height: 400,
|
11
|
+
duration: 500,
|
12
|
+
interval: 6000
|
13
|
+
};
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @class
|
17
|
+
*
|
18
|
+
*/
|
19
|
+
|
20
|
+
var Slider = function () {
|
21
|
+
/**
|
22
|
+
* Construct Slider instance and set up overlay
|
23
|
+
* @constructor
|
24
|
+
* @param {Element} el
|
25
|
+
* @param {Object} options
|
26
|
+
*/
|
27
|
+
function Slider(el, options) {
|
28
|
+
var _this = this;
|
29
|
+
|
30
|
+
_classCallCheck(this, Slider);
|
31
|
+
|
32
|
+
// If exists, destroy and reinitialize
|
33
|
+
if (!!el.M_Slider) {
|
34
|
+
el.M_Slider.destroy();
|
35
|
+
}
|
36
|
+
|
37
|
+
this.el = el;
|
38
|
+
this.$el = $(el);
|
39
|
+
this.el.M_Slider = this;
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Options for the modal
|
43
|
+
* @member Slider#options
|
44
|
+
* @prop {Boolean} [indicators=true] - Show indicators
|
45
|
+
* @prop {Number} [height=400] - height of slider
|
46
|
+
* @prop {Number} [duration=500] - Length in ms of slide transition
|
47
|
+
* @prop {Number} [interval=6000] - Length in ms of slide interval
|
48
|
+
*/
|
49
|
+
this.options = $.extend({}, Slider.defaults, options);
|
50
|
+
|
51
|
+
// setup
|
52
|
+
this.$slider = this.$el.find('.slides');
|
53
|
+
this.$slides = this.$slider.children('li');
|
54
|
+
this.activeIndex = this.$slider.find('.active').index();
|
55
|
+
if (this.activeIndex != -1) {
|
56
|
+
this.$active = this.$slides.eq(this.activeIndex);
|
57
|
+
}
|
58
|
+
|
59
|
+
this._setSliderHeight();
|
60
|
+
|
61
|
+
// Set initial positions of captions
|
62
|
+
this.$slides.find('.caption').each(function (el) {
|
63
|
+
_this._animateCaptionIn(el, 0);
|
64
|
+
});
|
65
|
+
|
66
|
+
// Move img src into background-image
|
67
|
+
this.$slides.find('img').each(function (el) {
|
68
|
+
var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
|
69
|
+
if ($(el).attr('src') !== placeholderBase64) {
|
70
|
+
$(el).css('background-image', 'url("' + $(el).attr('src') + '")');
|
71
|
+
$(el).attr('src', placeholderBase64);
|
72
|
+
}
|
73
|
+
});
|
74
|
+
|
75
|
+
this._setupIndicators();
|
76
|
+
|
77
|
+
// Show active slide
|
78
|
+
if (this.$active) {
|
79
|
+
this.$active.css('display', 'block');
|
80
|
+
} else {
|
81
|
+
this.$slides.first().addClass('active');
|
82
|
+
Vel(this.$slides.first()[0], { opacity: 1 }, { duration: this.options.duration, queue: false, easing: 'easeOutQuad' });
|
83
|
+
|
84
|
+
this.activeIndex = 0;
|
85
|
+
this.$active = this.$slides.eq(this.activeIndex);
|
86
|
+
|
87
|
+
// Update indicators
|
88
|
+
if (this.options.indicators) {
|
89
|
+
this.$indicators.eq(this.activeIndex).addClass('active');
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
// Adjust height to current slide
|
94
|
+
this.$active.find('img').each(function (el) {
|
95
|
+
Vel(_this.$active.find('.caption')[0], { opacity: 1, translateX: 0, translateY: 0 }, { duration: _this.options.duration, queue: false, easing: 'easeOutQuad' });
|
96
|
+
});
|
97
|
+
|
98
|
+
this._setupEventHandlers();
|
99
|
+
|
100
|
+
// auto scroll
|
101
|
+
this.start();
|
102
|
+
}
|
103
|
+
|
104
|
+
_createClass(Slider, [{
|
105
|
+
key: 'destroy',
|
106
|
+
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Teardown component
|
110
|
+
*/
|
111
|
+
value: function destroy() {
|
112
|
+
this.pause();
|
113
|
+
this._removeIndicators();
|
114
|
+
this._removeEventHandlers();
|
115
|
+
this.el.M_Slider = undefined;
|
116
|
+
}
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Setup Event Handlers
|
120
|
+
*/
|
121
|
+
|
122
|
+
}, {
|
123
|
+
key: '_setupEventHandlers',
|
124
|
+
value: function _setupEventHandlers() {
|
125
|
+
var _this2 = this;
|
126
|
+
|
127
|
+
this._handleIntervalBound = this._handleInterval.bind(this);
|
128
|
+
this._handleIndicatorClickBound = this._handleIndicatorClick.bind(this);
|
129
|
+
|
130
|
+
if (this.options.indicators) {
|
131
|
+
this.$indicators.each(function (el) {
|
132
|
+
el.addEventListener('click', _this2._handleIndicatorClickBound);
|
133
|
+
});
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Remove Event Handlers
|
139
|
+
*/
|
140
|
+
|
141
|
+
}, {
|
142
|
+
key: '_removeEventHandlers',
|
143
|
+
value: function _removeEventHandlers() {
|
144
|
+
var _this3 = this;
|
145
|
+
|
146
|
+
if (this.options.indicators) {
|
147
|
+
this.$indicators.each(function (el) {
|
148
|
+
el.removeEventListener('click', _this3._handleIndicatorClickBound);
|
149
|
+
});
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Handle indicator click
|
155
|
+
* @param {Event} e
|
156
|
+
*/
|
157
|
+
|
158
|
+
}, {
|
159
|
+
key: '_handleIndicatorClick',
|
160
|
+
value: function _handleIndicatorClick(e) {
|
161
|
+
var currIndex = $(e.target).index();
|
162
|
+
this.set(currIndex);
|
163
|
+
}
|
164
|
+
|
165
|
+
/**
|
166
|
+
* Handle Interval
|
167
|
+
*/
|
168
|
+
|
169
|
+
}, {
|
170
|
+
key: '_handleInterval',
|
171
|
+
value: function _handleInterval() {
|
172
|
+
var newActiveIndex = this.$slider.find('.active').index();
|
173
|
+
if (this.$slides.length === newActiveIndex + 1) newActiveIndex = 0; // loop to start
|
174
|
+
else newActiveIndex += 1;
|
175
|
+
|
176
|
+
this.set(newActiveIndex);
|
177
|
+
}
|
178
|
+
|
179
|
+
/**
|
180
|
+
* Animate in caption
|
181
|
+
* @param {Element} caption
|
182
|
+
* @param {Number} duration
|
183
|
+
*/
|
184
|
+
|
185
|
+
}, {
|
186
|
+
key: '_animateCaptionIn',
|
187
|
+
value: function _animateCaptionIn(caption, duration) {
|
188
|
+
var velocityOptions = {
|
189
|
+
opacity: 0
|
190
|
+
};
|
191
|
+
|
192
|
+
if ($(caption).hasClass('center-align')) {
|
193
|
+
velocityOptions.translateY = -100;
|
194
|
+
} else if ($(caption).hasClass('right-align')) {
|
195
|
+
velocityOptions.translateX = 100;
|
196
|
+
} else if ($(caption).hasClass('left-align')) {
|
197
|
+
velocityOptions.translateX = -100;
|
198
|
+
}
|
199
|
+
|
200
|
+
Vel(caption, velocityOptions, { duration: duration, queue: false });
|
201
|
+
}
|
202
|
+
|
203
|
+
/**
|
204
|
+
* Set height of slider
|
205
|
+
*/
|
206
|
+
|
207
|
+
}, {
|
208
|
+
key: '_setSliderHeight',
|
209
|
+
value: function _setSliderHeight() {
|
210
|
+
// If fullscreen, do nothing
|
211
|
+
if (!this.$el.hasClass('fullscreen')) {
|
212
|
+
if (this.options.indicators) {
|
213
|
+
// Add height if indicators are present
|
214
|
+
this.$el.css('height', this.options.height + 40 + 'px');
|
215
|
+
} else {
|
216
|
+
this.$el.css('height', this.options.height + 'px');
|
217
|
+
}
|
218
|
+
this.$slider.css('height', this.options.height + 'px');
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
/**
|
223
|
+
* Setup indicators
|
224
|
+
*/
|
225
|
+
|
226
|
+
}, {
|
227
|
+
key: '_setupIndicators',
|
228
|
+
value: function _setupIndicators() {
|
229
|
+
var _this4 = this;
|
230
|
+
|
231
|
+
if (this.options.indicators) {
|
232
|
+
this.$indicators = $('<ul class="indicators"></ul>');
|
233
|
+
this.$slides.each(function (el, index) {
|
234
|
+
var $indicator = $('<li class="indicator-item"></li>');
|
235
|
+
_this4.$indicators.append($indicator[0]);
|
236
|
+
});
|
237
|
+
this.$el.append(this.$indicators[0]);
|
238
|
+
this.$indicators = this.$indicators.children('li.indicator-item');
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
/**
|
243
|
+
* Remove indicators
|
244
|
+
*/
|
245
|
+
|
246
|
+
}, {
|
247
|
+
key: '_removeIndicators',
|
248
|
+
value: function _removeIndicators() {
|
249
|
+
this.$el.find('ul.indicators').remove();
|
250
|
+
}
|
251
|
+
|
252
|
+
/**
|
253
|
+
* Cycle to nth item
|
254
|
+
* @param {Number} index
|
255
|
+
*/
|
256
|
+
|
257
|
+
}, {
|
258
|
+
key: 'set',
|
259
|
+
value: function set(index) {
|
260
|
+
var _this5 = this;
|
261
|
+
|
262
|
+
// Wrap around indices.
|
263
|
+
if (index >= this.$slides.length) index = 0;else if (index < 0) index = this.$slides.length - 1;
|
264
|
+
|
265
|
+
// Only do if index changes
|
266
|
+
if (this.activeIndex != index) {
|
267
|
+
this.$active = this.$slides.eq(this.activeIndex);
|
268
|
+
var $caption = this.$active.find('.caption');
|
269
|
+
|
270
|
+
this.$active.removeClass('active');
|
271
|
+
Vel(this.$active[0], { opacity: 0 }, { duration: this.options.duration, queue: false, easing: 'easeOutQuad',
|
272
|
+
complete: function () {
|
273
|
+
_this5.$slides.not('.active').each(function (el) {
|
274
|
+
Vel(el, { opacity: 0, translateX: 0, translateY: 0 }, { duration: 0, queue: false });
|
275
|
+
});
|
276
|
+
}.bind(this)
|
277
|
+
});
|
278
|
+
|
279
|
+
this._animateCaptionIn($caption[0], this.options.duration);
|
280
|
+
|
281
|
+
// Update indicators
|
282
|
+
if (this.options.indicators) {
|
283
|
+
this.$indicators.eq(this.activeIndex).removeClass('active');
|
284
|
+
this.$indicators.eq(index).addClass('active');
|
285
|
+
}
|
286
|
+
|
287
|
+
Vel(this.$slides.eq(index)[0], { opacity: 1 }, { duration: this.options.duration, queue: false, easing: 'easeOutQuad' });
|
288
|
+
Vel(this.$slides.eq(index).find('.caption')[0], { opacity: 1, translateX: 0, translateY: 0 }, { duration: this.options.duration, delay: this.options.duration, queue: false, easing: 'easeOutQuad' });
|
289
|
+
|
290
|
+
this.$slides.eq(index).addClass('active');
|
291
|
+
this.activeIndex = index;
|
292
|
+
|
293
|
+
// Reset interval
|
294
|
+
this.start();
|
295
|
+
}
|
296
|
+
}
|
297
|
+
|
298
|
+
/**
|
299
|
+
* Pause slider interval
|
300
|
+
*/
|
301
|
+
|
302
|
+
}, {
|
303
|
+
key: 'pause',
|
304
|
+
value: function pause() {
|
305
|
+
clearInterval(this.interval);
|
306
|
+
}
|
307
|
+
|
308
|
+
/**
|
309
|
+
* Start slider interval
|
310
|
+
*/
|
311
|
+
|
312
|
+
}, {
|
313
|
+
key: 'start',
|
314
|
+
value: function start() {
|
315
|
+
clearInterval(this.interval);
|
316
|
+
this.interval = setInterval(this._handleIntervalBound, this.options.duration + this.options.interval);
|
317
|
+
}
|
318
|
+
|
319
|
+
/**
|
320
|
+
* Move to next slide
|
321
|
+
*/
|
322
|
+
|
323
|
+
}, {
|
324
|
+
key: 'next',
|
325
|
+
value: function next() {
|
326
|
+
var newIndex = this.activeIndex + 1;
|
327
|
+
|
328
|
+
// Wrap around indices.
|
329
|
+
if (newIndex >= this.$slides.length) newIndex = 0;else if (newIndex < 0) newIndex = this.$slides.length - 1;
|
330
|
+
|
331
|
+
this.set(newIndex);
|
332
|
+
}
|
333
|
+
|
334
|
+
/**
|
335
|
+
* Move to previous slide
|
336
|
+
*/
|
337
|
+
|
338
|
+
}, {
|
339
|
+
key: 'prev',
|
340
|
+
value: function prev() {
|
341
|
+
var newIndex = this.activeIndex - 1;
|
342
|
+
|
343
|
+
// Wrap around indices.
|
344
|
+
if (newIndex >= this.$slides.length) newIndex = 0;else if (newIndex < 0) newIndex = this.$slides.length - 1;
|
345
|
+
|
346
|
+
this.set(newIndex);
|
347
|
+
}
|
348
|
+
}], [{
|
349
|
+
key: 'init',
|
350
|
+
value: function init($els, options) {
|
351
|
+
var arr = [];
|
352
|
+
$els.each(function () {
|
353
|
+
arr.push(new Slider(this, options));
|
354
|
+
});
|
355
|
+
return arr;
|
356
|
+
}
|
357
|
+
|
358
|
+
/**
|
359
|
+
* Get Instance
|
360
|
+
*/
|
361
|
+
|
362
|
+
}, {
|
363
|
+
key: 'getInstance',
|
364
|
+
value: function getInstance(el) {
|
365
|
+
var domElem = !!el.jquery ? el[0] : el;
|
366
|
+
return domElem.M_Slider;
|
367
|
+
}
|
368
|
+
}, {
|
369
|
+
key: 'defaults',
|
370
|
+
get: function () {
|
371
|
+
return _defaults;
|
372
|
+
}
|
373
|
+
}]);
|
374
|
+
|
375
|
+
return Slider;
|
376
|
+
}();
|
377
|
+
|
378
|
+
M.Slider = Slider;
|
379
|
+
|
380
|
+
if (M.jQueryLoaded) {
|
381
|
+
M.initializeJqueryWrapper(Slider, 'slider', 'M_Slider');
|
382
|
+
}
|
383
|
+
})(cash, M.Vel);
|
@@ -0,0 +1,460 @@
|
|
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 ($, Vel) {
|
6
|
+
'use strict';
|
7
|
+
|
8
|
+
var _defaults = {
|
9
|
+
duration: 300,
|
10
|
+
onShow: null,
|
11
|
+
swipeable: false,
|
12
|
+
responsiveThreshold: Infinity // breakpoint for swipeable
|
13
|
+
};
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @class
|
17
|
+
*
|
18
|
+
*/
|
19
|
+
|
20
|
+
var Tabs = function () {
|
21
|
+
/**
|
22
|
+
* Construct Tabs instance
|
23
|
+
* @constructor
|
24
|
+
* @param {Element} el
|
25
|
+
* @param {Object} options
|
26
|
+
*/
|
27
|
+
function Tabs(el, options) {
|
28
|
+
_classCallCheck(this, Tabs);
|
29
|
+
|
30
|
+
// If exists, destroy and reinitialize
|
31
|
+
if (!!el.M_Tabs) {
|
32
|
+
el.M_Tabs.destroy();
|
33
|
+
}
|
34
|
+
|
35
|
+
/**
|
36
|
+
* The jQuery element
|
37
|
+
* @type {jQuery}
|
38
|
+
*/
|
39
|
+
this.$el = $(el);
|
40
|
+
|
41
|
+
this.el = el;
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Options for the carousel
|
45
|
+
* @member Tabs#options
|
46
|
+
* @prop {Number} duration
|
47
|
+
* @prop {Function} onShow
|
48
|
+
* @prop {Boolean} swipeable
|
49
|
+
* @prop {Number} responsiveThreshold
|
50
|
+
*/
|
51
|
+
this.options = $.extend({}, Tabs.defaults, options);
|
52
|
+
|
53
|
+
this.el.M_Tabs = this;
|
54
|
+
|
55
|
+
// Setup
|
56
|
+
this.$tabLinks = this.$el.children('li.tab').children('a');
|
57
|
+
this.index = 0;
|
58
|
+
this._setTabsAndTabWidth();
|
59
|
+
this._setupActiveTabLink();
|
60
|
+
this._createIndicator();
|
61
|
+
|
62
|
+
if (this.options.swipeable) {
|
63
|
+
this._setupSwipeableTabs();
|
64
|
+
} else {
|
65
|
+
this._setupNormalTabs();
|
66
|
+
}
|
67
|
+
|
68
|
+
this._setupEventHandlers();
|
69
|
+
}
|
70
|
+
|
71
|
+
_createClass(Tabs, [{
|
72
|
+
key: 'destroy',
|
73
|
+
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Teardown component
|
77
|
+
*/
|
78
|
+
value: function destroy() {
|
79
|
+
this._removeEventHandlers();
|
80
|
+
this._indicator.parentNode.removeChild(this._indicator);
|
81
|
+
|
82
|
+
if (this.options.swipeable) {
|
83
|
+
this._teardownSwipeableTabs();
|
84
|
+
} else {
|
85
|
+
this._teardownNormalTabs();
|
86
|
+
}
|
87
|
+
|
88
|
+
this.$el[0].M_Tabs = undefined;
|
89
|
+
}
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Setup Event Handlers
|
93
|
+
*/
|
94
|
+
|
95
|
+
}, {
|
96
|
+
key: '_setupEventHandlers',
|
97
|
+
value: function _setupEventHandlers() {
|
98
|
+
this._handleWindowResizeBound = this._handleWindowResize.bind(this);
|
99
|
+
window.addEventListener('resize', this._handleWindowResizeBound);
|
100
|
+
|
101
|
+
this._handleTabClickBound = this._handleTabClick.bind(this);
|
102
|
+
this.el.addEventListener('click', this._handleTabClickBound);
|
103
|
+
}
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Remove Event Handlers
|
107
|
+
*/
|
108
|
+
|
109
|
+
}, {
|
110
|
+
key: '_removeEventHandlers',
|
111
|
+
value: function _removeEventHandlers() {
|
112
|
+
window.removeEventListener('resize', this._handleWindowResizeBound);
|
113
|
+
this.el.removeEventListener('click', this._handleTabClickBound);
|
114
|
+
}
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Handle window Resize
|
118
|
+
*/
|
119
|
+
|
120
|
+
}, {
|
121
|
+
key: '_handleWindowResize',
|
122
|
+
value: function _handleWindowResize() {
|
123
|
+
this._setTabsAndTabWidth();
|
124
|
+
|
125
|
+
if (this.tabWidth !== 0 && this.tabsWidth !== 0) {
|
126
|
+
this._indicator.style.left = this._calcLeftPos(this.$activeTabLink) + 'px';
|
127
|
+
this._indicator.style.right = this._calcRightPos(this.$activeTabLink) + 'px';
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Handle tab click
|
133
|
+
* @param {Event} e
|
134
|
+
*/
|
135
|
+
|
136
|
+
}, {
|
137
|
+
key: '_handleTabClick',
|
138
|
+
value: function _handleTabClick(e) {
|
139
|
+
var _this = this;
|
140
|
+
|
141
|
+
var tab = $(e.target).closest('li.tab');
|
142
|
+
var tabLink = $(e.target).closest('a');
|
143
|
+
|
144
|
+
// Handle click on tab link only
|
145
|
+
if (!tabLink.length || !tabLink.parent().hasClass('tab')) {
|
146
|
+
return;
|
147
|
+
}
|
148
|
+
|
149
|
+
if (tab.hasClass('disabled')) {
|
150
|
+
e.preventDefault();
|
151
|
+
return;
|
152
|
+
}
|
153
|
+
|
154
|
+
// Act as regular link if target attribute is specified.
|
155
|
+
if (!!tabLink.attr("target")) {
|
156
|
+
return;
|
157
|
+
}
|
158
|
+
|
159
|
+
this._setTabsAndTabWidth();
|
160
|
+
|
161
|
+
// Make the old tab inactive.
|
162
|
+
this.$activeTabLink.removeClass('active');
|
163
|
+
var $oldContent = this.$content;
|
164
|
+
|
165
|
+
// Update the variables with the new link and content
|
166
|
+
this.$activeTabLink = tabLink;
|
167
|
+
this.$content = $(M.escapeHash(tabLink[0].hash));
|
168
|
+
this.$tabLinks = this.$el.children('li.tab').children('a');
|
169
|
+
|
170
|
+
// Make the tab active.
|
171
|
+
this.$activeTabLink.addClass('active');
|
172
|
+
var prevIndex = this.index;
|
173
|
+
this.index = Math.max(this.$tabLinks.index(tabLink), 0);
|
174
|
+
|
175
|
+
// Swap content
|
176
|
+
if (this.options.swipeable) {
|
177
|
+
if (this._tabsCarousel) {
|
178
|
+
this._tabsCarousel.set(this.index, function () {
|
179
|
+
if (typeof _this.options.onShow === "function") {
|
180
|
+
_this.options.onShow.call(_this, _this.$content[0]);
|
181
|
+
}
|
182
|
+
});
|
183
|
+
}
|
184
|
+
} else {
|
185
|
+
if (this.$content !== undefined) {
|
186
|
+
this.$content[0].style.display = 'block';
|
187
|
+
this.$content.addClass('active');
|
188
|
+
if (typeof this.options.onShow === 'function') {
|
189
|
+
this.options.onShow.call(this, this.$content[0]);
|
190
|
+
}
|
191
|
+
|
192
|
+
if ($oldContent !== undefined && !$oldContent.is(this.$content)) {
|
193
|
+
$oldContent[0].style.display = 'none';
|
194
|
+
$oldContent.removeClass('active');
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
// Update indicator
|
200
|
+
this._animateIndicator(prevIndex);
|
201
|
+
|
202
|
+
// Prevent the anchor's default click action
|
203
|
+
e.preventDefault();
|
204
|
+
}
|
205
|
+
|
206
|
+
/**
|
207
|
+
* Generate elements for tab indicator.
|
208
|
+
*/
|
209
|
+
|
210
|
+
}, {
|
211
|
+
key: '_createIndicator',
|
212
|
+
value: function _createIndicator() {
|
213
|
+
var _this2 = this;
|
214
|
+
|
215
|
+
var indicator = document.createElement('li');
|
216
|
+
indicator.classList.add('indicator');
|
217
|
+
|
218
|
+
this.el.appendChild(indicator);
|
219
|
+
this._indicator = indicator;
|
220
|
+
|
221
|
+
setTimeout(function () {
|
222
|
+
_this2._indicator.style.left = _this2._calcLeftPos(_this2.$activeTabLink) + 'px';
|
223
|
+
_this2._indicator.style.right = _this2._calcRightPos(_this2.$activeTabLink) + 'px';
|
224
|
+
}, 0);
|
225
|
+
}
|
226
|
+
|
227
|
+
/**
|
228
|
+
* Setup first active tab link.
|
229
|
+
*/
|
230
|
+
|
231
|
+
}, {
|
232
|
+
key: '_setupActiveTabLink',
|
233
|
+
value: function _setupActiveTabLink() {
|
234
|
+
// If the location.hash matches one of the links, use that as the active tab.
|
235
|
+
this.$activeTabLink = $(this.$tabLinks.filter('[href="' + location.hash + '"]'));
|
236
|
+
|
237
|
+
// If no match is found, use the first link or any with class 'active' as the initial active tab.
|
238
|
+
if (this.$activeTabLink.length === 0) {
|
239
|
+
this.$activeTabLink = this.$el.children('li.tab').children('a.active').first();
|
240
|
+
}
|
241
|
+
if (this.$activeTabLink.length === 0) {
|
242
|
+
this.$activeTabLink = this.$el.children('li.tab').children('a').first();
|
243
|
+
}
|
244
|
+
|
245
|
+
this.$tabLinks.removeClass('active');
|
246
|
+
this.$activeTabLink[0].classList.add('active');
|
247
|
+
|
248
|
+
this.index = Math.max(this.$tabLinks.index(this.$activeTabLink), 0);
|
249
|
+
|
250
|
+
if (this.$activeTabLink.length) {
|
251
|
+
this.$content = $(M.escapeHash(this.$activeTabLink[0].hash));
|
252
|
+
this.$content.addClass('active');
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
/**
|
257
|
+
* Setup swipeable tabs
|
258
|
+
*/
|
259
|
+
|
260
|
+
}, {
|
261
|
+
key: '_setupSwipeableTabs',
|
262
|
+
value: function _setupSwipeableTabs() {
|
263
|
+
var _this3 = this;
|
264
|
+
|
265
|
+
// Change swipeable according to responsive threshold
|
266
|
+
if (window.innerWidth > options.responsiveThreshold) {
|
267
|
+
this.options.swipeable = false;
|
268
|
+
}
|
269
|
+
|
270
|
+
var $tabsContent = $();
|
271
|
+
this.$tabLinks.each(function (link) {
|
272
|
+
var $currContent = $(M.escapeHash(link.hash));
|
273
|
+
$currContent.addClass('carousel-item');
|
274
|
+
$tabsContent = $tabsContent.add($currContent);
|
275
|
+
});
|
276
|
+
|
277
|
+
var $tabsWrapper = $('<div class="tabs-content carousel carousel-slider"></div>');
|
278
|
+
$tabsContent.first().before($tabsWrapper);
|
279
|
+
$tabsWrapper.append($tabsContent);
|
280
|
+
$tabsContent[0].style.display = '';
|
281
|
+
|
282
|
+
this._tabsCarousel = new M.Carousel($tabsWrapper[0], {
|
283
|
+
fullWidth: true,
|
284
|
+
noWrap: true,
|
285
|
+
onCycleTo: function (item) {
|
286
|
+
var prevIndex = _this3.index;
|
287
|
+
_this3.index = $(item).index();
|
288
|
+
_this3.$activeTabLink.removeClass('active');
|
289
|
+
_this3.$activeTabLink = _this3.$tabLinks.eq(_this3.index);
|
290
|
+
_this3.$activeTabLink.addClass('active');
|
291
|
+
_this3._animateIndicator(prevIndex);
|
292
|
+
if (typeof _this3.options.onShow === "function") {
|
293
|
+
_this3.options.onShow.call(_this3, _this3.$content);
|
294
|
+
}
|
295
|
+
}
|
296
|
+
});
|
297
|
+
}
|
298
|
+
|
299
|
+
/**
|
300
|
+
* Teardown normal tabs.
|
301
|
+
*/
|
302
|
+
|
303
|
+
}, {
|
304
|
+
key: '_teardownSwipeableTabs',
|
305
|
+
value: function _teardownSwipeableTabs() {
|
306
|
+
var $tabsWrapper = this._tabsCarousel.$el;
|
307
|
+
this._tabsCarousel.destroy();
|
308
|
+
|
309
|
+
// Unwrap
|
310
|
+
$tabsWrapper.after($tabsWrapper.children());
|
311
|
+
$tabsWrapper.remove();
|
312
|
+
}
|
313
|
+
|
314
|
+
/**
|
315
|
+
* Setup normal tabs.
|
316
|
+
*/
|
317
|
+
|
318
|
+
}, {
|
319
|
+
key: '_setupNormalTabs',
|
320
|
+
value: function _setupNormalTabs() {
|
321
|
+
// Hide Tabs Content
|
322
|
+
this.$tabLinks.not(this.$activeTabLink).each(function (link) {
|
323
|
+
if (!!link.hash) {
|
324
|
+
var $currContent = $(M.escapeHash(link.hash));
|
325
|
+
if ($currContent.length) {
|
326
|
+
$currContent[0].style.display = 'none';
|
327
|
+
}
|
328
|
+
}
|
329
|
+
});
|
330
|
+
}
|
331
|
+
|
332
|
+
/**
|
333
|
+
* Teardown normal tabs.
|
334
|
+
*/
|
335
|
+
|
336
|
+
}, {
|
337
|
+
key: '_teardownNormalTabs',
|
338
|
+
value: function _teardownNormalTabs() {
|
339
|
+
// show Tabs Content
|
340
|
+
this.$tabLinks.each(function (link) {
|
341
|
+
if (!!link.hash) {
|
342
|
+
var $currContent = $(M.escapeHash(link.hash));
|
343
|
+
if ($currContent.length) {
|
344
|
+
$currContent[0].style.display = '';
|
345
|
+
}
|
346
|
+
}
|
347
|
+
});
|
348
|
+
}
|
349
|
+
|
350
|
+
/**
|
351
|
+
* set tabs and tab width
|
352
|
+
*/
|
353
|
+
|
354
|
+
}, {
|
355
|
+
key: '_setTabsAndTabWidth',
|
356
|
+
value: function _setTabsAndTabWidth() {
|
357
|
+
this.tabsWidth = this.$el.width();
|
358
|
+
this.tabWidth = Math.max(this.tabsWidth, this.el.scrollWidth) / this.$tabLinks.length;
|
359
|
+
}
|
360
|
+
|
361
|
+
/**
|
362
|
+
* Finds right attribute for indicator based on active tab.
|
363
|
+
* @param {jQuery} el
|
364
|
+
*/
|
365
|
+
|
366
|
+
}, {
|
367
|
+
key: '_calcRightPos',
|
368
|
+
value: function _calcRightPos(el) {
|
369
|
+
return Math.ceil(this.tabsWidth - el.position().left - el[0].getBoundingClientRect().width);
|
370
|
+
}
|
371
|
+
|
372
|
+
/**
|
373
|
+
* Finds left attribute for indicator based on active tab.
|
374
|
+
* @param {jQuery} el
|
375
|
+
*/
|
376
|
+
|
377
|
+
}, {
|
378
|
+
key: '_calcLeftPos',
|
379
|
+
value: function _calcLeftPos(el) {
|
380
|
+
return Math.floor(el.position().left);
|
381
|
+
}
|
382
|
+
|
383
|
+
/**
|
384
|
+
* Animates Indicator to active tab.
|
385
|
+
* @param {Number} prevIndex
|
386
|
+
*/
|
387
|
+
|
388
|
+
}, {
|
389
|
+
key: '_animateIndicator',
|
390
|
+
value: function _animateIndicator(prevIndex) {
|
391
|
+
var velOptions = {
|
392
|
+
duration: this.options.duration,
|
393
|
+
queue: false,
|
394
|
+
easing: 'easeOutQuad'
|
395
|
+
};
|
396
|
+
var velOptionsLeft = void 0,
|
397
|
+
velOptionsRight = void 0;
|
398
|
+
|
399
|
+
if (this.index - prevIndex >= 0) {
|
400
|
+
velOptionsLeft = $.extend({}, velOptions, { delay: 90 });
|
401
|
+
velOptionsRight = velOptions;
|
402
|
+
} else {
|
403
|
+
velOptionsLeft = velOptions;
|
404
|
+
velOptionsRight = $.extend({}, velOptions, { delay: 90 });
|
405
|
+
}
|
406
|
+
|
407
|
+
// Animate with velocity
|
408
|
+
Vel(this._indicator, { left: this._calcLeftPos(this.$activeTabLink) }, velOptionsLeft);
|
409
|
+
Vel(this._indicator, { right: this._calcRightPos(this.$activeTabLink) }, velOptionsRight);
|
410
|
+
}
|
411
|
+
|
412
|
+
/**
|
413
|
+
* Select tab.
|
414
|
+
* @param {String} tabId
|
415
|
+
*/
|
416
|
+
|
417
|
+
}, {
|
418
|
+
key: 'select',
|
419
|
+
value: function select(tabId) {
|
420
|
+
var tab = this.$tabLinks.filter('[href="#' + tabId + '"]');
|
421
|
+
if (tab.length) {
|
422
|
+
tab.trigger('click');
|
423
|
+
}
|
424
|
+
}
|
425
|
+
}], [{
|
426
|
+
key: 'init',
|
427
|
+
value: function init($els, options) {
|
428
|
+
var arr = [];
|
429
|
+
$els.each(function () {
|
430
|
+
arr.push(new Tabs(this, options));
|
431
|
+
});
|
432
|
+
return arr;
|
433
|
+
}
|
434
|
+
|
435
|
+
/**
|
436
|
+
* Get Instance
|
437
|
+
*/
|
438
|
+
|
439
|
+
}, {
|
440
|
+
key: 'getInstance',
|
441
|
+
value: function getInstance(el) {
|
442
|
+
var domElem = !!el.jquery ? el[0] : el;
|
443
|
+
return domElem.M_Tabs;
|
444
|
+
}
|
445
|
+
}, {
|
446
|
+
key: 'defaults',
|
447
|
+
get: function () {
|
448
|
+
return _defaults;
|
449
|
+
}
|
450
|
+
}]);
|
451
|
+
|
452
|
+
return Tabs;
|
453
|
+
}();
|
454
|
+
|
455
|
+
window.M.Tabs = Tabs;
|
456
|
+
|
457
|
+
if (M.jQueryLoaded) {
|
458
|
+
M.initializeJqueryWrapper(Tabs, 'tabs', 'M_Tabs');
|
459
|
+
}
|
460
|
+
})(cash, M.Vel);
|