@materializecss/materialize 1.2.2 → 2.0.1-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.
Files changed (90) hide show
  1. package/Gruntfile.js +68 -313
  2. package/README.md +26 -14
  3. package/dist/css/materialize.css +1009 -1822
  4. package/dist/css/materialize.min.css +2 -8
  5. package/dist/js/materialize.js +8414 -12299
  6. package/dist/js/materialize.min.js +8968 -2
  7. package/dist/js/materialize.min.js.map +1 -0
  8. package/package.json +13 -9
  9. package/sass/components/_badges.scss +12 -2
  10. package/sass/components/_buttons.scss +16 -11
  11. package/sass/components/_cards.scss +14 -9
  12. package/sass/components/_carousel.scss +5 -2
  13. package/sass/components/_chips.scss +3 -3
  14. package/sass/components/_collapsible.scss +22 -8
  15. package/sass/components/_collection.scss +14 -6
  16. package/sass/components/_datepicker.scss +30 -11
  17. package/sass/components/_dropdown.scss +6 -4
  18. package/sass/components/_global.scss +132 -111
  19. package/sass/components/_grid.scss +119 -98
  20. package/sass/components/_modal.scss +3 -3
  21. package/sass/components/_navbar.scss +31 -17
  22. package/sass/components/_normalize.scss +26 -124
  23. package/sass/components/_sidenav.scss +21 -20
  24. package/sass/components/_slider.scss +27 -7
  25. package/sass/components/_table_of_contents.scss +12 -12
  26. package/sass/components/_tabs.scss +47 -16
  27. package/sass/components/_tapTarget.scss +6 -6
  28. package/sass/components/_theme_variables.scss +98 -0
  29. package/sass/components/_timepicker.scss +54 -46
  30. package/sass/components/_toast.scss +3 -3
  31. package/sass/components/_tooltip.scss +4 -5
  32. package/sass/components/_typography.scss +1 -1
  33. package/sass/components/_variables.scss +185 -120
  34. package/sass/components/forms/_checkboxes.scss +9 -9
  35. package/sass/components/forms/_file-input.scss +9 -7
  36. package/sass/components/forms/_input-fields.scss +173 -234
  37. package/sass/components/forms/_radio-buttons.scss +1 -1
  38. package/sass/components/forms/_range.scss +11 -11
  39. package/sass/components/forms/_select.scss +29 -19
  40. package/sass/components/forms/_switches.scss +22 -18
  41. package/sass/materialize.scss +1 -1
  42. package/src/autocomplete.ts +459 -0
  43. package/src/bounding.ts +6 -0
  44. package/{js/buttons.js → src/buttons.ts} +103 -162
  45. package/src/cards.ts +54 -0
  46. package/{js/carousel.js → src/carousel.ts} +137 -262
  47. package/src/characterCounter.ts +88 -0
  48. package/src/chips.ts +350 -0
  49. package/src/collapsible.ts +184 -0
  50. package/{js/component.js → src/component.ts} +6 -19
  51. package/{js/datepicker.js → src/datepicker.ts} +213 -299
  52. package/{js/dropdown.js → src/dropdown.ts} +140 -254
  53. package/src/edges.ts +6 -0
  54. package/src/forms.ts +120 -0
  55. package/src/global.ts +385 -0
  56. package/src/materialbox.ts +348 -0
  57. package/src/modal.ts +256 -0
  58. package/{js/parallax.js → src/parallax.ts} +47 -60
  59. package/{js/pushpin.js → src/pushpin.ts} +19 -47
  60. package/{js/range.js → src/range.ts} +58 -139
  61. package/{js/scrollspy.js → src/scrollspy.ts} +81 -153
  62. package/src/select.ts +448 -0
  63. package/{js/sidenav.js → src/sidenav.ts} +96 -202
  64. package/src/slider.ts +415 -0
  65. package/src/tabs.ts +293 -0
  66. package/src/tapTarget.ts +240 -0
  67. package/{js/timepicker.js → src/timepicker.ts} +268 -272
  68. package/{js/toasts.js → src/toasts.ts} +75 -134
  69. package/{js/tooltip.js → src/tooltip.ts} +59 -96
  70. package/src/waves.ts +70 -0
  71. package/extras/noUiSlider/nouislider.css +0 -404
  72. package/extras/noUiSlider/nouislider.js +0 -2147
  73. package/extras/noUiSlider/nouislider.min.js +0 -1
  74. package/js/anime.min.js +0 -34
  75. package/js/autocomplete.js +0 -479
  76. package/js/cards.js +0 -40
  77. package/js/cash.js +0 -960
  78. package/js/characterCounter.js +0 -136
  79. package/js/chips.js +0 -486
  80. package/js/collapsible.js +0 -275
  81. package/js/forms.js +0 -285
  82. package/js/global.js +0 -428
  83. package/js/materialbox.js +0 -453
  84. package/js/modal.js +0 -382
  85. package/js/select.js +0 -391
  86. package/js/slider.js +0 -497
  87. package/js/tabs.js +0 -402
  88. package/js/tapTarget.js +0 -315
  89. package/js/waves.js +0 -615
  90. package/sass/components/_waves.scss +0 -187
