@materializecss/materialize 1.2.0 → 1.2.2

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.
Files changed (82) hide show
  1. package/Gruntfile.js +722 -712
  2. package/LICENSE +21 -21
  3. package/README.md +91 -91
  4. package/dist/css/materialize.css +78 -137
  5. package/dist/css/materialize.min.css +12 -12
  6. package/dist/js/materialize.js +1502 -1378
  7. package/dist/js/materialize.min.js +6 -6
  8. package/extras/noUiSlider/nouislider.css +403 -403
  9. package/extras/noUiSlider/nouislider.js +2147 -2147
  10. package/js/anime.min.js +34 -34
  11. package/js/autocomplete.js +479 -479
  12. package/js/buttons.js +354 -354
  13. package/js/cards.js +40 -40
  14. package/js/carousel.js +732 -732
  15. package/js/cash.js +960 -960
  16. package/js/characterCounter.js +136 -136
  17. package/js/chips.js +486 -486
  18. package/js/collapsible.js +275 -275
  19. package/js/component.js +44 -44
  20. package/js/datepicker.js +983 -983
  21. package/js/dropdown.js +669 -669
  22. package/js/forms.js +285 -285
  23. package/js/global.js +428 -428
  24. package/js/materialbox.js +453 -453
  25. package/js/modal.js +382 -382
  26. package/js/parallax.js +138 -138
  27. package/js/pushpin.js +148 -148
  28. package/js/range.js +263 -263
  29. package/js/scrollspy.js +295 -295
  30. package/js/select.js +391 -391
  31. package/js/sidenav.js +583 -583
  32. package/js/slider.js +497 -359
  33. package/js/tabs.js +402 -402
  34. package/js/tapTarget.js +315 -315
  35. package/js/timepicker.js +712 -712
  36. package/js/toasts.js +325 -325
  37. package/js/tooltip.js +320 -320
  38. package/js/waves.js +614 -614
  39. package/package.json +87 -84
  40. package/sass/components/_badges.scss +55 -55
  41. package/sass/components/_buttons.scss +322 -322
  42. package/sass/components/_cards.scss +195 -195
  43. package/sass/components/_carousel.scss +90 -90
  44. package/sass/components/_chips.scss +96 -96
  45. package/sass/components/_collapsible.scss +91 -91
  46. package/sass/components/_collection.scss +106 -106
  47. package/sass/components/_color-classes.scss +32 -32
  48. package/sass/components/_color-variables.scss +370 -370
  49. package/sass/components/_datepicker.scss +191 -191
  50. package/sass/components/_dropdown.scss +84 -84
  51. package/sass/components/_global.scss +646 -646
  52. package/sass/components/_grid.scss +158 -158
  53. package/sass/components/_icons-material-design.scss +5 -5
  54. package/sass/components/_materialbox.scss +42 -42
  55. package/sass/components/_modal.scss +97 -97
  56. package/sass/components/_navbar.scss +208 -208
  57. package/sass/components/_normalize.scss +447 -447
  58. package/sass/components/_preloader.scss +334 -334
  59. package/sass/components/_pulse.scss +34 -34
  60. package/sass/components/_sidenav.scss +214 -214
  61. package/sass/components/_slider.scss +100 -91
  62. package/sass/components/_table_of_contents.scss +33 -33
  63. package/sass/components/_tabs.scss +99 -99
  64. package/sass/components/_tapTarget.scss +103 -103
  65. package/sass/components/_timepicker.scss +199 -199
  66. package/sass/components/_toast.scss +58 -58
  67. package/sass/components/_tooltip.scss +32 -32
  68. package/sass/components/_transitions.scss +12 -12
  69. package/sass/components/_typography.scss +62 -62
  70. package/sass/components/_variables.scss +352 -352
  71. package/sass/components/_waves.scss +187 -187
  72. package/sass/components/forms/_checkboxes.scss +200 -200
  73. package/sass/components/forms/_file-input.scss +44 -44
  74. package/sass/components/forms/_forms.scss +22 -22
  75. package/sass/components/forms/_input-fields.scss +388 -388
  76. package/sass/components/forms/_radio-buttons.scss +115 -115
  77. package/sass/components/forms/_range.scss +161 -161
  78. package/sass/components/forms/_select.scss +199 -199
  79. package/sass/components/forms/_switches.scss +91 -91
  80. package/sass/materialize.scss +42 -42
  81. package/sass/_style.scss +0 -929
  82. package/sass/ghpages-materialize.scss +0 -7
