kmaterialize 2.0.0
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.
- package/LICENSE +21 -0
- package/README.md +91 -0
- package/dist/css/materialize.css +9067 -0
- package/dist/css/materialize.min.css +13 -0
- package/dist/js/materialize.js +12374 -0
- package/dist/js/materialize.min.js +6 -0
- package/extras/noUiSlider/nouislider.css +406 -0
- package/extras/noUiSlider/nouislider.js +2147 -0
- package/extras/noUiSlider/nouislider.min.js +1 -0
- package/js/anime.min.js +34 -0
- package/js/autocomplete.js +448 -0
- package/js/buttons.js +354 -0
- package/js/cards.js +40 -0
- package/js/carousel.js +717 -0
- package/js/cash.js +960 -0
- package/js/characterCounter.js +136 -0
- package/js/chips.js +481 -0
- package/js/collapsible.js +275 -0
- package/js/component.js +44 -0
- package/js/datepicker.js +975 -0
- package/js/dropdown.js +635 -0
- package/js/forms.js +275 -0
- package/js/global.js +444 -0
- package/js/materialbox.js +453 -0
- package/js/modal.js +382 -0
- package/js/parallax.js +138 -0
- package/js/pushpin.js +148 -0
- package/js/range.js +263 -0
- package/js/scrollspy.js +295 -0
- package/js/select.js +450 -0
- package/js/sidenav.js +580 -0
- package/js/slider.js +359 -0
- package/js/tabs.js +402 -0
- package/js/tapTarget.js +314 -0
- package/js/timepicker.js +647 -0
- package/js/toasts.js +310 -0
- package/js/tooltip.js +303 -0
- package/js/waves.js +335 -0
- package/package.json +62 -0
package/js/buttons.js
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
(function($, anim) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
let _defaults = {
|
|
5
|
+
direction: 'top',
|
|
6
|
+
hoverEnabled: true,
|
|
7
|
+
toolbarEnabled: false
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
$.fn.reverse = [].reverse;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @class
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
class FloatingActionButton extends Component {
|
|
17
|
+
/**
|
|
18
|
+
* Construct FloatingActionButton instance
|
|
19
|
+
* @constructor
|
|
20
|
+
* @param {Element} el
|
|
21
|
+
* @param {Object} options
|
|
22
|
+
*/
|
|
23
|
+
constructor(el, options) {
|
|
24
|
+
super(FloatingActionButton, el, options);
|
|
25
|
+
|
|
26
|
+
this.el.M_FloatingActionButton = this;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Options for the fab
|
|
30
|
+
* @member FloatingActionButton#options
|
|
31
|
+
* @prop {Boolean} [direction] - Direction fab menu opens
|
|
32
|
+
* @prop {Boolean} [hoverEnabled=true] - Enable hover vs click
|
|
33
|
+
* @prop {Boolean} [toolbarEnabled=false] - Enable toolbar transition
|
|
34
|
+
*/
|
|
35
|
+
this.options = $.extend({}, FloatingActionButton.defaults, options);
|
|
36
|
+
|
|
37
|
+
this.isOpen = false;
|
|
38
|
+
this.$anchor = this.$el.children('a').first();
|
|
39
|
+
this.$menu = this.$el.children('ul').first();
|
|
40
|
+
this.$floatingBtns = this.$el.find('ul .btn-floating');
|
|
41
|
+
this.$floatingBtnsReverse = this.$el.find('ul .btn-floating').reverse();
|
|
42
|
+
this.offsetY = 0;
|
|
43
|
+
this.offsetX = 0;
|
|
44
|
+
|
|
45
|
+
this.$el.addClass(`direction-${this.options.direction}`);
|
|
46
|
+
if (this.options.direction === 'top') {
|
|
47
|
+
this.offsetY = 40;
|
|
48
|
+
} else if (this.options.direction === 'right') {
|
|
49
|
+
this.offsetX = -40;
|
|
50
|
+
} else if (this.options.direction === 'bottom') {
|
|
51
|
+
this.offsetY = -40;
|
|
52
|
+
} else {
|
|
53
|
+
this.offsetX = 40;
|
|
54
|
+
}
|
|
55
|
+
this._setupEventHandlers();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static get defaults() {
|
|
59
|
+
return _defaults;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static init(els, options) {
|
|
63
|
+
return super.init(this, els, options);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Get Instance
|
|
68
|
+
*/
|
|
69
|
+
static getInstance(el) {
|
|
70
|
+
let domElem = !!el.jquery ? el[0] : el;
|
|
71
|
+
return domElem.M_FloatingActionButton;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Teardown component
|
|
76
|
+
*/
|
|
77
|
+
destroy() {
|
|
78
|
+
this._removeEventHandlers();
|
|
79
|
+
this.el.M_FloatingActionButton = undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Setup Event Handlers
|
|
84
|
+
*/
|
|
85
|
+
_setupEventHandlers() {
|
|
86
|
+
this._handleFABClickBound = this._handleFABClick.bind(this);
|
|
87
|
+
this._handleOpenBound = this.open.bind(this);
|
|
88
|
+
this._handleCloseBound = this.close.bind(this);
|
|
89
|
+
|
|
90
|
+
if (this.options.hoverEnabled && !this.options.toolbarEnabled) {
|
|
91
|
+
this.el.addEventListener('mouseenter', this._handleOpenBound);
|
|
92
|
+
this.el.addEventListener('mouseleave', this._handleCloseBound);
|
|
93
|
+
} else {
|
|
94
|
+
this.el.addEventListener('click', this._handleFABClickBound);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Remove Event Handlers
|
|
100
|
+
*/
|
|
101
|
+
_removeEventHandlers() {
|
|
102
|
+
if (this.options.hoverEnabled && !this.options.toolbarEnabled) {
|
|
103
|
+
this.el.removeEventListener('mouseenter', this._handleOpenBound);
|
|
104
|
+
this.el.removeEventListener('mouseleave', this._handleCloseBound);
|
|
105
|
+
} else {
|
|
106
|
+
this.el.removeEventListener('click', this._handleFABClickBound);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Handle FAB Click
|
|
112
|
+
*/
|
|
113
|
+
_handleFABClick() {
|
|
114
|
+
if (this.isOpen) {
|
|
115
|
+
this.close();
|
|
116
|
+
} else {
|
|
117
|
+
this.open();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Handle Document Click
|
|
123
|
+
* @param {Event} e
|
|
124
|
+
*/
|
|
125
|
+
_handleDocumentClick(e) {
|
|
126
|
+
if (!$(e.target).closest(this.$menu).length) {
|
|
127
|
+
this.close();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Open FAB
|
|
133
|
+
*/
|
|
134
|
+
open() {
|
|
135
|
+
if (this.isOpen) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (this.options.toolbarEnabled) {
|
|
140
|
+
this._animateInToolbar();
|
|
141
|
+
} else {
|
|
142
|
+
this._animateInFAB();
|
|
143
|
+
}
|
|
144
|
+
this.isOpen = true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Close FAB
|
|
149
|
+
*/
|
|
150
|
+
close() {
|
|
151
|
+
if (!this.isOpen) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (this.options.toolbarEnabled) {
|
|
156
|
+
window.removeEventListener('scroll', this._handleCloseBound, true);
|
|
157
|
+
document.body.removeEventListener('click', this._handleDocumentClickBound, true);
|
|
158
|
+
this._animateOutToolbar();
|
|
159
|
+
} else {
|
|
160
|
+
this._animateOutFAB();
|
|
161
|
+
}
|
|
162
|
+
this.isOpen = false;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Classic FAB Menu open
|
|
167
|
+
*/
|
|
168
|
+
_animateInFAB() {
|
|
169
|
+
this.$el.addClass('active');
|
|
170
|
+
|
|
171
|
+
let time = 0;
|
|
172
|
+
this.$floatingBtnsReverse.each((el) => {
|
|
173
|
+
anim({
|
|
174
|
+
targets: el,
|
|
175
|
+
opacity: 1,
|
|
176
|
+
scale: [0.4, 1],
|
|
177
|
+
translateY: [this.offsetY, 0],
|
|
178
|
+
translateX: [this.offsetX, 0],
|
|
179
|
+
duration: 275,
|
|
180
|
+
delay: time,
|
|
181
|
+
easing: 'easeInOutQuad'
|
|
182
|
+
});
|
|
183
|
+
time += 40;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Classic FAB Menu close
|
|
189
|
+
*/
|
|
190
|
+
_animateOutFAB() {
|
|
191
|
+
this.$floatingBtnsReverse.each((el) => {
|
|
192
|
+
anim.remove(el);
|
|
193
|
+
anim({
|
|
194
|
+
targets: el,
|
|
195
|
+
opacity: 0,
|
|
196
|
+
scale: 0.4,
|
|
197
|
+
translateY: this.offsetY,
|
|
198
|
+
translateX: this.offsetX,
|
|
199
|
+
duration: 175,
|
|
200
|
+
easing: 'easeOutQuad',
|
|
201
|
+
complete: () => {
|
|
202
|
+
this.$el.removeClass('active');
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Toolbar transition Menu open
|
|
210
|
+
*/
|
|
211
|
+
_animateInToolbar() {
|
|
212
|
+
let scaleFactor;
|
|
213
|
+
let windowWidth = window.innerWidth;
|
|
214
|
+
let windowHeight = window.innerHeight;
|
|
215
|
+
let btnRect = this.el.getBoundingClientRect();
|
|
216
|
+
let backdrop = $('<div class="fab-backdrop"></div>');
|
|
217
|
+
let fabColor = this.$anchor.css('background-color');
|
|
218
|
+
this.$anchor.append(backdrop);
|
|
219
|
+
|
|
220
|
+
this.offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2;
|
|
221
|
+
this.offsetY = windowHeight - btnRect.bottom;
|
|
222
|
+
scaleFactor = windowWidth / backdrop[0].clientWidth;
|
|
223
|
+
this.btnBottom = btnRect.bottom;
|
|
224
|
+
this.btnLeft = btnRect.left;
|
|
225
|
+
this.btnWidth = btnRect.width;
|
|
226
|
+
|
|
227
|
+
// Set initial state
|
|
228
|
+
this.$el.addClass('active');
|
|
229
|
+
this.$el.css({
|
|
230
|
+
'text-align': 'center',
|
|
231
|
+
width: '100%',
|
|
232
|
+
bottom: 0,
|
|
233
|
+
left: 0,
|
|
234
|
+
transform: 'translateX(' + this.offsetX + 'px)',
|
|
235
|
+
transition: 'none'
|
|
236
|
+
});
|
|
237
|
+
this.$anchor.css({
|
|
238
|
+
transform: 'translateY(' + -this.offsetY + 'px)',
|
|
239
|
+
transition: 'none'
|
|
240
|
+
});
|
|
241
|
+
backdrop.css({
|
|
242
|
+
'background-color': fabColor
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
setTimeout(() => {
|
|
246
|
+
this.$el.css({
|
|
247
|
+
transform: '',
|
|
248
|
+
transition:
|
|
249
|
+
'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s'
|
|
250
|
+
});
|
|
251
|
+
this.$anchor.css({
|
|
252
|
+
overflow: 'visible',
|
|
253
|
+
transform: '',
|
|
254
|
+
transition: 'transform .2s'
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
setTimeout(() => {
|
|
258
|
+
this.$el.css({
|
|
259
|
+
overflow: 'hidden',
|
|
260
|
+
'background-color': fabColor
|
|
261
|
+
});
|
|
262
|
+
backdrop.css({
|
|
263
|
+
transform: 'scale(' + scaleFactor + ')',
|
|
264
|
+
transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
|
|
265
|
+
});
|
|
266
|
+
this.$menu
|
|
267
|
+
.children('li')
|
|
268
|
+
.children('a')
|
|
269
|
+
.css({
|
|
270
|
+
opacity: 1
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// Scroll to close.
|
|
274
|
+
this._handleDocumentClickBound = this._handleDocumentClick.bind(this);
|
|
275
|
+
window.addEventListener('scroll', this._handleCloseBound, true);
|
|
276
|
+
document.body.addEventListener('click', this._handleDocumentClickBound, true);
|
|
277
|
+
}, 100);
|
|
278
|
+
}, 0);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Toolbar transition Menu close
|
|
283
|
+
*/
|
|
284
|
+
_animateOutToolbar() {
|
|
285
|
+
let windowWidth = window.innerWidth;
|
|
286
|
+
let windowHeight = window.innerHeight;
|
|
287
|
+
let backdrop = this.$el.find('.fab-backdrop');
|
|
288
|
+
let fabColor = this.$anchor.css('background-color');
|
|
289
|
+
|
|
290
|
+
this.offsetX = this.btnLeft - windowWidth / 2 + this.btnWidth / 2;
|
|
291
|
+
this.offsetY = windowHeight - this.btnBottom;
|
|
292
|
+
|
|
293
|
+
// Hide backdrop
|
|
294
|
+
this.$el.removeClass('active');
|
|
295
|
+
this.$el.css({
|
|
296
|
+
'background-color': 'transparent',
|
|
297
|
+
transition: 'none'
|
|
298
|
+
});
|
|
299
|
+
this.$anchor.css({
|
|
300
|
+
transition: 'none'
|
|
301
|
+
});
|
|
302
|
+
backdrop.css({
|
|
303
|
+
transform: 'scale(0)',
|
|
304
|
+
'background-color': fabColor
|
|
305
|
+
});
|
|
306
|
+
this.$menu
|
|
307
|
+
.children('li')
|
|
308
|
+
.children('a')
|
|
309
|
+
.css({
|
|
310
|
+
opacity: ''
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
setTimeout(() => {
|
|
314
|
+
backdrop.remove();
|
|
315
|
+
|
|
316
|
+
// Set initial state.
|
|
317
|
+
this.$el.css({
|
|
318
|
+
'text-align': '',
|
|
319
|
+
width: '',
|
|
320
|
+
bottom: '',
|
|
321
|
+
left: '',
|
|
322
|
+
overflow: '',
|
|
323
|
+
'background-color': '',
|
|
324
|
+
transform: 'translate3d(' + -this.offsetX + 'px,0,0)'
|
|
325
|
+
});
|
|
326
|
+
this.$anchor.css({
|
|
327
|
+
overflow: '',
|
|
328
|
+
transform: 'translate3d(0,' + this.offsetY + 'px,0)'
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
setTimeout(() => {
|
|
332
|
+
this.$el.css({
|
|
333
|
+
transform: 'translate3d(0,0,0)',
|
|
334
|
+
transition: 'transform .2s'
|
|
335
|
+
});
|
|
336
|
+
this.$anchor.css({
|
|
337
|
+
transform: 'translate3d(0,0,0)',
|
|
338
|
+
transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
|
|
339
|
+
});
|
|
340
|
+
}, 20);
|
|
341
|
+
}, 200);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
M.FloatingActionButton = FloatingActionButton;
|
|
346
|
+
|
|
347
|
+
if (M.jQueryLoaded) {
|
|
348
|
+
M.initializeJqueryWrapper(
|
|
349
|
+
FloatingActionButton,
|
|
350
|
+
'floatingActionButton',
|
|
351
|
+
'M_FloatingActionButton'
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
})(cash, M.anime);
|
package/js/cards.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
(function($, anim) {
|
|
2
|
+
$(document).on('click', '.card', function(e) {
|
|
3
|
+
if ($(this).children('.card-reveal').length) {
|
|
4
|
+
var $card = $(e.target).closest('.card');
|
|
5
|
+
if ($card.data('initialOverflow') === undefined) {
|
|
6
|
+
$card.data(
|
|
7
|
+
'initialOverflow',
|
|
8
|
+
$card.css('overflow') === undefined ? '' : $card.css('overflow')
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
let $cardReveal = $(this).find('.card-reveal');
|
|
12
|
+
if (
|
|
13
|
+
$(e.target).is($('.card-reveal .card-title')) ||
|
|
14
|
+
$(e.target).is($('.card-reveal .card-title i'))
|
|
15
|
+
) {
|
|
16
|
+
// Make Reveal animate down and display none
|
|
17
|
+
anim({
|
|
18
|
+
targets: $cardReveal[0],
|
|
19
|
+
translateY: 0,
|
|
20
|
+
duration: 225,
|
|
21
|
+
easing: 'easeInOutQuad',
|
|
22
|
+
complete: function(anim) {
|
|
23
|
+
let el = anim.animatables[0].target;
|
|
24
|
+
$(el).css({ display: 'none' });
|
|
25
|
+
$card.css('overflow', $card.data('initialOverflow'));
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
} else if ($(e.target).is($('.card .activator')) || $(e.target).is($('.card .activator i'))) {
|
|
29
|
+
$card.css('overflow', 'hidden');
|
|
30
|
+
$cardReveal.css({ display: 'block' });
|
|
31
|
+
anim({
|
|
32
|
+
targets: $cardReveal[0],
|
|
33
|
+
translateY: '-100%',
|
|
34
|
+
duration: 300,
|
|
35
|
+
easing: 'easeInOutQuad'
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
})(cash, M.anime);
|