materialize-sass 1.0.0.alpha2 → 1.0.0.alpha3
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.
- checksums.yaml +5 -5
- data/assets/javascripts/materialize-sprockets.js +1 -0
- data/assets/javascripts/materialize.js +1337 -1281
- data/assets/javascripts/materialize/autocomplete.js +27 -27
- data/assets/javascripts/materialize/buttons.js +58 -58
- data/assets/javascripts/materialize/carousel.js +47 -49
- data/assets/javascripts/materialize/cash.js +4 -4
- data/assets/javascripts/materialize/characterCounter.js +20 -20
- data/assets/javascripts/materialize/chips.js +42 -38
- data/assets/javascripts/materialize/collapsible.js +27 -27
- data/assets/javascripts/materialize/component.js +57 -0
- data/assets/javascripts/materialize/datepicker.js +59 -53
- data/assets/javascripts/materialize/dropdown.js +43 -43
- data/assets/javascripts/materialize/extras/nouislider.js +1 -1
- data/assets/javascripts/materialize/extras/nouislider.min.js +1 -1
- data/assets/javascripts/materialize/forms.js +8 -2
- data/assets/javascripts/materialize/global.js +11 -13
- data/assets/javascripts/materialize/materialbox.js +72 -44
- data/assets/javascripts/materialize/modal.js +55 -38
- data/assets/javascripts/materialize/parallax.js +61 -24
- data/assets/javascripts/materialize/pushpin.js +37 -21
- data/assets/javascripts/materialize/range.js +19 -21
- data/assets/javascripts/materialize/scrollspy.js +23 -23
- data/assets/javascripts/materialize/select.js +42 -36
- data/assets/javascripts/materialize/sidenav.js +34 -34
- data/assets/javascripts/materialize/slider.js +37 -39
- data/assets/javascripts/materialize/tabs.js +42 -49
- data/assets/javascripts/materialize/tapTarget.js +39 -22
- data/assets/javascripts/materialize/timepicker.js +579 -579
- data/assets/javascripts/materialize/tooltip.js +34 -31
- data/assets/stylesheets/materialize/components/_cards.scss +0 -2
- data/assets/stylesheets/materialize/components/_global.scss +4 -14
- data/assets/stylesheets/materialize/components/_typography.scss +0 -1
- data/assets/stylesheets/materialize/components/_variables.scss +1 -1
- data/assets/stylesheets/materialize/components/forms/_checkboxes.scss +0 -10
- data/assets/stylesheets/materialize/extras/nouislider.css +1 -1
- data/lib/materialize-sass/version.rb +1 -1
- metadata +4 -3
@@ -1,7 +1,13 @@
|
|
1
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
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
|
+
|
3
5
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4
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
|
+
|
5
11
|
(function ($) {
|
6
12
|
'use strict';
|
7
13
|
|
@@ -14,7 +20,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
14
20
|
*
|
15
21
|
*/
|
16
22
|
|
17
|
-
var Select = function () {
|
23
|
+
var Select = function (_Component) {
|
24
|
+
_inherits(Select, _Component);
|
25
|
+
|
18
26
|
/**
|
19
27
|
* Construct Select instance
|
20
28
|
* @constructor
|
@@ -24,29 +32,25 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
24
32
|
function Select(el, options) {
|
25
33
|
_classCallCheck(this, Select);
|
26
34
|
|
27
|
-
|
28
|
-
if (!!el.M_Select) {
|
29
|
-
el.M_Select.destroy();
|
30
|
-
}
|
35
|
+
var _this = _possibleConstructorReturn(this, (Select.__proto__ || Object.getPrototypeOf(Select)).call(this, Select, el, options));
|
31
36
|
|
32
|
-
|
33
|
-
this.$el = $(el);
|
34
|
-
this.el.M_Select = this;
|
37
|
+
_this.el.M_Select = _this;
|
35
38
|
|
36
39
|
/**
|
37
40
|
* Options for the select
|
38
41
|
* @member Select#options
|
39
42
|
*/
|
40
|
-
|
43
|
+
_this.options = $.extend({}, Select.defaults, options);
|
41
44
|
|
42
|
-
|
45
|
+
_this.isMultiple = _this.$el.prop('multiple');
|
43
46
|
|
44
47
|
// Setup
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
+
_this._keysSelected = {};
|
49
|
+
_this._valueDict = {}; // Maps key to original and generated option element.
|
50
|
+
_this._setupDropdown();
|
48
51
|
|
49
|
-
|
52
|
+
_this._setupEventHandlers();
|
53
|
+
return _this;
|
50
54
|
}
|
51
55
|
|
52
56
|
_createClass(Select, [{
|
@@ -69,14 +73,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
69
73
|
}, {
|
70
74
|
key: '_setupEventHandlers',
|
71
75
|
value: function _setupEventHandlers() {
|
72
|
-
var
|
76
|
+
var _this2 = this;
|
73
77
|
|
74
78
|
this._handleSelectChangeBound = this._handleSelectChange.bind(this);
|
75
79
|
this._handleOptionClickBound = this._handleOptionClick.bind(this);
|
76
80
|
this._handleInputClickBound = this._handleInputClick.bind(this);
|
77
81
|
|
78
82
|
$(this.dropdownOptions).find('li:not(.optgroup)').each(function (el) {
|
79
|
-
el.addEventListener('click',
|
83
|
+
el.addEventListener('click', _this2._handleOptionClickBound);
|
80
84
|
});
|
81
85
|
this.el.addEventListener('change', this._handleSelectChangeBound);
|
82
86
|
this.input.addEventListener('click', this._handleInputClickBound);
|
@@ -89,10 +93,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
89
93
|
}, {
|
90
94
|
key: '_removeEventHandlers',
|
91
95
|
value: function _removeEventHandlers() {
|
92
|
-
var
|
96
|
+
var _this3 = this;
|
93
97
|
|
94
98
|
$(this.dropdownOptions).find('li:not(.optgroup)').each(function (el) {
|
95
|
-
el.removeEventListener('click',
|
99
|
+
el.removeEventListener('click', _this3._handleOptionClickBound);
|
96
100
|
});
|
97
101
|
this.el.removeEventListener('change', this._handleSelectChangeBound);
|
98
102
|
this.input.removeEventListener('click', this._handleInputClickBound);
|
@@ -125,6 +129,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
125
129
|
var selected = true;
|
126
130
|
|
127
131
|
if (this.isMultiple) {
|
132
|
+
// Deselect placeholder option if still selected.
|
133
|
+
var placeholderOption = $(this.dropdownOptions).find('li.disabled.selected');
|
134
|
+
if (placeholderOption.length) {
|
135
|
+
placeholderOption.removeClass('selected');
|
136
|
+
placeholderOption.find('input[type="checkbox"]').prop('checked', false);
|
137
|
+
this._toggleEntryFromArray(placeholderOption[0].id);
|
138
|
+
}
|
139
|
+
|
128
140
|
var checkbox = $(option).find('input[type="checkbox"]');
|
129
141
|
checkbox.prop('checked', !checkbox.prop('checked'));
|
130
142
|
selected = this._toggleEntryFromArray(key);
|
@@ -162,7 +174,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
162
174
|
}, {
|
163
175
|
key: '_setupDropdown',
|
164
176
|
value: function _setupDropdown() {
|
165
|
-
var
|
177
|
+
var _this4 = this;
|
166
178
|
|
167
179
|
this.wrapper = document.createElement('div');
|
168
180
|
$(this.wrapper).addClass('select-wrapper' + ' ' + this.options.classes);
|
@@ -185,21 +197,21 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
185
197
|
if ($(el).is('option')) {
|
186
198
|
// Direct descendant option.
|
187
199
|
var optionEl = void 0;
|
188
|
-
if (
|
189
|
-
optionEl =
|
200
|
+
if (_this4.isMultiple) {
|
201
|
+
optionEl = _this4._appendOptionWithIcon(_this4.$el, el, 'multiple');
|
190
202
|
} else {
|
191
|
-
optionEl =
|
203
|
+
optionEl = _this4._appendOptionWithIcon(_this4.$el, el);
|
192
204
|
}
|
193
205
|
|
194
|
-
|
206
|
+
_this4._addOptionToValueDict(el, optionEl);
|
195
207
|
} else if ($(el).is('optgroup')) {
|
196
208
|
// Optgroup.
|
197
209
|
var selectOptions = $(el).children('option');
|
198
|
-
$(
|
210
|
+
$(_this4.dropdownOptions).append($('<li class="optgroup"><span>' + el.getAttribute('label') + '</span></li>')[0]);
|
199
211
|
|
200
212
|
selectOptions.each(function (el) {
|
201
|
-
var optionEl =
|
202
|
-
|
213
|
+
var optionEl = _this4._appendOptionWithIcon(_this4.$el, el, 'optgroup-option');
|
214
|
+
_this4._addOptionToValueDict(el, optionEl);
|
203
215
|
});
|
204
216
|
}
|
205
217
|
});
|
@@ -230,7 +242,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
230
242
|
if (this.isMultiple) {
|
231
243
|
dropdownOptions.closeOnClick = false;
|
232
244
|
}
|
233
|
-
this.dropdown =
|
245
|
+
this.dropdown = M.Dropdown.init(this.input, dropdownOptions);
|
234
246
|
}
|
235
247
|
|
236
248
|
// Add initial selections
|
@@ -412,14 +424,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
412
424
|
}
|
413
425
|
}], [{
|
414
426
|
key: 'init',
|
415
|
-
value: function init(
|
416
|
-
|
417
|
-
$els.each(function () {
|
418
|
-
if (!$(this).hasClass('browser-default')) {
|
419
|
-
arr.push(new Select(this, options));
|
420
|
-
}
|
421
|
-
});
|
422
|
-
return arr;
|
427
|
+
value: function init(els, options) {
|
428
|
+
return _get(Select.__proto__ || Object.getPrototypeOf(Select), 'init', this).call(this, this, els, options);
|
423
429
|
}
|
424
430
|
|
425
431
|
/**
|
@@ -440,7 +446,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
440
446
|
}]);
|
441
447
|
|
442
448
|
return Select;
|
443
|
-
}();
|
449
|
+
}(Component);
|
444
450
|
|
445
451
|
M.Select = Select;
|
446
452
|
|
@@ -1,7 +1,13 @@
|
|
1
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
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
|
+
|
3
5
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4
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
|
+
|
5
11
|
(function ($, anim) {
|
6
12
|
'use strict';
|
7
13
|
|
@@ -20,7 +26,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
20
26
|
* @class
|
21
27
|
*/
|
22
28
|
|
23
|
-
var Sidenav = function () {
|
29
|
+
var Sidenav = function (_Component) {
|
30
|
+
_inherits(Sidenav, _Component);
|
31
|
+
|
24
32
|
/**
|
25
33
|
* Construct Sidenav instance and set up overlay
|
26
34
|
* @constructor
|
@@ -30,15 +38,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
30
38
|
function Sidenav(el, options) {
|
31
39
|
_classCallCheck(this, Sidenav);
|
32
40
|
|
33
|
-
|
34
|
-
if (!!el.M_Sidenav) {
|
35
|
-
el.M_Sidenav.destroy();
|
36
|
-
}
|
41
|
+
var _this = _possibleConstructorReturn(this, (Sidenav.__proto__ || Object.getPrototypeOf(Sidenav)).call(this, Sidenav, el, options));
|
37
42
|
|
38
|
-
|
39
|
-
|
40
|
-
this.el.M_Sidenav = this;
|
41
|
-
this.id = this.$el.attr('id');
|
43
|
+
_this.el.M_Sidenav = _this;
|
44
|
+
_this.id = _this.$el.attr('id');
|
42
45
|
|
43
46
|
/**
|
44
47
|
* Options for the Sidenav
|
@@ -52,33 +55,34 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
52
55
|
* @prop {Function} onCloseStart - Function called when sidenav starts exiting
|
53
56
|
* @prop {Function} onCloseEnd - Function called when sidenav finishes exiting
|
54
57
|
*/
|
55
|
-
|
58
|
+
_this.options = $.extend({}, Sidenav.defaults, options);
|
56
59
|
|
57
60
|
/**
|
58
61
|
* Describes open/close state of Sidenav
|
59
62
|
* @type {Boolean}
|
60
63
|
*/
|
61
|
-
|
64
|
+
_this.isOpen = false;
|
62
65
|
|
63
66
|
/**
|
64
67
|
* Describes if Sidenav is fixed
|
65
68
|
* @type {Boolean}
|
66
69
|
*/
|
67
|
-
|
70
|
+
_this.isFixed = _this.el.classList.contains('sidenav-fixed');
|
68
71
|
|
69
72
|
/**
|
70
73
|
* Describes if Sidenav is being draggeed
|
71
74
|
* @type {Boolean}
|
72
75
|
*/
|
73
|
-
|
76
|
+
_this.isDragged = false;
|
74
77
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
78
|
+
_this._createOverlay();
|
79
|
+
_this._createDragTarget();
|
80
|
+
_this._setupEventHandlers();
|
81
|
+
_this._setupClasses();
|
82
|
+
_this._setupFixed();
|
80
83
|
|
81
|
-
Sidenav._sidenavs.push(
|
84
|
+
Sidenav._sidenavs.push(_this);
|
85
|
+
return _this;
|
82
86
|
}
|
83
87
|
|
84
88
|
_createClass(Sidenav, [{
|
@@ -483,7 +487,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
483
487
|
}, {
|
484
488
|
key: '_animateSidenavIn',
|
485
489
|
value: function _animateSidenavIn() {
|
486
|
-
var
|
490
|
+
var _this2 = this;
|
487
491
|
|
488
492
|
var slideOutPercent = this.options.edge === 'left' ? -1 : 1;
|
489
493
|
if (this.isDragged) {
|
@@ -498,8 +502,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
498
502
|
easing: 'easeOutQuad',
|
499
503
|
complete: function () {
|
500
504
|
// Run onOpenEnd callback
|
501
|
-
if (typeof
|
502
|
-
|
505
|
+
if (typeof _this2.options.onOpenEnd === 'function') {
|
506
|
+
_this2.options.onOpenEnd.call(_this2, _this2.el);
|
503
507
|
}
|
504
508
|
}
|
505
509
|
});
|
@@ -533,7 +537,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
533
537
|
}, {
|
534
538
|
key: '_animateSidenavOut',
|
535
539
|
value: function _animateSidenavOut() {
|
536
|
-
var
|
540
|
+
var _this3 = this;
|
537
541
|
|
538
542
|
var endPercent = this.options.edge === 'left' ? -1 : 1;
|
539
543
|
var slideOutPercent = 0;
|
@@ -549,8 +553,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
549
553
|
easing: 'easeOutQuad',
|
550
554
|
complete: function () {
|
551
555
|
// Run onOpenEnd callback
|
552
|
-
if (typeof
|
553
|
-
|
556
|
+
if (typeof _this3.options.onCloseEnd === 'function') {
|
557
|
+
_this3.options.onCloseEnd.call(_this3, _this3.el);
|
554
558
|
}
|
555
559
|
}
|
556
560
|
});
|
@@ -558,7 +562,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
558
562
|
}, {
|
559
563
|
key: '_animateOverlayOut',
|
560
564
|
value: function _animateOverlayOut() {
|
561
|
-
var
|
565
|
+
var _this4 = this;
|
562
566
|
|
563
567
|
anim.remove(this._overlay);
|
564
568
|
anim({
|
@@ -567,18 +571,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
567
571
|
duration: this.options.outDuration,
|
568
572
|
easing: 'easeOutQuad',
|
569
573
|
complete: function () {
|
570
|
-
$(
|
574
|
+
$(_this4._overlay).css('display', 'none');
|
571
575
|
}
|
572
576
|
});
|
573
577
|
}
|
574
578
|
}], [{
|
575
579
|
key: 'init',
|
576
|
-
value: function init(
|
577
|
-
|
578
|
-
$els.each(function () {
|
579
|
-
arr.push(new Sidenav(this, options));
|
580
|
-
});
|
581
|
-
return arr;
|
580
|
+
value: function init(els, options) {
|
581
|
+
return _get(Sidenav.__proto__ || Object.getPrototypeOf(Sidenav), 'init', this).call(this, this, els, options);
|
582
582
|
}
|
583
583
|
|
584
584
|
/**
|
@@ -599,7 +599,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
599
599
|
}]);
|
600
600
|
|
601
601
|
return Sidenav;
|
602
|
-
}();
|
602
|
+
}(Component);
|
603
603
|
|
604
604
|
/**
|
605
605
|
* @static
|
@@ -1,7 +1,13 @@
|
|
1
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
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
|
+
|
3
5
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4
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
|
+
|
5
11
|
(function ($, anim) {
|
6
12
|
'use strict';
|
7
13
|
|
@@ -17,7 +23,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
17
23
|
*
|
18
24
|
*/
|
19
25
|
|
20
|
-
var Slider = function () {
|
26
|
+
var Slider = function (_Component) {
|
27
|
+
_inherits(Slider, _Component);
|
28
|
+
|
21
29
|
/**
|
22
30
|
* Construct Slider instance and set up overlay
|
23
31
|
* @constructor
|
@@ -25,18 +33,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
25
33
|
* @param {Object} options
|
26
34
|
*/
|
27
35
|
function Slider(el, options) {
|
28
|
-
var _this = this;
|
29
|
-
|
30
36
|
_classCallCheck(this, Slider);
|
31
37
|
|
32
|
-
|
33
|
-
if (!!el.M_Slider) {
|
34
|
-
el.M_Slider.destroy();
|
35
|
-
}
|
38
|
+
var _this = _possibleConstructorReturn(this, (Slider.__proto__ || Object.getPrototypeOf(Slider)).call(this, Slider, el, options));
|
36
39
|
|
37
|
-
|
38
|
-
this.$el = $(el);
|
39
|
-
this.el.M_Slider = this;
|
40
|
+
_this.el.M_Slider = _this;
|
40
41
|
|
41
42
|
/**
|
42
43
|
* Options for the modal
|
@@ -46,25 +47,25 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
46
47
|
* @prop {Number} [duration=500] - Length in ms of slide transition
|
47
48
|
* @prop {Number} [interval=6000] - Length in ms of slide interval
|
48
49
|
*/
|
49
|
-
|
50
|
+
_this.options = $.extend({}, Slider.defaults, options);
|
50
51
|
|
51
52
|
// setup
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
if (
|
56
|
-
|
53
|
+
_this.$slider = _this.$el.find('.slides');
|
54
|
+
_this.$slides = _this.$slider.children('li');
|
55
|
+
_this.activeIndex = _this.$slider.find('.active').index();
|
56
|
+
if (_this.activeIndex != -1) {
|
57
|
+
_this.$active = _this.$slides.eq(_this.activeIndex);
|
57
58
|
}
|
58
59
|
|
59
|
-
|
60
|
+
_this._setSliderHeight();
|
60
61
|
|
61
62
|
// Set initial positions of captions
|
62
|
-
|
63
|
+
_this.$slides.find('.caption').each(function (el) {
|
63
64
|
_this._animateCaptionIn(el, 0);
|
64
65
|
});
|
65
66
|
|
66
67
|
// Move img src into background-image
|
67
|
-
|
68
|
+
_this.$slides.find('img').each(function (el) {
|
68
69
|
var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
|
69
70
|
if ($(el).attr('src') !== placeholderBase64) {
|
70
71
|
$(el).css('background-image', 'url("' + $(el).attr('src') + '")');
|
@@ -72,31 +73,31 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
72
73
|
}
|
73
74
|
});
|
74
75
|
|
75
|
-
|
76
|
+
_this._setupIndicators();
|
76
77
|
|
77
78
|
// Show active slide
|
78
|
-
if (
|
79
|
-
|
79
|
+
if (_this.$active) {
|
80
|
+
_this.$active.css('display', 'block');
|
80
81
|
} else {
|
81
|
-
|
82
|
+
_this.$slides.first().addClass('active');
|
82
83
|
anim({
|
83
|
-
targets:
|
84
|
+
targets: _this.$slides.first()[0],
|
84
85
|
opacity: 1,
|
85
|
-
duration:
|
86
|
+
duration: _this.options.duration,
|
86
87
|
easing: 'easeOutQuad'
|
87
88
|
});
|
88
89
|
|
89
|
-
|
90
|
-
|
90
|
+
_this.activeIndex = 0;
|
91
|
+
_this.$active = _this.$slides.eq(_this.activeIndex);
|
91
92
|
|
92
93
|
// Update indicators
|
93
|
-
if (
|
94
|
-
|
94
|
+
if (_this.options.indicators) {
|
95
|
+
_this.$indicators.eq(_this.activeIndex).addClass('active');
|
95
96
|
}
|
96
97
|
}
|
97
98
|
|
98
99
|
// Adjust height to current slide
|
99
|
-
|
100
|
+
_this.$active.find('img').each(function (el) {
|
100
101
|
anim({
|
101
102
|
targets: _this.$active.find('.caption')[0],
|
102
103
|
opacity: 1,
|
@@ -107,10 +108,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
107
108
|
});
|
108
109
|
});
|
109
110
|
|
110
|
-
|
111
|
+
_this._setupEventHandlers();
|
111
112
|
|
112
113
|
// auto scroll
|
113
|
-
|
114
|
+
_this.start();
|
115
|
+
return _this;
|
114
116
|
}
|
115
117
|
|
116
118
|
_createClass(Slider, [{
|
@@ -387,12 +389,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
387
389
|
}
|
388
390
|
}], [{
|
389
391
|
key: 'init',
|
390
|
-
value: function init(
|
391
|
-
|
392
|
-
$els.each(function () {
|
393
|
-
arr.push(new Slider(this, options));
|
394
|
-
});
|
395
|
-
return arr;
|
392
|
+
value: function init(els, options) {
|
393
|
+
return _get(Slider.__proto__ || Object.getPrototypeOf(Slider), 'init', this).call(this, this, els, options);
|
396
394
|
}
|
397
395
|
|
398
396
|
/**
|
@@ -413,7 +411,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
413
411
|
}]);
|
414
412
|
|
415
413
|
return Slider;
|
416
|
-
}();
|
414
|
+
}(Component);
|
417
415
|
|
418
416
|
M.Slider = Slider;
|
419
417
|
|