package/js/global.js CHANGED
@@ -1,428 +1,428 @@
1
- // Required for Meteor package, the use of window prevents export by Meteor
2
- (function(window) {
3
- if (window.Package) {
4
- M = {};
5
- } else {
6
- window.M = {};
7
- }
8
-
9
- // Check for jQuery
10
- M.jQueryLoaded = !!window.jQuery;
11
- })(window);
12
-
13
- // AMD
14
- if (typeof define === 'function' && define.amd) {
15
- define('M', [], function() {
16
- return M;
17
- });
18
-
19
- // Common JS
20
- } else if (typeof exports !== 'undefined' && !exports.nodeType) {
21
- if (typeof module !== 'undefined' && !module.nodeType && module.exports) {
22
- exports = module.exports = M;
23
- }
24
- exports.default = M;
25
- }
26
-
27
- M.version = '1.2.0';
28
-
29
- M.keys = {
30
- TAB: 9,
31
- ENTER: 13,
32
- ESC: 27,
33
- ARROW_UP: 38,
34
- ARROW_DOWN: 40
35
- };
36
-
37
- /**
38
- * TabPress Keydown handler
39
- */
40
- M.tabPressed = false;
41
- M.keyDown = false;
42
- let docHandleKeydown = function(e) {
43
- M.keyDown = true;
44
- if (e.which === M.keys.TAB || e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) {
45
- M.tabPressed = true;
46
- }
47
- };
48
- let docHandleKeyup = function(e) {
49
- M.keyDown = false;
50
- if (e.which === M.keys.TAB || e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) {
51
- M.tabPressed = false;
52
- }
53
- };
54
- let docHandleFocus = function(e) {
55
- if (M.keyDown) {
56
- document.body.classList.add('keyboard-focused');
57
- }
58
- };
59
- let docHandleBlur = function(e) {
60
- document.body.classList.remove('keyboard-focused');
61
- };
62
- document.addEventListener('keydown', docHandleKeydown, true);
63
- document.addEventListener('keyup', docHandleKeyup, true);
64
- document.addEventListener('focus', docHandleFocus, true);
65
- document.addEventListener('blur', docHandleBlur, true);
66
-
67
- /**
68
- * Initialize jQuery wrapper for plugin
69
- * @param {Class} plugin javascript class
70
- * @param {string} pluginName jQuery plugin name
71
- * @param {string} classRef Class reference name
72
- */
73
- M.initializeJqueryWrapper = function(plugin, pluginName, classRef) {
74
- jQuery.fn[pluginName] = function(methodOrOptions) {
75
- // Call plugin method if valid method name is passed in
76
- if (plugin.prototype[methodOrOptions]) {
77
- let params = Array.prototype.slice.call(arguments, 1);
78
-
79
- // Getter methods
80
- if (methodOrOptions.slice(0, 3) === 'get') {
81
- let instance = this.first()[0][classRef];
82
- return instance[methodOrOptions].apply(instance, params);
83
- }
84
-
85
- // Void methods
86
- return this.each(function() {
87
- let instance = this[classRef];
88
- instance[methodOrOptions].apply(instance, params);
89
- });
90
-
91
- // Initialize plugin if options or no argument is passed in
92
- } else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
93
- plugin.init(this, arguments[0]);
94
- return this;
95
- }
96
-
97
- // Return error if an unrecognized method name is passed in
98
- jQuery.error(`Method ${methodOrOptions} does not exist on jQuery.${pluginName}`);
99
- };
100
- };
101
-
102
- /**
103
- * Automatically initialize components
104
- * @param {Element} context DOM Element to search within for components
105
- */
106
- M.AutoInit = function(context) {
107
- // Use document.body if no context is given
108
- let root = !!context ? context : document.body;
109
-
110
- let registry = {
111
- Autocomplete: root.querySelectorAll('.autocomplete:not(.no-autoinit)'),
112
- Carousel: root.querySelectorAll('.carousel:not(.no-autoinit)'),
113
- Chips: root.querySelectorAll('.chips:not(.no-autoinit)'),
114
- Collapsible: root.querySelectorAll('.collapsible:not(.no-autoinit)'),
115
- Datepicker: root.querySelectorAll('.datepicker:not(.no-autoinit)'),
116
- Dropdown: root.querySelectorAll('.dropdown-trigger:not(.no-autoinit)'),
117
- Materialbox: root.querySelectorAll('.materialboxed:not(.no-autoinit)'),
118
- Modal: root.querySelectorAll('.modal:not(.no-autoinit)'),
119
- Parallax: root.querySelectorAll('.parallax:not(.no-autoinit)'),
120
- Pushpin: root.querySelectorAll('.pushpin:not(.no-autoinit)'),
121
- ScrollSpy: root.querySelectorAll('.scrollspy:not(.no-autoinit)'),
122
- FormSelect: root.querySelectorAll('select:not(.no-autoinit)'),
123
- Sidenav: root.querySelectorAll('.sidenav:not(.no-autoinit)'),
124
- Tabs: root.querySelectorAll('.tabs:not(.no-autoinit)'),
125
- TapTarget: root.querySelectorAll('.tap-target:not(.no-autoinit)'),
126
- Timepicker: root.querySelectorAll('.timepicker:not(.no-autoinit)'),
127
- Tooltip: root.querySelectorAll('.tooltipped:not(.no-autoinit)'),
128
- FloatingActionButton: root.querySelectorAll('.fixed-action-btn:not(.no-autoinit)')
129
- };
130
-
131
- for (let pluginName in registry) {
132
- let plugin = M[pluginName];
133
- plugin.init(registry[pluginName]);
134
- }
135
- };
136
-
137
- /**
138
- * Generate approximated selector string for a jQuery object
139
- * @param {jQuery} obj jQuery object to be parsed
140
- * @returns {string}
141
- */
142
- M.objectSelectorString = function(obj) {
143
- let tagStr = obj.prop('tagName') || '';
144
- let idStr = obj.attr('id') || '';
145
- let classStr = obj.attr('class') || '';
146
- return (tagStr + idStr + classStr).replace(/\s/g, '');
147
- };
148
-
149
- // Unique Random ID
150
- M.guid = (function() {
151
- function s4() {
152
- return Math.floor((1 + Math.random()) * 0x10000)
153
- .toString(16)
154
- .substring(1);
155
- }
156
- return function() {
157
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
158
- };
159
- })();
160
-
161
- /**
162
- * Escapes hash from special characters
163
- * @param {string} hash String returned from this.hash
164
- * @returns {string}
165
- */
166
- M.escapeHash = function(hash) {
167
- return hash.replace(/(:|\.|\[|\]|,|=|\/)/g, '\\$1');
168
- };
169
-
170
- /**
171
- * @typedef {Object} Edges
172
- * @property {Boolean} top If the top edge was exceeded
173
- * @property {Boolean} right If the right edge was exceeded
174
- * @property {Boolean} bottom If the bottom edge was exceeded
175
- * @property {Boolean} left If the left edge was exceeded
176
- */
177
-
178
- /**
179
- * @typedef {Object} Bounding
180
- * @property {Number} left left offset coordinate
181
- * @property {Number} top top offset coordinate
182
- * @property {Number} width
183
- * @property {Number} height
184
- */
185
-
186
- /**
187
- * Escapes hash from special characters
188
- * @param {Element} container Container element that acts as the boundary
189
- * @param {Bounding} bounding element bounding that is being checked
190
- * @param {Number} offset offset from edge that counts as exceeding
191
- * @returns {Edges}
192
- */
193
- M.checkWithinContainer = function(container, bounding, offset) {
194
- let edges = {
195
- top: false,
196
- right: false,
197
- bottom: false,
198
- left: false
199
- };
200
-
201
- let containerRect = container.getBoundingClientRect();
202
- // If body element is smaller than viewport, use viewport height instead.
203
- let containerBottom =
204
- container === document.body
205
- ? Math.max(containerRect.bottom, window.innerHeight)
206
- : containerRect.bottom;
207
-
208
- let scrollLeft = container.scrollLeft;
209
- let scrollTop = container.scrollTop;
210
-
211
- let scrolledX = bounding.left - scrollLeft;
212
- let scrolledY = bounding.top - scrollTop;
213
-
214
- // Check for container and viewport for each edge
215
- if (scrolledX < containerRect.left + offset || scrolledX < offset) {
216
- edges.left = true;
217
- }
218
-
219
- if (
220
- scrolledX + bounding.width > containerRect.right - offset ||
221
- scrolledX + bounding.width > window.innerWidth - offset
222
- ) {
223
- edges.right = true;
224
- }
225
-
226
- if (scrolledY < containerRect.top + offset || scrolledY < offset) {
227
- edges.top = true;
228
- }
229
-
230
- if (
231
- scrolledY + bounding.height > containerBottom - offset ||
232
- scrolledY + bounding.height > window.innerHeight - offset
233
- ) {
234
- edges.bottom = true;
235
- }
236
-
237
- return edges;
238
- };
239
-
240
- M.checkPossibleAlignments = function(el, container, bounding, offset) {
241
- let canAlign = {
242
- top: true,
243
- right: true,
244
- bottom: true,
245
- left: true,
246
- spaceOnTop: null,
247
- spaceOnRight: null,
248
- spaceOnBottom: null,
249
- spaceOnLeft: null
250
- };
251
-
252
- let containerAllowsOverflow = getComputedStyle(container).overflow === 'visible';
253
- let containerRect = container.getBoundingClientRect();
254
- let containerHeight = Math.min(containerRect.height, window.innerHeight);
255
- let containerWidth = Math.min(containerRect.width, window.innerWidth);
256
- let elOffsetRect = el.getBoundingClientRect();
257
-
258
- let scrollLeft = container.scrollLeft;
259
- let scrollTop = container.scrollTop;
260
-
261
- let scrolledX = bounding.left - scrollLeft;
262
- let scrolledYTopEdge = bounding.top - scrollTop;
263
- let scrolledYBottomEdge = bounding.top + elOffsetRect.height - scrollTop;
264
-
265
- // Check for container and viewport for left
266
- canAlign.spaceOnRight = !containerAllowsOverflow
267
- ? containerWidth - (scrolledX + bounding.width)
268
- : window.innerWidth - (elOffsetRect.left + bounding.width);
269
- if (canAlign.spaceOnRight < 0) {
270
- canAlign.left = false;
271
- }
272
-
273
- // Check for container and viewport for Right
274
- canAlign.spaceOnLeft = !containerAllowsOverflow
275
- ? scrolledX - bounding.width + elOffsetRect.width
276
- : elOffsetRect.right - bounding.width;
277
- if (canAlign.spaceOnLeft < 0) {
278
- canAlign.right = false;
279
- }
280
-
281
- // Check for container and viewport for Top
282
- canAlign.spaceOnBottom = !containerAllowsOverflow
283
- ? containerHeight - (scrolledYTopEdge + bounding.height + offset)
284
- : window.innerHeight - (elOffsetRect.top + bounding.height + offset);
285
- if (canAlign.spaceOnBottom < 0) {
286
- canAlign.top = false;
287
- }
288
-
289
- // Check for container and viewport for Bottom
290
- canAlign.spaceOnTop = !containerAllowsOverflow
291
- ? scrolledYBottomEdge - (bounding.height - offset)
292
- : elOffsetRect.bottom - (bounding.height + offset);
293
- if (canAlign.spaceOnTop < 0) {
294
- canAlign.bottom = false;
295
- }
296
-
297
- return canAlign;
298
- };
299
-
300
- M.getOverflowParent = function(element) {
301
- if (element == null) {
302
- return null;
303
- }
304
-
305
- if (element === document.body || getComputedStyle(element).overflow !== 'visible') {
306
- return element;
307
- }
308
-
309
- return M.getOverflowParent(element.parentElement);
310
- };
311
-
312
- /**
313
- * Gets id of component from a trigger
314
- * @param {Element} trigger trigger
315
- * @returns {string}
316
- */
317
- M.getIdFromTrigger = function(trigger) {
318
- let id = trigger.getAttribute('data-target');
319
- if (!id) {
320
- id = trigger.getAttribute('href');
321
- if (id) {
322
- id = id.slice(1);
323
- } else {
324
- id = '';
325
- }
326
- }
327
- return id;
328
- };
329
-
330
- /**
331
- * Multi browser support for document scroll top
332
- * @returns {Number}
333
- */
334
- M.getDocumentScrollTop = function() {
335
- return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
336
- };
337
-
338
- /**
339
- * Multi browser support for document scroll left
340
- * @returns {Number}
341
- */
342
- M.getDocumentScrollLeft = function() {
343
- return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
344
- };
345
-
346
- /**
347
- * @typedef {Object} Edges
348
- * @property {Boolean} top If the top edge was exceeded
349
- * @property {Boolean} right If the right edge was exceeded
350
- * @property {Boolean} bottom If the bottom edge was exceeded
351
- * @property {Boolean} left If the left edge was exceeded
352
- */
353
-
354
- /**
355
- * @typedef {Object} Bounding
356
- * @property {Number} left left offset coordinate
357
- * @property {Number} top top offset coordinate
358
- * @property {Number} width
359
- * @property {Number} height
360
- */
361
-
362
- /**
363
- * Get time in ms
364
- * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
365
- * @type {function}
366
- * @return {number}
367
- */
368
- let getTime =
369
- Date.now ||
370
- function() {
371
- return new Date().getTime();
372
- };
373
-
374
- /**
375
- * Returns a function, that, when invoked, will only be triggered at most once
376
- * during a given window of time. Normally, the throttled function will run
377
- * as much as it can, without ever going more than once per `wait` duration;
378
- * but if you'd like to disable the execution on the leading edge, pass
379
- * `{leading: false}`. To disable execution on the trailing edge, ditto.
380
- * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
381
- * @param {function} func
382
- * @param {number} wait
383
- * @param {Object=} options
384
- * @returns {Function}
385
- */
386
- M.throttle = function(func, wait, options) {
387
- let context, args, result;
388
- let timeout = null;
389
- let previous = 0;
390
- options || (options = {});
391
- let later = function() {
392
- previous = options.leading === false ? 0 : getTime();
393
- timeout = null;
394
- result = func.apply(context, args);
395
- context = args = null;
396
- };
397
- return function() {
398
- let now = getTime();
399
- if (!previous && options.leading === false) previous = now;
400
- let remaining = wait - (now - previous);
401
- context = this;
402
- args = arguments;
403
- if (remaining <= 0) {
404
- clearTimeout(timeout);
405
- timeout = null;
406
- previous = now;
407
- result = func.apply(context, args);
408
- context = args = null;
409
- } else if (!timeout && options.trailing !== false) {
410
- timeout = setTimeout(later, remaining);
411
- }
412
- return result;
413
- };
414
- };
415
-
416
- /* Feature detection */
417
- var passiveIfSupported = false;
418
- try {
419
- window.addEventListener(
420
- 'test',
421
- null,
422
- Object.defineProperty({}, 'passive', {
423
- get: function() {
424
- passiveIfSupported = { passive: false };
425
- }
426
- })
427
- );
428
- } catch (err) {}
1
+ // Required for Meteor package, the use of window prevents export by Meteor
2
+ (function(window) {
3
+ if (window.Package) {
4
+ M = {};
5
+ } else {
6
+ window.M = {};
7
+ }
8
+
9
+ // Check for jQuery
10
+ M.jQueryLoaded = !!window.jQuery;
11
+ })(window);
12
+
13
+ // AMD
14
+ if (typeof define === 'function' && define.amd) {
15
+ define('M', [], function() {
16
+ return M;
17
+ });
18
+
19
+ // Common JS
20
+ } else if (typeof exports !== 'undefined' && !exports.nodeType) {
21
+ if (typeof module !== 'undefined' && !module.nodeType && module.exports) {
22
+ exports = module.exports = M;
23
+ }
24
+ exports.default = M;
25
+ }
26
+
27
+ M.version = '1.2.2';
28
+
29
+ M.keys = {
30
+ TAB: 9,
31
+ ENTER: 13,
32
+ ESC: 27,
33
+ ARROW_UP: 38,
34
+ ARROW_DOWN: 40
35
+ };
36
+
37
+ /**
38
+ * TabPress Keydown handler
39
+ */
40
+ M.tabPressed = false;
41
+ M.keyDown = false;
42
+ let docHandleKeydown = function(e) {
43
+ M.keyDown = true;
44
+ if (e.which === M.keys.TAB || e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) {
45
+ M.tabPressed = true;
46
+ }
47
+ };
48
+ let docHandleKeyup = function(e) {
49
+ M.keyDown = false;
50
+ if (e.which === M.keys.TAB || e.which === M.keys.ARROW_DOWN || e.which === M.keys.ARROW_UP) {
51
+ M.tabPressed = false;
52
+ }
53
+ };
54
+ let docHandleFocus = function(e) {
55
+ if (M.keyDown) {
56
+ document.body.classList.add('keyboard-focused');
57
+ }
58
+ };
59
+ let docHandleBlur = function(e) {
60
+ document.body.classList.remove('keyboard-focused');
61
+ };
62
+ document.addEventListener('keydown', docHandleKeydown, true);
63
+ document.addEventListener('keyup', docHandleKeyup, true);
64
+ document.addEventListener('focus', docHandleFocus, true);
65
+ document.addEventListener('blur', docHandleBlur, true);
66
+
67
+ /**
68
+ * Initialize jQuery wrapper for plugin
69
+ * @param {Class} plugin javascript class
70
+ * @param {string} pluginName jQuery plugin name
71
+ * @param {string} classRef Class reference name
72
+ */
73
+ M.initializeJqueryWrapper = function(plugin, pluginName, classRef) {
74
+ jQuery.fn[pluginName] = function(methodOrOptions) {
75
+ // Call plugin method if valid method name is passed in
76
+ if (plugin.prototype[methodOrOptions]) {
77
+ let params = Array.prototype.slice.call(arguments, 1);
78
+
79
+ // Getter methods
80
+ if (methodOrOptions.slice(0, 3) === 'get') {
81
+ let instance = this.first()[0][classRef];
82
+ return instance[methodOrOptions].apply(instance, params);
83
+ }
84
+
85
+ // Void methods
86
+ return this.each(function() {
87
+ let instance = this[classRef];
88
+ instance[methodOrOptions].apply(instance, params);
89
+ });
90
+
91
+ // Initialize plugin if options or no argument is passed in
92
+ } else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
93
+ plugin.init(this, arguments[0]);
94
+ return this;
95
+ }
96
+
97
+ // Return error if an unrecognized method name is passed in
98
+ jQuery.error(`Method ${methodOrOptions} does not exist on jQuery.${pluginName}`);
99
+ };
100
+ };
101
+
102
+ /**
103
+ * Automatically initialize components
104
+ * @param {Element} context DOM Element to search within for components
105
+ */
106
+ M.AutoInit = function(context) {
107
+ // Use document.body if no context is given
108
+ let root = !!context ? context : document.body;
109
+
110
+ let registry = {
111
+ Autocomplete: root.querySelectorAll('.autocomplete:not(.no-autoinit)'),
112
+ Carousel: root.querySelectorAll('.carousel:not(.no-autoinit)'),
113
+ Chips: root.querySelectorAll('.chips:not(.no-autoinit)'),
114
+ Collapsible: root.querySelectorAll('.collapsible:not(.no-autoinit)'),
115
+ Datepicker: root.querySelectorAll('.datepicker:not(.no-autoinit)'),
116
+ Dropdown: root.querySelectorAll('.dropdown-trigger:not(.no-autoinit)'),
117
+ Materialbox: root.querySelectorAll('.materialboxed:not(.no-autoinit)'),
118
+ Modal: root.querySelectorAll('.modal:not(.no-autoinit)'),
119
+ Parallax: root.querySelectorAll('.parallax:not(.no-autoinit)'),
120
+ Pushpin: root.querySelectorAll('.pushpin:not(.no-autoinit)'),
121
+ ScrollSpy: root.querySelectorAll('.scrollspy:not(.no-autoinit)'),
122
+ FormSelect: root.querySelectorAll('select:not(.no-autoinit)'),
123
+ Sidenav: root.querySelectorAll('.sidenav:not(.no-autoinit)'),
124
+ Tabs: root.querySelectorAll('.tabs:not(.no-autoinit)'),
125
+ TapTarget: root.querySelectorAll('.tap-target:not(.no-autoinit)'),
126
+ Timepicker: root.querySelectorAll('.timepicker:not(.no-autoinit)'),
127
+ Tooltip: root.querySelectorAll('.tooltipped:not(.no-autoinit)'),
128
+ FloatingActionButton: root.querySelectorAll('.fixed-action-btn:not(.no-autoinit)')
129
+ };
130
+
131
+ for (let pluginName in registry) {
132
+ let plugin = M[pluginName];
133
+ plugin.init(registry[pluginName]);
134
+ }
135
+ };
136
+
137
+ /**
138
+ * Generate approximated selector string for a jQuery object
139
+ * @param {jQuery} obj jQuery object to be parsed
140
+ * @returns {string}
141
+ */
142
+ M.objectSelectorString = function(obj) {
143
+ let tagStr = obj.prop('tagName') || '';
144
+ let idStr = obj.attr('id') || '';
145
+ let classStr = obj.attr('class') || '';
146
+ return (tagStr + idStr + classStr).replace(/\s/g, '');
147
+ };
148
+
149
+ // Unique Random ID
150
+ M.guid = (function() {
151
+ function s4() {
152
+ return Math.floor((1 + Math.random()) * 0x10000)
153
+ .toString(16)
154
+ .substring(1);
155
+ }
156
+ return function() {
157
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
158
+ };
159
+ })();
160
+
161
+ /**
162
+ * Escapes hash from special characters
163
+ * @param {string} hash String returned from this.hash
164
+ * @returns {string}
165
+ */
166
+ M.escapeHash = function(hash) {
167
+ return hash.replace(/(:|\.|\[|\]|,|=|\/)/g, '\\$1');
168
+ };
169
+
170
+ /**
171
+ * @typedef {Object} Edges
172
+ * @property {Boolean} top If the top edge was exceeded
173
+ * @property {Boolean} right If the right edge was exceeded
174
+ * @property {Boolean} bottom If the bottom edge was exceeded
175
+ * @property {Boolean} left If the left edge was exceeded
176
+ */
177
+
178
+ /**
179
+ * @typedef {Object} Bounding
180
+ * @property {Number} left left offset coordinate
181
+ * @property {Number} top top offset coordinate
182
+ * @property {Number} width
183
+ * @property {Number} height
184
+ */
185
+
186
+ /**
187
+ * Escapes hash from special characters
188
+ * @param {Element} container Container element that acts as the boundary
189
+ * @param {Bounding} bounding element bounding that is being checked
190
+ * @param {Number} offset offset from edge that counts as exceeding
191
+ * @returns {Edges}
192
+ */
193
+ M.checkWithinContainer = function(container, bounding, offset) {
194
+ let edges = {
195
+ top: false,
196
+ right: false,
197
+ bottom: false,
198
+ left: false
199
+ };
200
+
201
+ let containerRect = container.getBoundingClientRect();
202
+ // If body element is smaller than viewport, use viewport height instead.
203
+ let containerBottom =
204
+ container === document.body
205
+ ? Math.max(containerRect.bottom, window.innerHeight)
206
+ : containerRect.bottom;
207
+
208
+ let scrollLeft = container.scrollLeft;
209
+ let scrollTop = container.scrollTop;
210
+
211
+ let scrolledX = bounding.left - scrollLeft;
212
+ let scrolledY = bounding.top - scrollTop;
213
+
214
+ // Check for container and viewport for each edge
215
+ if (scrolledX < containerRect.left + offset || scrolledX < offset) {
216
+ edges.left = true;
217
+ }
218
+
219
+ if (
220
+ scrolledX + bounding.width > containerRect.right - offset ||
221
+ scrolledX + bounding.width > window.innerWidth - offset
222
+ ) {
223
+ edges.right = true;
224
+ }
225
+
226
+ if (scrolledY < containerRect.top + offset || scrolledY < offset) {
227
+ edges.top = true;
228
+ }
229
+
230
+ if (
231
+ scrolledY + bounding.height > containerBottom - offset ||
232
+ scrolledY + bounding.height > window.innerHeight - offset
233
+ ) {
234
+ edges.bottom = true;
235
+ }
236
+
237
+ return edges;
238
+ };
239
+
240
+ M.checkPossibleAlignments = function(el, container, bounding, offset) {
241
+ let canAlign = {
242
+ top: true,
243
+ right: true,
244
+ bottom: true,
245
+ left: true,
246
+ spaceOnTop: null,
247
+ spaceOnRight: null,
248
+ spaceOnBottom: null,
249
+ spaceOnLeft: null
250
+ };
251
+
252
+ let containerAllowsOverflow = getComputedStyle(container).overflow === 'visible';
253
+ let containerRect = container.getBoundingClientRect();
254
+ let containerHeight = Math.min(containerRect.height, window.innerHeight);
255
+ let containerWidth = Math.min(containerRect.width, window.innerWidth);
256
+ let elOffsetRect = el.getBoundingClientRect();
257
+
258
+ let scrollLeft = container.scrollLeft;
259
+ let scrollTop = container.scrollTop;
260
+
261
+ let scrolledX = bounding.left - scrollLeft;
262
+ let scrolledYTopEdge = bounding.top - scrollTop;
263
+ let scrolledYBottomEdge = bounding.top + elOffsetRect.height - scrollTop;
264
+
265
+ // Check for container and viewport for left
266
+ canAlign.spaceOnRight = !containerAllowsOverflow
267
+ ? containerWidth - (scrolledX + bounding.width)
268
+ : window.innerWidth - (elOffsetRect.left + bounding.width);
269
+ if (canAlign.spaceOnRight < 0) {
270
+ canAlign.left = false;
271
+ }
272
+
273
+ // Check for container and viewport for Right
274
+ canAlign.spaceOnLeft = !containerAllowsOverflow
275
+ ? scrolledX - bounding.width + elOffsetRect.width
276
+ : elOffsetRect.right - bounding.width;
277
+ if (canAlign.spaceOnLeft < 0) {
278
+ canAlign.right = false;
279
+ }
280
+
281
+ // Check for container and viewport for Top
282
+ canAlign.spaceOnBottom = !containerAllowsOverflow
283
+ ? containerHeight - (scrolledYTopEdge + bounding.height + offset)
284
+ : window.innerHeight - (elOffsetRect.top + bounding.height + offset);
285
+ if (canAlign.spaceOnBottom < 0) {
286
+ canAlign.top = false;
287
+ }
288
+
289
+ // Check for container and viewport for Bottom
290
+ canAlign.spaceOnTop = !containerAllowsOverflow
291
+ ? scrolledYBottomEdge - (bounding.height - offset)
292
+ : elOffsetRect.bottom - (bounding.height + offset);
293
+ if (canAlign.spaceOnTop < 0) {
294
+ canAlign.bottom = false;
295
+ }
296
+
297
+ return canAlign;
298
+ };
299
+
300
+ M.getOverflowParent = function(element) {
301
+ if (element == null) {
302
+ return null;
303
+ }
304
+
305
+ if (element === document.body || getComputedStyle(element).overflow !== 'visible') {
306
+ return element;
307
+ }
308
+
309
+ return M.getOverflowParent(element.parentElement);
310
+ };
311
+
312
+ /**
313
+ * Gets id of component from a trigger
314
+ * @param {Element} trigger trigger
315
+ * @returns {string}
316
+ */
317
+ M.getIdFromTrigger = function(trigger) {
318
+ let id = trigger.getAttribute('data-target');
319
+ if (!id) {
320
+ id = trigger.getAttribute('href');
321
+ if (id) {
322
+ id = id.slice(1);
323
+ } else {
324
+ id = '';
325
+ }
326
+ }
327
+ return id;
328
+ };
329
+
330
+ /**
331
+ * Multi browser support for document scroll top
332
+ * @returns {Number}
333
+ */
334
+ M.getDocumentScrollTop = function() {
335
+ return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
336
+ };
337
+
338
+ /**
339
+ * Multi browser support for document scroll left
340
+ * @returns {Number}
341
+ */
342
+ M.getDocumentScrollLeft = function() {
343
+ return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
344
+ };
345
+
346
+ /**
347
+ * @typedef {Object} Edges
348
+ * @property {Boolean} top If the top edge was exceeded
349
+ * @property {Boolean} right If the right edge was exceeded
350
+ * @property {Boolean} bottom If the bottom edge was exceeded
351
+ * @property {Boolean} left If the left edge was exceeded
352
+ */
353
+
354
+ /**
355
+ * @typedef {Object} Bounding
356
+ * @property {Number} left left offset coordinate
357
+ * @property {Number} top top offset coordinate
358
+ * @property {Number} width
359
+ * @property {Number} height
360
+ */
361
+
362
+ /**
363
+ * Get time in ms
364
+ * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
365
+ * @type {function}
366
+ * @return {number}
367
+ */
368
+ let getTime =
369
+ Date.now ||
370
+ function() {
371
+ return new Date().getTime();
372
+ };
373
+
374
+ /**
375
+ * Returns a function, that, when invoked, will only be triggered at most once
376
+ * during a given window of time. Normally, the throttled function will run
377
+ * as much as it can, without ever going more than once per `wait` duration;
378
+ * but if you'd like to disable the execution on the leading edge, pass
379
+ * `{leading: false}`. To disable execution on the trailing edge, ditto.
380
+ * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
381
+ * @param {function} func
382
+ * @param {number} wait
383
+ * @param {Object=} options
384
+ * @returns {Function}
385
+ */
386
+ M.throttle = function(func, wait, options) {
387
+ let context, args, result;
388
+ let timeout = null;
389
+ let previous = 0;
390
+ options || (options = {});
391
+ let later = function() {
392
+ previous = options.leading === false ? 0 : getTime();
393
+ timeout = null;
394
+ result = func.apply(context, args);
395
+ context = args = null;
396
+ };
397
+ return function() {
398
+ let now = getTime();
399
+ if (!previous && options.leading === false) previous = now;
400
+ let remaining = wait - (now - previous);
401
+ context = this;
402
+ args = arguments;
403
+ if (remaining <= 0) {
404
+ clearTimeout(timeout);
405
+ timeout = null;
406
+ previous = now;
407
+ result = func.apply(context, args);
408
+ context = args = null;
409
+ } else if (!timeout && options.trailing !== false) {
410
+ timeout = setTimeout(later, remaining);
411
+ }
412
+ return result;
413
+ };
414
+ };
415
+
416
+ /* Feature detection */
417
+ var passiveIfSupported = false;
418
+ try {
419
+ window.addEventListener(
420
+ 'test',
421
+ null,
422
+ Object.defineProperty({}, 'passive', {
423
+ get: function() {
424
+ passiveIfSupported = { passive: false };
425
+ }
426
+ })
427
+ );
428
+ } catch (err) {}