package/js/tabs.js DELETED
@@ -1,402 +0,0 @@
1
- (function($, anim) {
2
- 'use strict';
3
-
4
- let _defaults = {
5
- duration: 300,
6
- onShow: null,
7
- swipeable: false,
8
- responsiveThreshold: Infinity // breakpoint for swipeable
9
- };
10
-
11
- /**
12
- * @class
13
- *
14
- */
15
- class Tabs extends Component {
16
- /**
17
- * Construct Tabs instance
18
- * @constructor
19
- * @param {Element} el
20
- * @param {Object} options
21
- */
22
- constructor(el, options) {
23
- super(Tabs, el, options);
24
-
25
- this.el.M_Tabs = this;
26
-
27
- /**
28
- * Options for the Tabs
29
- * @member Tabs#options
30
- * @prop {Number} duration
31
- * @prop {Function} onShow
32
- * @prop {Boolean} swipeable
33
- * @prop {Number} responsiveThreshold
34
- */
35
- this.options = $.extend({}, Tabs.defaults, options);
36
-
37
- // Setup
38
- this.$tabLinks = this.$el.children('li.tab').children('a');
39
- this.index = 0;
40
- this._setupActiveTabLink();
41
-
42
- // Setup tabs content
43
- if (this.options.swipeable) {
44
- this._setupSwipeableTabs();
45
- } else {
46
- this._setupNormalTabs();
47
- }
48
-
49
- // Setup tabs indicator after content to ensure accurate widths
50
- this._setTabsAndTabWidth();
51
- this._createIndicator();
52
-
53
- this._setupEventHandlers();
54
- }
55
-
56
- static get defaults() {
57
- return _defaults;
58
- }
59
-
60
- static init(els, options) {
61
- return super.init(this, els, options);
62
- }
63
-
64
- /**
65
- * Get Instance
66
- */
67
- static getInstance(el) {
68
- let domElem = !!el.jquery ? el[0] : el;
69
- return domElem.M_Tabs;
70
- }
71
-
72
- /**
73
- * Teardown component
74
- */
75
- destroy() {
76
- this._removeEventHandlers();
77
- this._indicator.parentNode.removeChild(this._indicator);
78
-
79
- if (this.options.swipeable) {
80
- this._teardownSwipeableTabs();
81
- } else {
82
- this._teardownNormalTabs();
83
- }
84
-
85
- this.$el[0].M_Tabs = undefined;
86
- }
87
-
88
- /**
89
- * Setup Event Handlers
90
- */
91
- _setupEventHandlers() {
92
- this._handleWindowResizeBound = this._handleWindowResize.bind(this);
93
- window.addEventListener('resize', this._handleWindowResizeBound);
94
-
95
- this._handleTabClickBound = this._handleTabClick.bind(this);
96
- this.el.addEventListener('click', this._handleTabClickBound);
97
- }
98
-
99
- /**
100
- * Remove Event Handlers
101
- */
102
- _removeEventHandlers() {
103
- window.removeEventListener('resize', this._handleWindowResizeBound);
104
- this.el.removeEventListener('click', this._handleTabClickBound);
105
- }
106
-
107
- /**
108
- * Handle window Resize
109
- */
110
- _handleWindowResize() {
111
- this._setTabsAndTabWidth();
112
-
113
- if (this.tabWidth !== 0 && this.tabsWidth !== 0) {
114
- this._indicator.style.left = this._calcLeftPos(this.$activeTabLink) + 'px';
115
- this._indicator.style.right = this._calcRightPos(this.$activeTabLink) + 'px';
116
- }
117
- }
118
-
119
- /**
120
- * Handle tab click
121
- * @param {Event} e
122
- */
123
- _handleTabClick(e) {
124
- let tab = $(e.target).closest('li.tab');
125
- let tabLink = $(e.target).closest('a');
126
-
127
- // Handle click on tab link only
128
- if (!tabLink.length || !tabLink.parent().hasClass('tab')) {
129
- return;
130
- }
131
-
132
- if (tab.hasClass('disabled')) {
133
- e.preventDefault();
134
- return;
135
- }
136
-
137
- // Act as regular link if target attribute is specified.
138
- if (!!tabLink.attr('target')) {
139
- return;
140
- }
141
-
142
- // Make the old tab inactive.
143
- this.$activeTabLink.removeClass('active');
144
- let $oldContent = this.$content;
145
-
146
- // Update the variables with the new link and content
147
- this.$activeTabLink = tabLink;
148
- this.$content = $(M.escapeHash(tabLink[0].hash));
149
- this.$tabLinks = this.$el.children('li.tab').children('a');
150
-
151
- // Make the tab active.
152
- this.$activeTabLink.addClass('active');
153
- let prevIndex = this.index;
154
- this.index = Math.max(this.$tabLinks.index(tabLink), 0);
155
-
156
- // Swap content
157
- if (this.options.swipeable) {
158
- if (this._tabsCarousel) {
159
- this._tabsCarousel.set(this.index, () => {
160
- if (typeof this.options.onShow === 'function') {
161
- this.options.onShow.call(this, this.$content[0]);
162
- }
163
- });
164
- }
165
- } else {
166
- if (this.$content.length) {
167
- this.$content[0].style.display = 'block';
168
- this.$content.addClass('active');
169
- if (typeof this.options.onShow === 'function') {
170
- this.options.onShow.call(this, this.$content[0]);
171
- }
172
-
173
- if ($oldContent.length && !$oldContent.is(this.$content)) {
174
- $oldContent[0].style.display = 'none';
175
- $oldContent.removeClass('active');
176
- }
177
- }
178
- }
179
-
180
- // Update widths after content is swapped (scrollbar bugfix)
181
- this._setTabsAndTabWidth();
182
-
183
- // Update indicator
184
- this._animateIndicator(prevIndex);
185
-
186
- // Prevent the anchor's default click action
187
- e.preventDefault();
188
- }
189
-
190
- /**
191
- * Generate elements for tab indicator.
192
- */
193
- _createIndicator() {
194
- let indicator = document.createElement('li');
195
- indicator.classList.add('indicator');
196
-
197
- this.el.appendChild(indicator);
198
- this._indicator = indicator;
199
-
200
- setTimeout(() => {
201
- this._indicator.style.left = this._calcLeftPos(this.$activeTabLink) + 'px';
202
- this._indicator.style.right = this._calcRightPos(this.$activeTabLink) + 'px';
203
- }, 0);
204
- }
205
-
206
- /**
207
- * Setup first active tab link.
208
- */
209
- _setupActiveTabLink() {
210
- // If the location.hash matches one of the links, use that as the active tab.
211
- this.$activeTabLink = $(this.$tabLinks.filter('[href="' + location.hash + '"]'));
212
-
213
- // If no match is found, use the first link or any with class 'active' as the initial active tab.
214
- if (this.$activeTabLink.length === 0) {
215
- this.$activeTabLink = this.$el
216
- .children('li.tab')
217
- .children('a.active')
218
- .first();
219
- }
220
- if (this.$activeTabLink.length === 0) {
221
- this.$activeTabLink = this.$el
222
- .children('li.tab')
223
- .children('a')
224
- .first();
225
- }
226
-
227
- this.$tabLinks.removeClass('active');
228
- this.$activeTabLink[0].classList.add('active');
229
-
230
- this.index = Math.max(this.$tabLinks.index(this.$activeTabLink), 0);
231
-
232
- if (this.$activeTabLink.length) {
233
- this.$content = $(M.escapeHash(this.$activeTabLink[0].hash));
234
- this.$content.addClass('active');
235
- }
236
- }
237
-
238
- /**
239
- * Setup swipeable tabs
240
- */
241
- _setupSwipeableTabs() {
242
- // Change swipeable according to responsive threshold
243
- if (window.innerWidth > this.options.responsiveThreshold) {
244
- this.options.swipeable = false;
245
- }
246
-
247
- let $tabsContent = $();
248
- this.$tabLinks.each((link) => {
249
- let $currContent = $(M.escapeHash(link.hash));
250
- $currContent.addClass('carousel-item');
251
- $tabsContent = $tabsContent.add($currContent);
252
- });
253
-
254
- let $tabsWrapper = $('<div class="tabs-content carousel carousel-slider"></div>');
255
- $tabsContent.first().before($tabsWrapper);
256
- $tabsWrapper.append($tabsContent);
257
- $tabsContent[0].style.display = '';
258
-
259
- // Keep active tab index to set initial carousel slide
260
- let activeTabIndex = this.$activeTabLink.closest('.tab').index();
261
-
262
- this._tabsCarousel = M.Carousel.init($tabsWrapper[0], {
263
- fullWidth: true,
264
- noWrap: true,
265
- onCycleTo: (item) => {
266
- let prevIndex = this.index;
267
- this.index = $(item).index();
268
- this.$activeTabLink.removeClass('active');
269
- this.$activeTabLink = this.$tabLinks.eq(this.index);
270
- this.$activeTabLink.addClass('active');
271
- this._animateIndicator(prevIndex);
272
- if (typeof this.options.onShow === 'function') {
273
- this.options.onShow.call(this, this.$content[0]);
274
- }
275
- }
276
- });
277
-
278
- // Set initial carousel slide to active tab
279
- this._tabsCarousel.set(activeTabIndex);
280
- }
281
-
282
- /**
283
- * Teardown normal tabs.
284
- */
285
- _teardownSwipeableTabs() {
286
- let $tabsWrapper = this._tabsCarousel.$el;
287
- this._tabsCarousel.destroy();
288
-
289
- // Unwrap
290
- $tabsWrapper.after($tabsWrapper.children());
291
- $tabsWrapper.remove();
292
- }
293
-
294
- /**
295
- * Setup normal tabs.
296
- */
297
- _setupNormalTabs() {
298
- // Hide Tabs Content
299
- this.$tabLinks.not(this.$activeTabLink).each((link) => {
300
- if (!!link.hash) {
301
- let $currContent = $(M.escapeHash(link.hash));
302
- if ($currContent.length) {
303
- $currContent[0].style.display = 'none';
304
- }
305
- }
306
- });
307
- }
308
-
309
- /**
310
- * Teardown normal tabs.
311
- */
312
- _teardownNormalTabs() {
313
- // show Tabs Content
314
- this.$tabLinks.each((link) => {
315
- if (!!link.hash) {
316
- let $currContent = $(M.escapeHash(link.hash));
317
- if ($currContent.length) {
318
- $currContent[0].style.display = '';
319
- }
320
- }
321
- });
322
- }
323
-
324
- /**
325
- * set tabs and tab width
326
- */
327
- _setTabsAndTabWidth() {
328
- this.tabsWidth = this.$el.width();
329
- this.tabWidth = Math.max(this.tabsWidth, this.el.scrollWidth) / this.$tabLinks.length;
330
- }
331
-
332
- /**
333
- * Finds right attribute for indicator based on active tab.
334
- * @param {cash} el
335
- */
336
- _calcRightPos(el) {
337
- return Math.ceil(this.tabsWidth - el.position().left - el[0].getBoundingClientRect().width);
338
- }
339
-
340
- /**
341
- * Finds left attribute for indicator based on active tab.
342
- * @param {cash} el
343
- */
344
- _calcLeftPos(el) {
345
- return Math.floor(el.position().left);
346
- }
347
-
348
- updateTabIndicator() {
349
- this._setTabsAndTabWidth();
350
- this._animateIndicator(this.index);
351
- }
352
-
353
- /**
354
- * Animates Indicator to active tab.
355
- * @param {Number} prevIndex
356
- */
357
- _animateIndicator(prevIndex) {
358
- let leftDelay = 0,
359
- rightDelay = 0;
360
-
361
- if (this.index - prevIndex >= 0) {
362
- leftDelay = 90;
363
- } else {
364
- rightDelay = 90;
365
- }
366
-
367
- // Animate
368
- let animOptions = {
369
- targets: this._indicator,
370
- left: {
371
- value: this._calcLeftPos(this.$activeTabLink),
372
- delay: leftDelay
373
- },
374
- right: {
375
- value: this._calcRightPos(this.$activeTabLink),
376
- delay: rightDelay
377
- },
378
- duration: this.options.duration,
379
- easing: 'easeOutQuad'
380
- };
381
- anim.remove(this._indicator);
382
- anim(animOptions);
383
- }
384
-
385
- /**
386
- * Select tab.
387
- * @param {String} tabId
388
- */
389
- select(tabId) {
390
- let tab = this.$tabLinks.filter('[href="#' + tabId + '"]');
391
- if (tab.length) {
392
- tab.trigger('click');
393
- }
394
- }
395
- }
396
-
397
- M.Tabs = Tabs;
398
-
399
- if (M.jQueryLoaded) {
400
- M.initializeJqueryWrapper(Tabs, 'tabs', 'M_Tabs');
401
- }
402
- })(cash, M.anime);
package/js/tapTarget.js DELETED
@@ -1,315 +0,0 @@
1
- (function($) {
2
- 'use strict';
3
-
4
- let _defaults = {
5
- onOpen: undefined,
6
- onClose: undefined
7
- };
8
-
9
- /**
10
- * @class
11
- *
12
- */
13
- class TapTarget extends Component {
14
- /**
15
- * Construct TapTarget instance
16
- * @constructor
17
- * @param {Element} el
18
- * @param {Object} options
19
- */
20
- constructor(el, options) {
21
- super(TapTarget, el, options);
22
-
23
- this.el.M_TapTarget = this;
24
-
25
- /**
26
- * Options for the select
27
- * @member TapTarget#options
28
- * @prop {Function} onOpen - Callback function called when feature discovery is opened
29
- * @prop {Function} onClose - Callback function called when feature discovery is closed
30
- */
31
- this.options = $.extend({}, TapTarget.defaults, options);
32
-
33
- this.isOpen = false;
34
-
35
- // setup
36
- this.$origin = $('#' + this.$el.attr('data-target'));
37
- this._setup();
38
-
39
- this._calculatePositioning();
40
- this._setupEventHandlers();
41
- }
42
-
43
- static get defaults() {
44
- return _defaults;
45
- }
46
-
47
- static init(els, options) {
48
- return super.init(this, els, options);
49
- }
50
-
51
- /**
52
- * Get Instance
53
- */
54
- static getInstance(el) {
55
- let domElem = !!el.jquery ? el[0] : el;
56
- return domElem.M_TapTarget;
57
- }
58
-
59
- /**
60
- * Teardown component
61
- */
62
- destroy() {
63
- this._removeEventHandlers();
64
- this.el.TapTarget = undefined;
65
- }
66
-
67
- /**
68
- * Setup Event Handlers
69
- */
70
- _setupEventHandlers() {
71
- this._handleDocumentClickBound = this._handleDocumentClick.bind(this);
72
- this._handleTargetClickBound = this._handleTargetClick.bind(this);
73
- this._handleOriginClickBound = this._handleOriginClick.bind(this);
74
-
75
- this.el.addEventListener('click', this._handleTargetClickBound);
76
- this.originEl.addEventListener('click', this._handleOriginClickBound);
77
-
78
- // Resize
79
- let throttledResize = M.throttle(this._handleResize, 200);
80
- this._handleThrottledResizeBound = throttledResize.bind(this);
81
-
82
- window.addEventListener('resize', this._handleThrottledResizeBound);
83
- }
84
-
85
- /**
86
- * Remove Event Handlers
87
- */
88
- _removeEventHandlers() {
89
- this.el.removeEventListener('click', this._handleTargetClickBound);
90
- this.originEl.removeEventListener('click', this._handleOriginClickBound);
91
- window.removeEventListener('resize', this._handleThrottledResizeBound);
92
- }
93
-
94
- /**
95
- * Handle Target Click
96
- * @param {Event} e
97
- */
98
- _handleTargetClick(e) {
99
- this.open();
100
- }
101
-
102
- /**
103
- * Handle Origin Click
104
- * @param {Event} e
105
- */
106
- _handleOriginClick(e) {
107
- this.close();
108
- }
109
-
110
- /**
111
- * Handle Resize
112
- * @param {Event} e
113
- */
114
- _handleResize(e) {
115
- this._calculatePositioning();
116
- }
117
-
118
- /**
119
- * Handle Resize
120
- * @param {Event} e
121
- */
122
- _handleDocumentClick(e) {
123
- if (!$(e.target).closest('.tap-target-wrapper').length) {
124
- this.close();
125
- e.preventDefault();
126
- e.stopPropagation();
127
- }
128
- }
129
-
130
- /**
131
- * Setup Tap Target
132
- */
133
- _setup() {
134
- // Creating tap target
135
- this.wrapper = this.$el.parent()[0];
136
- this.waveEl = $(this.wrapper).find('.tap-target-wave')[0];
137
- this.originEl = $(this.wrapper).find('.tap-target-origin')[0];
138
- this.contentEl = this.$el.find('.tap-target-content')[0];
139
-
140
- // Creating wrapper
141
- if (!$(this.wrapper).hasClass('.tap-target-wrapper')) {
142
- this.wrapper = document.createElement('div');
143
- this.wrapper.classList.add('tap-target-wrapper');
144
- this.$el.before($(this.wrapper));
145
- this.wrapper.append(this.el);
146
- }
147
-
148
- // Creating content
149
- if (!this.contentEl) {
150
- this.contentEl = document.createElement('div');
151
- this.contentEl.classList.add('tap-target-content');
152
- this.$el.append(this.contentEl);
153
- }
154
-
155
- // Creating foreground wave
156
- if (!this.waveEl) {
157
- this.waveEl = document.createElement('div');
158
- this.waveEl.classList.add('tap-target-wave');
159
-
160
- // Creating origin
161
- if (!this.originEl) {
162
- this.originEl = this.$origin.clone(true, true);
163
- this.originEl.addClass('tap-target-origin');
164
- this.originEl.removeAttr('id');
165
- this.originEl.removeAttr('style');
166
- this.originEl = this.originEl[0];
167
- this.waveEl.append(this.originEl);
168
- }
169
-
170
- this.wrapper.append(this.waveEl);
171
- }
172
- }
173
-
174
- /**
175
- * Calculate positioning
176
- */
177
- _calculatePositioning() {
178
- // Element or parent is fixed position?
179
- let isFixed = this.$origin.css('position') === 'fixed';
180
- if (!isFixed) {
181
- let parents = this.$origin.parents();
182
- for (let i = 0; i < parents.length; i++) {
183
- isFixed = $(parents[i]).css('position') == 'fixed';
184
- if (isFixed) {
185
- break;
186
- }
187
- }
188
- }
189
-
190
- // Calculating origin
191
- let originWidth = this.$origin.outerWidth();
192
- let originHeight = this.$origin.outerHeight();
193
- let originTop = isFixed
194
- ? this.$origin.offset().top - M.getDocumentScrollTop()
195
- : this.$origin.offset().top;
196
- let originLeft = isFixed
197
- ? this.$origin.offset().left - M.getDocumentScrollLeft()
198
- : this.$origin.offset().left;
199
-
200
- // Calculating screen
201
- let windowWidth = window.innerWidth;
202
- let windowHeight = window.innerHeight;
203
- let scrollBarWidth = windowWidth - document.documentElement.clientWidth;
204
- let centerX = windowWidth / 2;
205
- let centerY = windowHeight / 2;
206
- let isLeft = originLeft <= centerX;
207
- let isRight = originLeft > centerX;
208
- let isTop = originTop <= centerY;
209
- let isBottom = originTop > centerY;
210
- let isCenterX = originLeft >= windowWidth * 0.25 && originLeft <= windowWidth * 0.75;
211
-
212
- // Calculating tap target
213
- let tapTargetWidth = this.$el.outerWidth();
214
- let tapTargetHeight = this.$el.outerHeight();
215
- let tapTargetTop = originTop + originHeight / 2 - tapTargetHeight / 2;
216
- let tapTargetLeft = originLeft + originWidth / 2 - tapTargetWidth / 2;
217
- let tapTargetPosition = isFixed ? 'fixed' : 'absolute';
218
-
219
- // Calculating content
220
- let tapTargetTextWidth = isCenterX ? tapTargetWidth : tapTargetWidth / 2 + originWidth;
221
- let tapTargetTextHeight = tapTargetHeight / 2;
222
- let tapTargetTextTop = isTop ? tapTargetHeight / 2 : 0;
223
- let tapTargetTextBottom = 0;
224
- let tapTargetTextLeft = isLeft && !isCenterX ? tapTargetWidth / 2 - originWidth : 0;
225
- let tapTargetTextRight = 0;
226
- let tapTargetTextPadding = originWidth;
227
- let tapTargetTextAlign = isBottom ? 'bottom' : 'top';
228
-
229
- // Calculating wave
230
- let tapTargetWaveWidth = originWidth > originHeight ? originWidth * 2 : originWidth * 2;
231
- let tapTargetWaveHeight = tapTargetWaveWidth;
232
- let tapTargetWaveTop = tapTargetHeight / 2 - tapTargetWaveHeight / 2;
233
- let tapTargetWaveLeft = tapTargetWidth / 2 - tapTargetWaveWidth / 2;
234
-
235
- // Setting tap target
236
- let tapTargetWrapperCssObj = {};
237
- tapTargetWrapperCssObj.top = isTop ? tapTargetTop + 'px' : '';
238
- tapTargetWrapperCssObj.right = isRight
239
- ? windowWidth - tapTargetLeft - tapTargetWidth - scrollBarWidth + 'px'
240
- : '';
241
- tapTargetWrapperCssObj.bottom = isBottom
242
- ? windowHeight - tapTargetTop - tapTargetHeight + 'px'
243
- : '';
244
- tapTargetWrapperCssObj.left = isLeft ? tapTargetLeft + 'px' : '';
245
- tapTargetWrapperCssObj.position = tapTargetPosition;
246
- $(this.wrapper).css(tapTargetWrapperCssObj);
247
-
248
- // Setting content
249
- $(this.contentEl).css({
250
- width: tapTargetTextWidth + 'px',
251
- height: tapTargetTextHeight + 'px',
252
- top: tapTargetTextTop + 'px',
253
- right: tapTargetTextRight + 'px',
254
- bottom: tapTargetTextBottom + 'px',
255
- left: tapTargetTextLeft + 'px',
256
- padding: tapTargetTextPadding + 'px',
257
- verticalAlign: tapTargetTextAlign
258
- });
259
-
260
- // Setting wave
261
- $(this.waveEl).css({
262
- top: tapTargetWaveTop + 'px',
263
- left: tapTargetWaveLeft + 'px',
264
- width: tapTargetWaveWidth + 'px',
265
- height: tapTargetWaveHeight + 'px'
266
- });
267
- }
268
-
269
- /**
270
- * Open TapTarget
271
- */
272
- open() {
273
- if (this.isOpen) {
274
- return;
275
- }
276
-
277
- // onOpen callback
278
- if (typeof this.options.onOpen === 'function') {
279
- this.options.onOpen.call(this, this.$origin[0]);
280
- }
281
-
282
- this.isOpen = true;
283
- this.wrapper.classList.add('open');
284
-
285
- document.body.addEventListener('click', this._handleDocumentClickBound, true);
286
- document.body.addEventListener('touchend', this._handleDocumentClickBound);
287
- }
288
-
289
- /**
290
- * Close Tap Target
291
- */
292
- close() {
293
- if (!this.isOpen) {
294
- return;
295
- }
296
-
297
- // onClose callback
298
- if (typeof this.options.onClose === 'function') {
299
- this.options.onClose.call(this, this.$origin[0]);
300
- }
301
-
302
- this.isOpen = false;
303
- this.wrapper.classList.remove('open');
304
-
305
- document.body.removeEventListener('click', this._handleDocumentClickBound, true);
306
- document.body.removeEventListener('touchend', this._handleDocumentClickBound);
307
- }
308
- }
309
-
310
- M.TapTarget = TapTarget;
311
-
312
- if (M.jQueryLoaded) {
313
- M.initializeJqueryWrapper(TapTarget, 'tapTarget', 'M_TapTarget');
314
- }
315
- })(cash);