@materializecss/materialize 2.0.1-alpha → 2.0.2-alpha
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 +5 -2
- package/dist/css/materialize.css +90 -86
- package/dist/css/materialize.min.css +2 -2
- package/dist/js/materialize.js +2797 -2705
- package/dist/js/materialize.min.js +2 -8967
- package/dist/js/materialize.min.js.map +1 -1
- package/package.json +1 -1
- package/sass/components/_collapsible.scss +0 -41
- package/sass/components/_global.scss +3 -2
- package/sass/components/_icons-material-design.scss +2 -1
- package/sass/components/_navbar.scss +6 -3
- package/sass/components/_sidenav.scss +66 -37
- package/sass/components/_theme_variables.scss +2 -2
- package/sass/components/_typography.scss +2 -2
- package/sass/components/forms/_input-fields.scss +4 -10
- package/sass/materialize.scss +0 -4
- package/src/autocomplete.ts +188 -94
- package/src/buttons.ts +225 -260
- package/src/cards.ts +5 -6
- package/src/carousel.ts +611 -542
- package/src/characterCounter.ts +50 -21
- package/src/chips.ts +152 -63
- package/src/collapsible.ts +97 -32
- package/src/component.ts +99 -10
- package/src/datepicker.ts +905 -726
- package/src/dropdown.ts +576 -484
- package/src/edges.ts +4 -4
- package/src/forms.ts +17 -14
- package/src/global.ts +55 -324
- package/src/materialbox.ts +354 -298
- package/src/modal.ts +296 -211
- package/src/parallax.ts +129 -105
- package/src/pushpin.ts +148 -103
- package/src/range.ts +166 -150
- package/src/scrollspy.ts +214 -174
- package/src/select.ts +434 -398
- package/src/sidenav.ts +447 -381
- package/src/slider.ts +421 -362
- package/src/tabs.ts +276 -222
- package/src/tapTarget.ts +246 -213
- package/src/timepicker.ts +738 -614
- package/src/toasts.ts +254 -230
- package/src/tooltip.ts +315 -252
- package/src/utils.ts +271 -0
- package/src/waves.ts +10 -10
package/src/edges.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export class Edges {
|
|
2
|
-
public top:
|
|
3
|
-
public right:
|
|
4
|
-
public bottom:
|
|
5
|
-
public left:
|
|
2
|
+
public top: boolean; // If the top edge was exceeded
|
|
3
|
+
public right: boolean; // If the right edge was exceeded
|
|
4
|
+
public bottom: boolean; // If the bottom edge was exceeded
|
|
5
|
+
public left: boolean; // If the left edge was exceeded
|
|
6
6
|
}
|
package/src/forms.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Utils } from "./utils";
|
|
2
2
|
|
|
3
3
|
export class Forms {
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Resizes the given TextArea after updating the
|
|
7
|
+
* value content dynamically.
|
|
8
|
+
* @param textarea TextArea to be resized
|
|
9
|
+
*/
|
|
10
|
+
static textareaAutoResize(textarea: HTMLTextAreaElement){
|
|
6
11
|
if (!textarea) {
|
|
7
12
|
console.error('No textarea element found');
|
|
8
13
|
return;
|
|
@@ -27,13 +32,13 @@ export class Forms {
|
|
|
27
32
|
|
|
28
33
|
if (fontSize) hiddenDiv.style.fontSize = fontSize; //('font-size', fontSize);
|
|
29
34
|
if (fontFamily) hiddenDiv.style.fontFamily = fontFamily; //css('font-family', fontFamily);
|
|
30
|
-
if (lineHeight) hiddenDiv.style.lineHeight = lineHeight; //css('line-height', lineHeight);
|
|
31
|
-
if (paddingTop) hiddenDiv.style.paddingTop = paddingTop; //ss('padding-top', paddingTop);
|
|
32
|
-
if (paddingRight) hiddenDiv.style.paddingRight = paddingRight; //css('padding-right', paddingRight);
|
|
33
|
-
if (paddingBottom) hiddenDiv.style.paddingBottom = paddingBottom; //css('padding-bottom', paddingBottom);
|
|
34
|
-
if (paddingLeft) hiddenDiv.style.paddingLeft = paddingLeft; //css('padding-left', paddingLeft);
|
|
35
|
+
if (lineHeight) hiddenDiv.style.lineHeight = lineHeight; //css('line-height', lineHeight);
|
|
36
|
+
if (paddingTop) hiddenDiv.style.paddingTop = paddingTop; //ss('padding-top', paddingTop);
|
|
37
|
+
if (paddingRight) hiddenDiv.style.paddingRight = paddingRight; //css('padding-right', paddingRight);
|
|
38
|
+
if (paddingBottom) hiddenDiv.style.paddingBottom = paddingBottom; //css('padding-bottom', paddingBottom);
|
|
39
|
+
if (paddingLeft) hiddenDiv.style.paddingLeft = paddingLeft; //css('padding-left', paddingLeft);
|
|
35
40
|
|
|
36
|
-
// Set original-height, if none
|
|
41
|
+
// Set original-height, if none
|
|
37
42
|
if (!textarea.hasAttribute('original-height'))
|
|
38
43
|
textarea.setAttribute('original-height', textarea.getBoundingClientRect().height.toString());
|
|
39
44
|
|
|
@@ -76,12 +81,12 @@ export class Forms {
|
|
|
76
81
|
static Init(){
|
|
77
82
|
document.addEventListener("DOMContentLoaded", () => {
|
|
78
83
|
|
|
79
|
-
document.addEventListener('keyup', e => {
|
|
84
|
+
document.addEventListener('keyup', (e: KeyboardEvent) => {
|
|
80
85
|
const target = <HTMLInputElement>e.target;
|
|
81
86
|
// Radio and Checkbox focus class
|
|
82
87
|
if (target instanceof HTMLInputElement && ['radio','checkbox'].includes(target.type)) {
|
|
83
88
|
// TAB, check if tabbing to radio or checkbox.
|
|
84
|
-
if (
|
|
89
|
+
if (Utils.keys.TAB.includes(e.key)) {
|
|
85
90
|
target.classList.add('tabbed');
|
|
86
91
|
target.addEventListener('blur', e => target.classList.remove('tabbed'), {once: true});
|
|
87
92
|
}
|
|
@@ -97,7 +102,7 @@ export class Forms {
|
|
|
97
102
|
textArea.addEventListener('keyup', e => Forms.textareaAutoResize(textArea));
|
|
98
103
|
textArea.addEventListener('keydown', e => Forms.textareaAutoResize(textArea));
|
|
99
104
|
});
|
|
100
|
-
|
|
105
|
+
|
|
101
106
|
// File Input Path
|
|
102
107
|
document.querySelectorAll('.file-field input[type="file"]').forEach((fileInput: HTMLInputElement) => {
|
|
103
108
|
fileInput.addEventListener('change', e => {
|
|
@@ -112,9 +117,7 @@ export class Forms {
|
|
|
112
117
|
pathInput.dispatchEvent(new Event('change'));
|
|
113
118
|
});
|
|
114
119
|
});
|
|
115
|
-
|
|
120
|
+
|
|
116
121
|
});
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
|
-
|
|
120
|
-
|
package/src/global.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Autocomplete } from './autocomplete';
|
|
2
|
-
import { Bounding } from './bounding';
|
|
3
2
|
import { FloatingActionButton } from './buttons';
|
|
4
3
|
import { Cards } from './cards';
|
|
5
4
|
import { Carousel } from './carousel';
|
|
@@ -8,7 +7,6 @@ import { Chips } from './chips';
|
|
|
8
7
|
import { Collapsible } from './collapsible';
|
|
9
8
|
import { Datepicker } from './datepicker';
|
|
10
9
|
import { Dropdown } from './dropdown';
|
|
11
|
-
import { Edges } from './edges';
|
|
12
10
|
import { Forms } from './forms';
|
|
13
11
|
import { Materialbox } from './materialbox';
|
|
14
12
|
import { Modal } from './modal';
|
|
@@ -21,31 +19,25 @@ import { Slider } from './slider';
|
|
|
21
19
|
import { Tabs } from './tabs';
|
|
22
20
|
import { TapTarget } from './tapTarget';
|
|
23
21
|
import { Timepicker } from './timepicker';
|
|
24
|
-
import { Toast } from './toasts';
|
|
22
|
+
import { Toast, ToastOptions } from './toasts';
|
|
25
23
|
import { Tooltip } from './tooltip';
|
|
26
24
|
import { Waves } from './waves';
|
|
27
25
|
import { Range } from './range';
|
|
26
|
+
import { Utils } from './utils';
|
|
28
27
|
|
|
29
28
|
export class M {
|
|
30
|
-
static version = '2.0.
|
|
29
|
+
static version = '2.0.2-alpha';
|
|
31
30
|
|
|
32
|
-
static
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
ESC: 27,
|
|
36
|
-
ARROW_UP: 38,
|
|
37
|
-
ARROW_DOWN: 40
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
static Autocomplete: typeof Autocomplete = Autocomplete;
|
|
41
|
-
static Tabs: typeof Tabs = Tabs;
|
|
42
|
-
static Carousel: typeof Carousel = Carousel;
|
|
31
|
+
static Autocomplete: typeof Autocomplete = Autocomplete;
|
|
32
|
+
static Tabs: typeof Tabs = Tabs;
|
|
33
|
+
static Carousel: typeof Carousel = Carousel;
|
|
43
34
|
static Dropdown: typeof Dropdown = Dropdown;
|
|
44
35
|
static FloatingActionButton: typeof FloatingActionButton = FloatingActionButton;
|
|
45
36
|
static Chips: typeof Chips = Chips;
|
|
46
37
|
static Collapsible: typeof Collapsible = Collapsible;
|
|
47
38
|
static Datepicker: typeof Datepicker = Datepicker;
|
|
48
39
|
static CharacterCounter: typeof CharacterCounter = CharacterCounter;
|
|
40
|
+
static Forms: typeof Forms = Forms;
|
|
49
41
|
static FormSelect: typeof FormSelect = FormSelect;
|
|
50
42
|
static Modal: typeof Modal = Modal;
|
|
51
43
|
static Pushpin: typeof Pushpin = Pushpin;
|
|
@@ -53,67 +45,21 @@ export class M {
|
|
|
53
45
|
static Parallax: typeof Parallax = Parallax;
|
|
54
46
|
static Slider: typeof Slider = Slider;
|
|
55
47
|
static Timepicker: typeof Timepicker = Timepicker;
|
|
56
|
-
|
|
48
|
+
/** Creates a toast. */
|
|
49
|
+
static toast: (opt: ToastOptions) => Toast = (opt) => new Toast(opt) ;
|
|
57
50
|
static Tooltip: typeof Tooltip = Tooltip;
|
|
58
51
|
static Sidenav: typeof Sidenav = Sidenav;
|
|
59
52
|
static TapTarget: typeof TapTarget = TapTarget;
|
|
60
53
|
static ScrollSpy: typeof ScrollSpy = ScrollSpy;
|
|
61
54
|
static Range: typeof Range = Range;
|
|
62
55
|
static Waves: typeof Waves = Waves;
|
|
63
|
-
|
|
64
|
-
static tabPressed:boolean = false;
|
|
65
|
-
static keyDown:boolean = false;
|
|
66
|
-
|
|
67
|
-
static docHandleKeydown(e) {
|
|
68
|
-
M.keyDown = true;
|
|
69
|
-
if (e.which === M.keys.TAB || e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) {
|
|
70
|
-
M.tabPressed = true;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static docHandleKeyup(e) {
|
|
75
|
-
M.keyDown = false;
|
|
76
|
-
if (e.which === M.keys.TAB || e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) {
|
|
77
|
-
M.tabPressed = false;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
static docHandleFocus(e) {
|
|
82
|
-
if (M.keyDown) {
|
|
83
|
-
document.body.classList.add('keyboard-focused');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static docHandleBlur(e) {
|
|
88
|
-
document.body.classList.remove('keyboard-focused');
|
|
89
|
-
}
|
|
56
|
+
static Utils: typeof Utils = Utils;
|
|
90
57
|
|
|
91
58
|
static {
|
|
92
|
-
document.addEventListener('keydown',
|
|
93
|
-
document.addEventListener('keyup',
|
|
94
|
-
document.addEventListener('focus',
|
|
95
|
-
document.addEventListener('blur',
|
|
96
|
-
this.initializeJqueryWrapper(Tabs, 'tabs', 'M_Tabs');
|
|
97
|
-
this.initializeJqueryWrapper(Carousel, 'carousel', 'M_Carousel');
|
|
98
|
-
this.initializeJqueryWrapper(Autocomplete, 'autocomplete', 'M_Autocomplete');
|
|
99
|
-
this.initializeJqueryWrapper(Dropdown, 'dropdown', 'M_Dropdown');
|
|
100
|
-
this.initializeJqueryWrapper(FloatingActionButton, 'floatingActionButton', 'M_FloatingActionButton');
|
|
101
|
-
M.initializeJqueryWrapper(Collapsible, 'collapsible', 'M_Collapsible');
|
|
102
|
-
M.initializeJqueryWrapper(CharacterCounter, 'characterCounter', 'M_CharacterCounter');
|
|
103
|
-
M.initializeJqueryWrapper(Datepicker, 'datepicker', 'M_Datepicker');
|
|
104
|
-
M.initializeJqueryWrapper(FormSelect, 'formSelect', 'M_FormSelect');
|
|
105
|
-
M.initializeJqueryWrapper(Modal, 'modal', 'M_Modal');
|
|
106
|
-
M.initializeJqueryWrapper(Pushpin, 'pushpin', 'M_Pushpin');
|
|
107
|
-
M.initializeJqueryWrapper(Materialbox, 'materialbox', 'M_Materialbox');
|
|
108
|
-
M.initializeJqueryWrapper(Parallax, 'parallax', 'M_Parallax');
|
|
109
|
-
M.initializeJqueryWrapper(Slider, 'slider', 'M_Slider');
|
|
110
|
-
M.initializeJqueryWrapper(Timepicker, 'timepicker', 'M_Timepicker');
|
|
111
|
-
M.initializeJqueryWrapper(Tooltip, 'tooltip', 'M_Tooltip');
|
|
112
|
-
M.initializeJqueryWrapper(TapTarget, 'tapTarget', 'M_TapTarget');
|
|
113
|
-
M.initializeJqueryWrapper(Sidenav, 'sidenav', 'M_Sidenav');
|
|
114
|
-
M.initializeJqueryWrapper(ScrollSpy, 'scrollSpy', 'M_ScrollSpy');
|
|
115
|
-
M.initializeJqueryWrapper(Range, 'range', 'M_Range');
|
|
116
|
-
M.initializeJqueryWrapper(Chips, 'chips', 'M_Chips');
|
|
59
|
+
document.addEventListener('keydown', Utils.docHandleKeydown, true);
|
|
60
|
+
document.addEventListener('keyup', Utils.docHandleKeyup, true);
|
|
61
|
+
document.addEventListener('focus', Utils.docHandleFocus, true);
|
|
62
|
+
document.addEventListener('blur', Utils.docHandleBlur, true);
|
|
117
63
|
Cards.Init();
|
|
118
64
|
Forms.Init();
|
|
119
65
|
Chips.Init();
|
|
@@ -121,264 +67,49 @@ export class M {
|
|
|
121
67
|
Range.Init();
|
|
122
68
|
}
|
|
123
69
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
static
|
|
129
|
-
if (!this.jQueryLoaded())
|
|
130
|
-
return;
|
|
131
|
-
var jq = (<any>window).jQuery;
|
|
132
|
-
|
|
133
|
-
jq.fn[pluginName] = function(methodOrOptions) {
|
|
134
|
-
// Call plugin method if valid method name is passed in
|
|
135
|
-
if (plugin.prototype[methodOrOptions]) {
|
|
136
|
-
let params = Array.prototype.slice.call(arguments, 1);
|
|
137
|
-
// Getter methods
|
|
138
|
-
if (methodOrOptions.slice(0, 3) === 'get') {
|
|
139
|
-
let instance = this.first()[0][classRef];
|
|
140
|
-
return instance[methodOrOptions].apply(instance, params);
|
|
141
|
-
}
|
|
142
|
-
// Void methods
|
|
143
|
-
return this.each(function() {
|
|
144
|
-
let instance = this[classRef];
|
|
145
|
-
instance[methodOrOptions].apply(instance, params);
|
|
146
|
-
});
|
|
147
|
-
// Initialize plugin if options or no argument is passed in
|
|
148
|
-
} else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
|
|
149
|
-
plugin.init(this, arguments[0]);
|
|
150
|
-
return this;
|
|
151
|
-
}
|
|
152
|
-
// Return error if an unrecognized method name is passed in
|
|
153
|
-
jq.error(`Method ${methodOrOptions} does not exist on jQuery.${pluginName}`);
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
//---
|
|
157
|
-
|
|
158
|
-
static AutoInit(context:Element = null) {
|
|
159
|
-
let root = !!context ? context : document.body;
|
|
70
|
+
/**
|
|
71
|
+
* Automatically initialize components.
|
|
72
|
+
* @param context Root element to initialize. Defaults to `document.body`.
|
|
73
|
+
*/
|
|
74
|
+
static AutoInit(context: HTMLElement = document.body) {
|
|
160
75
|
let registry = {
|
|
161
|
-
Autocomplete:
|
|
162
|
-
Carousel:
|
|
163
|
-
Chips:
|
|
164
|
-
Collapsible:
|
|
165
|
-
Datepicker:
|
|
166
|
-
Dropdown:
|
|
167
|
-
Materialbox:
|
|
168
|
-
Modal:
|
|
169
|
-
Parallax:
|
|
170
|
-
Pushpin:
|
|
171
|
-
ScrollSpy:
|
|
172
|
-
FormSelect:
|
|
173
|
-
Sidenav:
|
|
174
|
-
Tabs:
|
|
175
|
-
TapTarget:
|
|
176
|
-
Timepicker:
|
|
177
|
-
Tooltip:
|
|
178
|
-
FloatingActionButton:
|
|
179
|
-
};
|
|
180
|
-
M.Autocomplete.init(registry.Autocomplete, null);
|
|
181
|
-
M.Carousel.init(registry.Carousel, null);
|
|
182
|
-
M.Chips.init(registry.Chips, null);
|
|
183
|
-
M.Collapsible.init(registry.Collapsible, null);
|
|
184
|
-
M.Datepicker.init(registry.Datepicker, null);
|
|
185
|
-
M.Dropdown.init(registry.Dropdown, null);
|
|
186
|
-
M.Materialbox.init(registry.Materialbox, null);
|
|
187
|
-
M.Modal.init(registry.Modal, null);
|
|
188
|
-
M.Parallax.init(registry.Parallax, null);
|
|
189
|
-
M.Pushpin.init(registry.Pushpin, null);
|
|
190
|
-
M.ScrollSpy.init(registry.ScrollSpy, null);
|
|
191
|
-
M.FormSelect.init(registry.FormSelect, null);
|
|
192
|
-
M.Sidenav.init(registry.Sidenav, null);
|
|
193
|
-
M.Tabs.init(registry.Tabs, null);
|
|
194
|
-
M.TapTarget.init(registry.TapTarget, null);
|
|
195
|
-
M.Timepicker.init(registry.Timepicker, null);
|
|
196
|
-
M.Tooltip.init(registry.Tooltip, null);
|
|
197
|
-
M.FloatingActionButton.init(registry.FloatingActionButton, null);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
static objectSelectorString(obj: any): string {
|
|
201
|
-
let tagStr = obj.prop('tagName') || '';
|
|
202
|
-
let idStr = obj.attr('id') || '';
|
|
203
|
-
let classStr = obj.attr('class') || '';
|
|
204
|
-
return (tagStr + idStr + classStr).replace(/\s/g, '');
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
static guid(): string {
|
|
208
|
-
function s4():string {
|
|
209
|
-
return Math.floor((1 + Math.random()) * 0x10000)
|
|
210
|
-
.toString(16)
|
|
211
|
-
.substring(1);
|
|
212
|
-
}
|
|
213
|
-
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
static checkWithinContainer(container: Element, bounding: Bounding, offset: number): Edges {
|
|
217
|
-
let edges = {
|
|
218
|
-
top: false,
|
|
219
|
-
right: false,
|
|
220
|
-
bottom: false,
|
|
221
|
-
left: false
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
let containerRect = container.getBoundingClientRect();
|
|
225
|
-
// If body element is smaller than viewport, use viewport height instead.
|
|
226
|
-
let containerBottom =
|
|
227
|
-
container === document.body
|
|
228
|
-
? Math.max(containerRect.bottom, window.innerHeight)
|
|
229
|
-
: containerRect.bottom;
|
|
230
|
-
|
|
231
|
-
let scrollLeft = container.scrollLeft;
|
|
232
|
-
let scrollTop = container.scrollTop;
|
|
233
|
-
|
|
234
|
-
let scrolledX = bounding.left - scrollLeft;
|
|
235
|
-
let scrolledY = bounding.top - scrollTop;
|
|
236
|
-
|
|
237
|
-
// Check for container and viewport for each edge
|
|
238
|
-
if (scrolledX < containerRect.left + offset || scrolledX < offset) {
|
|
239
|
-
edges.left = true;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (
|
|
243
|
-
scrolledX + bounding.width > containerRect.right - offset ||
|
|
244
|
-
scrolledX + bounding.width > window.innerWidth - offset
|
|
245
|
-
) {
|
|
246
|
-
edges.right = true;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (scrolledY < containerRect.top + offset || scrolledY < offset) {
|
|
250
|
-
edges.top = true;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
if (
|
|
254
|
-
scrolledY + bounding.height > containerBottom - offset ||
|
|
255
|
-
scrolledY + bounding.height > window.innerHeight - offset
|
|
256
|
-
) {
|
|
257
|
-
edges.bottom = true;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
return edges;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
static checkPossibleAlignments(el, container, bounding, offset) {
|
|
264
|
-
let canAlign = {
|
|
265
|
-
top: true,
|
|
266
|
-
right: true,
|
|
267
|
-
bottom: true,
|
|
268
|
-
left: true,
|
|
269
|
-
spaceOnTop: null,
|
|
270
|
-
spaceOnRight: null,
|
|
271
|
-
spaceOnBottom: null,
|
|
272
|
-
spaceOnLeft: null
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
let containerAllowsOverflow = getComputedStyle(container).overflow === 'visible';
|
|
276
|
-
let containerRect = container.getBoundingClientRect();
|
|
277
|
-
let containerHeight = Math.min(containerRect.height, window.innerHeight);
|
|
278
|
-
let containerWidth = Math.min(containerRect.width, window.innerWidth);
|
|
279
|
-
let elOffsetRect = el.getBoundingClientRect();
|
|
280
|
-
|
|
281
|
-
let scrollLeft = container.scrollLeft;
|
|
282
|
-
let scrollTop = container.scrollTop;
|
|
283
|
-
|
|
284
|
-
let scrolledX = bounding.left - scrollLeft;
|
|
285
|
-
let scrolledYTopEdge = bounding.top - scrollTop;
|
|
286
|
-
let scrolledYBottomEdge = bounding.top + elOffsetRect.height - scrollTop;
|
|
287
|
-
|
|
288
|
-
// Check for container and viewport for left
|
|
289
|
-
canAlign.spaceOnRight = !containerAllowsOverflow
|
|
290
|
-
? containerWidth - (scrolledX + bounding.width)
|
|
291
|
-
: window.innerWidth - (elOffsetRect.left + bounding.width);
|
|
292
|
-
if (canAlign.spaceOnRight < 0) {
|
|
293
|
-
canAlign.left = false;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// Check for container and viewport for Right
|
|
297
|
-
canAlign.spaceOnLeft = !containerAllowsOverflow
|
|
298
|
-
? scrolledX - bounding.width + elOffsetRect.width
|
|
299
|
-
: elOffsetRect.right - bounding.width;
|
|
300
|
-
if (canAlign.spaceOnLeft < 0) {
|
|
301
|
-
canAlign.right = false;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// Check for container and viewport for Top
|
|
305
|
-
canAlign.spaceOnBottom = !containerAllowsOverflow
|
|
306
|
-
? containerHeight - (scrolledYTopEdge + bounding.height + offset)
|
|
307
|
-
: window.innerHeight - (elOffsetRect.top + bounding.height + offset);
|
|
308
|
-
if (canAlign.spaceOnBottom < 0) {
|
|
309
|
-
canAlign.top = false;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Check for container and viewport for Bottom
|
|
313
|
-
canAlign.spaceOnTop = !containerAllowsOverflow
|
|
314
|
-
? scrolledYBottomEdge - (bounding.height - offset)
|
|
315
|
-
: elOffsetRect.bottom - (bounding.height + offset);
|
|
316
|
-
if (canAlign.spaceOnTop < 0) {
|
|
317
|
-
canAlign.bottom = false;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
return canAlign;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
static getOverflowParent(element) {
|
|
324
|
-
if (element == null) {
|
|
325
|
-
return null;
|
|
326
|
-
}
|
|
327
|
-
if (element === document.body || getComputedStyle(element).overflow !== 'visible') {
|
|
328
|
-
return element;
|
|
329
|
-
}
|
|
330
|
-
return this.getOverflowParent(element.parentElement);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
static getIdFromTrigger(trigger: Element): string {
|
|
334
|
-
let id = trigger.getAttribute('data-target');
|
|
335
|
-
if (!id) {
|
|
336
|
-
id = trigger.getAttribute('href');
|
|
337
|
-
if (id) {
|
|
338
|
-
id = id.slice(1);
|
|
339
|
-
} else {
|
|
340
|
-
id = '';
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
return id;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
static getDocumentScrollTop(): number {
|
|
347
|
-
return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
static getDocumentScrollLeft(): number {
|
|
351
|
-
return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
public static throttle(func, wait, options = null) {
|
|
355
|
-
let context, args, result;
|
|
356
|
-
let timeout = null;
|
|
357
|
-
let previous = 0;
|
|
358
|
-
options || (options = {});
|
|
359
|
-
let later = function() {
|
|
360
|
-
previous = options.leading === false ? 0 : new Date().getTime();
|
|
361
|
-
timeout = null;
|
|
362
|
-
result = func.apply(context, args);
|
|
363
|
-
context = args = null;
|
|
364
|
-
};
|
|
365
|
-
return function() {
|
|
366
|
-
let now = new Date().getTime();
|
|
367
|
-
if (!previous && options.leading === false) previous = now;
|
|
368
|
-
let remaining = wait - (now - previous);
|
|
369
|
-
context = this;
|
|
370
|
-
args = arguments;
|
|
371
|
-
if (remaining <= 0) {
|
|
372
|
-
clearTimeout(timeout);
|
|
373
|
-
timeout = null;
|
|
374
|
-
previous = now;
|
|
375
|
-
result = func.apply(context, args);
|
|
376
|
-
context = args = null;
|
|
377
|
-
} else if (!timeout && options.trailing !== false) {
|
|
378
|
-
timeout = setTimeout(later, remaining);
|
|
379
|
-
}
|
|
380
|
-
return result;
|
|
76
|
+
Autocomplete: <NodeListOf<HTMLElement>>context.querySelectorAll('.autocomplete:not(.no-autoinit)'),
|
|
77
|
+
Carousel: <NodeListOf<HTMLElement>>context.querySelectorAll('.carousel:not(.no-autoinit)'),
|
|
78
|
+
Chips: <NodeListOf<HTMLElement>>context.querySelectorAll('.chips:not(.no-autoinit)'),
|
|
79
|
+
Collapsible: <NodeListOf<HTMLElement>>context.querySelectorAll('.collapsible:not(.no-autoinit)'),
|
|
80
|
+
Datepicker: <NodeListOf<HTMLElement>>context.querySelectorAll('.datepicker:not(.no-autoinit)'),
|
|
81
|
+
Dropdown: <NodeListOf<HTMLElement>>context.querySelectorAll('.dropdown-trigger:not(.no-autoinit)'),
|
|
82
|
+
Materialbox: <NodeListOf<HTMLElement>>context.querySelectorAll('.materialboxed:not(.no-autoinit)'),
|
|
83
|
+
Modal: <NodeListOf<HTMLElement>>context.querySelectorAll('.modal:not(.no-autoinit)'),
|
|
84
|
+
Parallax: <NodeListOf<HTMLElement>>context.querySelectorAll('.parallax:not(.no-autoinit)'),
|
|
85
|
+
Pushpin: <NodeListOf<HTMLElement>>context.querySelectorAll('.pushpin:not(.no-autoinit)'),
|
|
86
|
+
ScrollSpy: <NodeListOf<HTMLElement>>context.querySelectorAll('.scrollspy:not(.no-autoinit)'),
|
|
87
|
+
FormSelect: <NodeListOf<HTMLElement>>context.querySelectorAll('select:not(.no-autoinit)'),
|
|
88
|
+
Sidenav: <NodeListOf<HTMLElement>>context.querySelectorAll('.sidenav:not(.no-autoinit)'),
|
|
89
|
+
Tabs: <NodeListOf<HTMLElement>>context.querySelectorAll('.tabs:not(.no-autoinit)'),
|
|
90
|
+
TapTarget: <NodeListOf<HTMLElement>>context.querySelectorAll('.tap-target:not(.no-autoinit)'),
|
|
91
|
+
Timepicker: <NodeListOf<HTMLElement>>context.querySelectorAll('.timepicker:not(.no-autoinit)'),
|
|
92
|
+
Tooltip: <NodeListOf<HTMLElement>>context.querySelectorAll('.tooltipped:not(.no-autoinit)'),
|
|
93
|
+
FloatingActionButton: <NodeListOf<HTMLElement>>context.querySelectorAll('.fixed-action-btn:not(.no-autoinit)'),
|
|
381
94
|
};
|
|
95
|
+
M.Autocomplete.init(registry.Autocomplete, {});
|
|
96
|
+
M.Carousel.init(registry.Carousel, {});
|
|
97
|
+
M.Chips.init(registry.Chips, {});
|
|
98
|
+
M.Collapsible.init(registry.Collapsible, {});
|
|
99
|
+
M.Datepicker.init(registry.Datepicker, {});
|
|
100
|
+
M.Dropdown.init(registry.Dropdown, {});
|
|
101
|
+
M.Materialbox.init(registry.Materialbox, {});
|
|
102
|
+
M.Modal.init(registry.Modal, {});
|
|
103
|
+
M.Parallax.init(registry.Parallax, {});
|
|
104
|
+
M.Pushpin.init(registry.Pushpin, {});
|
|
105
|
+
M.ScrollSpy.init(registry.ScrollSpy, {});
|
|
106
|
+
M.FormSelect.init(registry.FormSelect, {});
|
|
107
|
+
M.Sidenav.init(registry.Sidenav, {});
|
|
108
|
+
M.Tabs.init(registry.Tabs, {});
|
|
109
|
+
M.TapTarget.init(registry.TapTarget, {});
|
|
110
|
+
M.Timepicker.init(registry.Timepicker, {});
|
|
111
|
+
M.Tooltip.init(registry.Tooltip, {});
|
|
112
|
+
M.FloatingActionButton.init(registry.FloatingActionButton, {});
|
|
382
113
|
}
|
|
383
114
|
}
|
|
384
115
|
|