@materializecss/materialize 1.2.0 → 1.2.1
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/Gruntfile.js +722 -712
- package/LICENSE +21 -21
- package/README.md +91 -91
- package/dist/css/materialize.css +68 -135
- package/dist/css/materialize.min.css +12 -12
- package/dist/js/materialize.js +1112 -1112
- package/dist/js/materialize.min.js +6 -6
- package/extras/noUiSlider/nouislider.css +403 -403
- package/extras/noUiSlider/nouislider.js +2147 -2147
- package/js/anime.min.js +34 -34
- package/js/autocomplete.js +479 -479
- package/js/buttons.js +354 -354
- package/js/cards.js +40 -40
- package/js/carousel.js +732 -732
- package/js/cash.js +960 -960
- package/js/characterCounter.js +136 -136
- package/js/chips.js +486 -486
- package/js/collapsible.js +275 -275
- package/js/component.js +44 -44
- package/js/datepicker.js +983 -983
- package/js/dropdown.js +669 -669
- package/js/forms.js +285 -285
- package/js/global.js +428 -428
- package/js/materialbox.js +453 -453
- package/js/modal.js +382 -382
- package/js/parallax.js +138 -138
- package/js/pushpin.js +148 -148
- package/js/range.js +263 -263
- package/js/scrollspy.js +295 -295
- package/js/select.js +391 -391
- package/js/sidenav.js +583 -583
- package/js/slider.js +359 -359
- package/js/tabs.js +402 -402
- package/js/tapTarget.js +315 -315
- package/js/timepicker.js +712 -712
- package/js/toasts.js +325 -325
- package/js/tooltip.js +320 -320
- package/js/waves.js +614 -614
- package/package.json +87 -84
- package/sass/_style.scss +929 -929
- package/sass/components/_badges.scss +55 -55
- package/sass/components/_buttons.scss +322 -322
- package/sass/components/_cards.scss +195 -195
- package/sass/components/_carousel.scss +90 -90
- package/sass/components/_chips.scss +96 -96
- package/sass/components/_collapsible.scss +91 -91
- package/sass/components/_collection.scss +106 -106
- package/sass/components/_color-classes.scss +32 -32
- package/sass/components/_color-variables.scss +370 -370
- package/sass/components/_datepicker.scss +191 -191
- package/sass/components/_dropdown.scss +84 -84
- package/sass/components/_global.scss +646 -646
- package/sass/components/_grid.scss +158 -158
- package/sass/components/_icons-material-design.scss +5 -5
- package/sass/components/_materialbox.scss +42 -42
- package/sass/components/_modal.scss +97 -97
- package/sass/components/_navbar.scss +208 -208
- package/sass/components/_normalize.scss +447 -447
- package/sass/components/_preloader.scss +334 -334
- package/sass/components/_pulse.scss +34 -34
- package/sass/components/_sidenav.scss +214 -214
- package/sass/components/_slider.scss +91 -91
- package/sass/components/_table_of_contents.scss +33 -33
- package/sass/components/_tabs.scss +99 -99
- package/sass/components/_tapTarget.scss +103 -103
- package/sass/components/_timepicker.scss +199 -199
- package/sass/components/_toast.scss +58 -58
- package/sass/components/_tooltip.scss +32 -32
- package/sass/components/_transitions.scss +12 -12
- package/sass/components/_typography.scss +62 -62
- package/sass/components/_variables.scss +352 -352
- package/sass/components/_waves.scss +187 -187
- package/sass/components/forms/_checkboxes.scss +200 -200
- package/sass/components/forms/_file-input.scss +44 -44
- package/sass/components/forms/_forms.scss +22 -22
- package/sass/components/forms/_input-fields.scss +388 -388
- package/sass/components/forms/_radio-buttons.scss +115 -115
- package/sass/components/forms/_range.scss +161 -161
- package/sass/components/forms/_select.scss +199 -199
- package/sass/components/forms/_switches.scss +91 -91
- package/sass/ghpages-materialize.scss +7 -7
- package/sass/materialize.scss +42 -42
package/js/buttons.js
CHANGED
|
@@ -1,354 +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);
|
|
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);
|