materialize-sass 1.0.0.alpha2 → 1.0.0.alpha3
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -706,11 +706,11 @@
|
|
706
706
|
val: function (value) {
|
707
707
|
if (value === undefined) {
|
708
708
|
return getValue(this[0]);
|
709
|
-
} else {
|
710
|
-
return this.each(function (v) {
|
711
|
-
return v.value = value;
|
712
|
-
});
|
713
709
|
}
|
710
|
+
|
711
|
+
return this.each(function (v) {
|
712
|
+
return v.value = value;
|
713
|
+
});
|
714
714
|
}
|
715
715
|
|
716
716
|
});
|
@@ -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
|
|
@@ -12,7 +18,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
12
18
|
*
|
13
19
|
*/
|
14
20
|
|
15
|
-
var CharacterCounter = function () {
|
21
|
+
var CharacterCounter = function (_Component) {
|
22
|
+
_inherits(CharacterCounter, _Component);
|
23
|
+
|
16
24
|
/**
|
17
25
|
* Construct CharacterCounter instance
|
18
26
|
* @constructor
|
@@ -22,24 +30,20 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
22
30
|
function CharacterCounter(el, options) {
|
23
31
|
_classCallCheck(this, CharacterCounter);
|
24
32
|
|
25
|
-
|
26
|
-
if (!!el.M_CharacterCounter) {
|
27
|
-
el.M_CharacterCounter.destroy();
|
28
|
-
}
|
33
|
+
var _this = _possibleConstructorReturn(this, (CharacterCounter.__proto__ || Object.getPrototypeOf(CharacterCounter)).call(this, CharacterCounter, el, options));
|
29
34
|
|
30
|
-
|
31
|
-
this.$el = $(el);
|
32
|
-
this.el.M_CharacterCounter = this;
|
35
|
+
_this.el.M_CharacterCounter = _this;
|
33
36
|
|
34
37
|
/**
|
35
38
|
* Options for the character counter
|
36
39
|
*/
|
37
|
-
|
40
|
+
_this.options = $.extend({}, CharacterCounter.defaults, options);
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
_this.isInvalid = false;
|
43
|
+
_this.isValidLength = false;
|
44
|
+
_this._setupCounter();
|
45
|
+
_this._setupEventHandlers();
|
46
|
+
return _this;
|
43
47
|
}
|
44
48
|
|
45
49
|
_createClass(CharacterCounter, [{
|
@@ -144,12 +148,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
144
148
|
}
|
145
149
|
}], [{
|
146
150
|
key: 'init',
|
147
|
-
value: function init(
|
148
|
-
|
149
|
-
$els.each(function () {
|
150
|
-
arr.push(new CharacterCounter(this, options));
|
151
|
-
});
|
152
|
-
return arr;
|
151
|
+
value: function init(els, options) {
|
152
|
+
return _get(CharacterCounter.__proto__ || Object.getPrototypeOf(CharacterCounter), 'init', this).call(this, this, els, options);
|
153
153
|
}
|
154
154
|
|
155
155
|
/**
|
@@ -170,7 +170,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
170
170
|
}]);
|
171
171
|
|
172
172
|
return CharacterCounter;
|
173
|
-
}();
|
173
|
+
}(Component);
|
174
174
|
|
175
175
|
M.CharacterCounter = CharacterCounter;
|
176
176
|
|
@@ -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
|
|
@@ -27,7 +33,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
27
33
|
*
|
28
34
|
*/
|
29
35
|
|
30
|
-
var Chips = function () {
|
36
|
+
var Chips = function (_Component) {
|
37
|
+
_inherits(Chips, _Component);
|
38
|
+
|
31
39
|
/**
|
32
40
|
* Construct Chips instance and set up overlay
|
33
41
|
* @constructor
|
@@ -37,14 +45,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
37
45
|
function Chips(el, options) {
|
38
46
|
_classCallCheck(this, Chips);
|
39
47
|
|
40
|
-
|
41
|
-
if (!!el.M_Chips) {
|
42
|
-
el.M_Chips.destroy();
|
43
|
-
}
|
48
|
+
var _this = _possibleConstructorReturn(this, (Chips.__proto__ || Object.getPrototypeOf(Chips)).call(this, Chips, el, options));
|
44
49
|
|
45
|
-
|
46
|
-
this.$el = $(el);
|
47
|
-
this.el.M_Chips = this;
|
50
|
+
_this.el.M_Chips = _this;
|
48
51
|
|
49
52
|
/**
|
50
53
|
* Options for the modal
|
@@ -54,33 +57,34 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
54
57
|
* @prop {String} secondaryPlaceholder
|
55
58
|
* @prop {Object} autocompleteOptions
|
56
59
|
*/
|
57
|
-
|
60
|
+
_this.options = $.extend({}, Chips.defaults, options);
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
_this.$el.addClass('chips input-field');
|
63
|
+
_this.chipsData = [];
|
64
|
+
_this.$chips = $();
|
65
|
+
_this._setupInput();
|
66
|
+
_this.hasAutocomplete = Object.keys(_this.options.autocompleteOptions).length > 0;
|
64
67
|
|
65
68
|
// Set input id
|
66
|
-
if (!
|
67
|
-
|
69
|
+
if (!_this.$input.attr('id')) {
|
70
|
+
_this.$input.attr('id', M.guid());
|
68
71
|
}
|
69
72
|
|
70
73
|
// Render initial chips
|
71
|
-
if (
|
72
|
-
|
73
|
-
|
74
|
+
if (_this.options.data.length) {
|
75
|
+
_this.chipsData = _this.options.data;
|
76
|
+
_this._renderChips(_this.chipsData);
|
74
77
|
}
|
75
78
|
|
76
79
|
// Setup autocomplete if needed
|
77
|
-
if (
|
78
|
-
|
80
|
+
if (_this.hasAutocomplete) {
|
81
|
+
_this._setupAutocomplete();
|
79
82
|
}
|
80
83
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
_this._setPlaceholder();
|
85
|
+
_this._setupLabel();
|
86
|
+
_this._setupEventHandlers();
|
87
|
+
return _this;
|
84
88
|
}
|
85
89
|
|
86
90
|
_createClass(Chips, [{
|
@@ -214,7 +218,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
214
218
|
}
|
215
219
|
|
216
220
|
e.preventDefault();
|
217
|
-
this.addChip({
|
221
|
+
this.addChip({
|
222
|
+
tag: this.$input[0].value
|
223
|
+
});
|
218
224
|
this.$input[0].value = '';
|
219
225
|
|
220
226
|
// delete or left
|
@@ -281,12 +287,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
281
287
|
}, {
|
282
288
|
key: '_setupAutocomplete',
|
283
289
|
value: function _setupAutocomplete() {
|
284
|
-
var
|
290
|
+
var _this2 = this;
|
285
291
|
|
286
292
|
this.options.autocompleteOptions.onAutocomplete = function (val) {
|
287
|
-
|
288
|
-
|
289
|
-
|
293
|
+
_this2.addChip({
|
294
|
+
tag: val
|
295
|
+
});
|
296
|
+
_this2.$input[0].value = '';
|
297
|
+
_this2.$input[0].focus();
|
290
298
|
};
|
291
299
|
|
292
300
|
this.autocomplete = M.Autocomplete.init(this.$input, this.options.autocompleteOptions)[0];
|
@@ -352,9 +360,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
352
360
|
}
|
353
361
|
}
|
354
362
|
return !exists;
|
355
|
-
} else {
|
356
|
-
return false;
|
357
363
|
}
|
364
|
+
|
365
|
+
return false;
|
358
366
|
}
|
359
367
|
|
360
368
|
/**
|
@@ -422,12 +430,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
422
430
|
}
|
423
431
|
}], [{
|
424
432
|
key: 'init',
|
425
|
-
value: function init(
|
426
|
-
|
427
|
-
$els.each(function () {
|
428
|
-
arr.push(new Chips(this, options));
|
429
|
-
});
|
430
|
-
return arr;
|
433
|
+
value: function init(els, options) {
|
434
|
+
return _get(Chips.__proto__ || Object.getPrototypeOf(Chips), 'init', this).call(this, this, els, options);
|
431
435
|
}
|
432
436
|
|
433
437
|
/**
|
@@ -529,7 +533,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
529
533
|
}]);
|
530
534
|
|
531
535
|
return Chips;
|
532
|
-
}();
|
536
|
+
}(Component);
|
533
537
|
|
534
538
|
/**
|
535
539
|
* @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
|
|
@@ -20,7 +26,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
20
26
|
*
|
21
27
|
*/
|
22
28
|
|
23
|
-
var Collapsible = function () {
|
29
|
+
var Collapsible = function (_Component) {
|
30
|
+
_inherits(Collapsible, _Component);
|
31
|
+
|
24
32
|
/**
|
25
33
|
* Construct Collapsible instance
|
26
34
|
* @constructor
|
@@ -30,14 +38,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
30
38
|
function Collapsible(el, options) {
|
31
39
|
_classCallCheck(this, Collapsible);
|
32
40
|
|
33
|
-
|
34
|
-
if (!!el.M_Collapsible) {
|
35
|
-
el.M_Collapsible.destroy();
|
36
|
-
}
|
41
|
+
var _this = _possibleConstructorReturn(this, (Collapsible.__proto__ || Object.getPrototypeOf(Collapsible)).call(this, Collapsible, el, options));
|
37
42
|
|
38
|
-
|
39
|
-
this.$el = $(el);
|
40
|
-
this.el.M_Collapsible = this;
|
43
|
+
_this.el.M_Collapsible = _this;
|
41
44
|
|
42
45
|
/**
|
43
46
|
* Options for the collapsible
|
@@ -50,19 +53,20 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
50
53
|
* @prop {Number} inDuration - Transition in duration in milliseconds.
|
51
54
|
* @prop {Number} outDuration - Transition duration in milliseconds.
|
52
55
|
*/
|
53
|
-
|
56
|
+
_this.options = $.extend({}, Collapsible.defaults, options);
|
54
57
|
|
55
|
-
|
58
|
+
_this._setupEventHandlers();
|
56
59
|
|
57
60
|
// Open first active
|
58
|
-
var $activeBodies =
|
59
|
-
if (
|
61
|
+
var $activeBodies = _this.$el.children('li.active').children('.collapsible-body');
|
62
|
+
if (_this.options.accordion) {
|
60
63
|
// Handle Accordion
|
61
64
|
$activeBodies.first().css('display', 'block');
|
62
65
|
} else {
|
63
66
|
// Handle Expandables
|
64
67
|
$activeBodies.css('display', 'block');
|
65
68
|
}
|
69
|
+
return _this;
|
66
70
|
}
|
67
71
|
|
68
72
|
_createClass(Collapsible, [{
|
@@ -132,7 +136,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
132
136
|
}, {
|
133
137
|
key: '_animateIn',
|
134
138
|
value: function _animateIn(index) {
|
135
|
-
var
|
139
|
+
var _this2 = this;
|
136
140
|
|
137
141
|
var $collapsibleLi = this.$el.children('li').eq(index);
|
138
142
|
if ($collapsibleLi.length) {
|
@@ -171,8 +175,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
171
175
|
});
|
172
176
|
|
173
177
|
// onOpenEnd callback
|
174
|
-
if (typeof
|
175
|
-
|
178
|
+
if (typeof _this2.options.onOpenEnd === 'function') {
|
179
|
+
_this2.options.onOpenEnd.call(_this2, $collapsibleLi[0]);
|
176
180
|
}
|
177
181
|
}
|
178
182
|
});
|
@@ -187,7 +191,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
187
191
|
}, {
|
188
192
|
key: '_animateOut',
|
189
193
|
value: function _animateOut(index) {
|
190
|
-
var
|
194
|
+
var _this3 = this;
|
191
195
|
|
192
196
|
var $collapsibleLi = this.$el.children('li').eq(index);
|
193
197
|
if ($collapsibleLi.length) {
|
@@ -210,8 +214,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
210
214
|
});
|
211
215
|
|
212
216
|
// onCloseEnd callback
|
213
|
-
if (typeof
|
214
|
-
|
217
|
+
if (typeof _this3.options.onCloseEnd === 'function') {
|
218
|
+
_this3.options.onCloseEnd.call(_this3, $collapsibleLi[0]);
|
215
219
|
}
|
216
220
|
}
|
217
221
|
});
|
@@ -226,7 +230,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
226
230
|
}, {
|
227
231
|
key: 'open',
|
228
232
|
value: function open(index) {
|
229
|
-
var
|
233
|
+
var _this4 = this;
|
230
234
|
|
231
235
|
var $collapsibleLi = this.$el.children('li').eq(index);
|
232
236
|
if ($collapsibleLi.length && !$collapsibleLi[0].classList.contains('active')) {
|
@@ -242,7 +246,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
242
246
|
var $activeLis = this.$el.children('li.active');
|
243
247
|
$activeLis.each(function (el) {
|
244
248
|
var index = $collapsibleLis.index($(el));
|
245
|
-
|
249
|
+
_this4.close(index);
|
246
250
|
});
|
247
251
|
}
|
248
252
|
|
@@ -275,12 +279,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
275
279
|
}
|
276
280
|
}], [{
|
277
281
|
key: 'init',
|
278
|
-
value: function init(
|
279
|
-
|
280
|
-
$els.each(function () {
|
281
|
-
arr.push(new Collapsible(this, options));
|
282
|
-
});
|
283
|
-
return arr;
|
282
|
+
value: function init(els, options) {
|
283
|
+
return _get(Collapsible.__proto__ || Object.getPrototypeOf(Collapsible), 'init', this).call(this, this, els, options);
|
284
284
|
}
|
285
285
|
|
286
286
|
/**
|
@@ -301,7 +301,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
301
301
|
}]);
|
302
302
|
|
303
303
|
return Collapsible;
|
304
|
-
}();
|
304
|
+
}(Component);
|
305
305
|
|
306
306
|
M.Collapsible = Collapsible;
|
307
307
|
|
@@ -0,0 +1,57 @@
|
|
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
|
+
var Component = function () {
|
6
|
+
/**
|
7
|
+
* Generic constructor for all components
|
8
|
+
* @constructor
|
9
|
+
* @param {Element} el
|
10
|
+
* @param {Object} options
|
11
|
+
*/
|
12
|
+
function Component(classDef, el, options) {
|
13
|
+
_classCallCheck(this, Component);
|
14
|
+
|
15
|
+
// Display error if el is valid HTML Element
|
16
|
+
if (!(el instanceof Element)) {
|
17
|
+
console.error(Error(el + ' is not an HTML Element'));
|
18
|
+
}
|
19
|
+
|
20
|
+
// If exists, destroy and reinitialize in child
|
21
|
+
var ins = classDef.getInstance(el);
|
22
|
+
if (!!ins) {
|
23
|
+
ins.destroy();
|
24
|
+
}
|
25
|
+
|
26
|
+
this.el = el;
|
27
|
+
this.$el = cash(el);
|
28
|
+
}
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Initializes components
|
32
|
+
* @param {class} classDef
|
33
|
+
* @param {Element | NodeList | jQuery} els
|
34
|
+
* @param {Object} options
|
35
|
+
*/
|
36
|
+
|
37
|
+
|
38
|
+
_createClass(Component, null, [{
|
39
|
+
key: 'init',
|
40
|
+
value: function init(classDef, els, options) {
|
41
|
+
var instances = null;
|
42
|
+
if (els instanceof Element) {
|
43
|
+
instances = new classDef(els, options);
|
44
|
+
} else if (!!els.jquery || els instanceof NodeList) {
|
45
|
+
var instancesArr = [];
|
46
|
+
for (var i = 0; i < els.length; i++) {
|
47
|
+
instancesArr.push(new classDef(els[i], options));
|
48
|
+
}
|
49
|
+
instances = instancesArr;
|
50
|
+
}
|
51
|
+
|
52
|
+
return instances;
|
53
|
+
}
|
54
|
+
}]);
|
55
|
+
|
56
|
+
return Component;
|
57
|
+
}();
|