kmaterialize 2.0.0 → 2.3.3-1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +55 -91
  3. package/components/appbar/_navbar.old.scss +223 -0
  4. package/components/appbar/appbar.css +235 -0
  5. package/components/appbar/appbar.mjs +54 -0
  6. package/components/appbar/appbar.test.mjs +9 -0
  7. package/components/atomic/atomic.mjs +19 -0
  8. package/components/atomic/component.mjs +67 -0
  9. package/components/badge/_badges.scss +75 -0
  10. package/components/badge/badge.mjs +11 -0
  11. package/components/breadcrumb/_breadcrumb.scss +27 -0
  12. package/components/button/_buttons.scss +352 -0
  13. package/components/button/button.mjs +11 -0
  14. package/components/button/buttons.stories.ts +150 -0
  15. package/components/button/buttons.ts +282 -0
  16. package/components/button/examples.iso.js +18 -0
  17. package/components/button/fabSpec.js +65 -0
  18. package/components/button/test-button.mjs +16 -0
  19. package/components/card/_cards.scss +229 -0
  20. package/components/card/card.mjs +10 -0
  21. package/components/card/cards.ts +185 -0
  22. package/components/card/cardsSpec.js +269 -0
  23. package/components/carousel/_carousel.scss +93 -0
  24. package/components/carousel/_slider.scss +119 -0
  25. package/components/carousel/carousel.ts +693 -0
  26. package/components/carousel/carouselSpec.js +61 -0
  27. package/components/carousel/slider.ts +431 -0
  28. package/components/carousel/sliderSpec.js +99 -0
  29. package/components/checkbox/_checkboxes.scss +281 -0
  30. package/components/checkbox/checkbox.mdx +24 -0
  31. package/components/checkbox/checkbox.stories.ts +120 -0
  32. package/components/chip/chip.mjs +37 -0
  33. package/components/chip/chip.test.mjs +10 -0
  34. package/components/chip/chips.css +126 -0
  35. package/components/chip/chips.mdx +33 -0
  36. package/components/chip/chips.ts +440 -0
  37. package/components/chip/chipsSpec.js +165 -0
  38. package/components/chip/readme.md +323 -0
  39. package/components/collapsible/_collapsible.scss +82 -0
  40. package/components/collapsible/collapsible.ts +230 -0
  41. package/components/collapsible/collapsibleSpec.js +240 -0
  42. package/components/datepicker/_datepicker.scss +268 -0
  43. package/components/datepicker/datepicker.ts +1450 -0
  44. package/components/datepicker/datepickerSpec.js +162 -0
  45. package/components/dialog/_materialbox.scss +42 -0
  46. package/components/dialog/_modal.scss +79 -0
  47. package/components/dialog/materialbox.ts +446 -0
  48. package/components/dialog/materialboxSpec.js +37 -0
  49. package/components/dialog/modal.ts +111 -0
  50. package/components/dialog/modalSpec.js +83 -0
  51. package/components/dialog/readme.md +5 -0
  52. package/components/divider/readme.md +15 -0
  53. package/components/dropdown/_dropdown.scss +83 -0
  54. package/components/dropdown/dropdown.ts +653 -0
  55. package/components/dropdown/dropdownSpec.js +108 -0
  56. package/components/list/_collection.scss +114 -0
  57. package/components/list/_list.scss +6 -0
  58. package/components/list/list.mjs +58 -0
  59. package/components/list/list.test.mjs +16 -0
  60. package/components/loading/loading.mjs +26 -0
  61. package/components/loading/loading.test.mjs +10 -0
  62. package/components/navigation-bar/_old +582 -0
  63. package/components/navigation-bar/navigation-bar.mdx +20 -0
  64. package/components/navigation-bar/navigation-bar.stories.ts +39 -0
  65. package/components/navigation-drawer/_sidenav.scss +247 -0
  66. package/components/navigation-drawer/sidenav.ts +546 -0
  67. package/components/navigation-drawer/sidenavSpec.js +124 -0
  68. package/components/pagination/_pagination.scss +47 -0
  69. package/components/progress/_preloader.scss +416 -0
  70. package/components/radio-button/_radio-buttons.scss +112 -0
  71. package/components/radio-button/radio-buttons.mdx +28 -0
  72. package/components/radio-button/radio-buttons.stories.ts +51 -0
  73. package/components/search/autocomplete.ts +620 -0
  74. package/components/search/autocompleteSpec.js +321 -0
  75. package/components/slider/_range.scss +157 -0
  76. package/components/slider/range.ts +216 -0
  77. package/components/snackbar/_toast.scss +68 -0
  78. package/components/snackbar/toastSpec.js +132 -0
  79. package/components/snackbar/toasts.ts +312 -0
  80. package/components/switch/_switches.scss +121 -0
  81. package/components/tabs/_tabs.scss +171 -0
  82. package/components/tabs/tabs.mjs +31 -0
  83. package/components/tabs/tabs.ts +358 -0
  84. package/components/tabs/tabsSpec.js +180 -0
  85. package/components/textfield/_file-input.scss +41 -0
  86. package/components/textfield/_input-fields.scss +368 -0
  87. package/components/textfield/_select.scss +104 -0
  88. package/components/textfield/formfields.css +311 -0
  89. package/components/textfield/forms.ts +182 -0
  90. package/components/textfield/formsSpec.js +142 -0
  91. package/components/textfield/select.ts +472 -0
  92. package/components/textfield/selectSpec.js +390 -0
  93. package/components/textfield/textfield.mjs +29 -0
  94. package/components/textfield/textfield.test.mjs +10 -0
  95. package/components/timepicker/_timepicker.scss +362 -0
  96. package/components/timepicker/timepicker.ts +905 -0
  97. package/components/tooltip/_tooltip.scss +40 -0
  98. package/components/tooltip/tooltip.ts +380 -0
  99. package/components/tooltip/tooltipSpec.js +145 -0
  100. package/dist/css/materialize.colors.min.css +6 -0
  101. package/dist/css/materialize.css +7578 -6326
  102. package/dist/css/materialize.min.css +6 -13
  103. package/dist/css/materialize.min.css.map +1 -0
  104. package/dist/js/materialize.cjs.js +8410 -0
  105. package/dist/js/materialize.d.ts +2625 -0
  106. package/dist/js/materialize.js +8415 -12374
  107. package/dist/js/materialize.min.js +6 -6
  108. package/dist/js/materialize.mjs +8382 -0
  109. package/package.json +82 -47
  110. package/sass/_colors.scss +417 -0
  111. package/sass/_global.scss +490 -0
  112. package/sass/_grid.scss +172 -0
  113. package/sass/_table_of_contents.scss +28 -0
  114. package/sass/_tapTarget.scss +102 -0
  115. package/sass/_typography.scss +58 -0
  116. package/sass/_variables.scss +56 -0
  117. package/sass/materialize.scss +51 -0
  118. package/sass/mixins.module.scss +168 -0
  119. package/extras/noUiSlider/nouislider.css +0 -406
  120. package/extras/noUiSlider/nouislider.js +0 -2147
  121. package/extras/noUiSlider/nouislider.min.js +0 -1
  122. package/js/anime.min.js +0 -34
  123. package/js/autocomplete.js +0 -448
  124. package/js/buttons.js +0 -354
  125. package/js/cards.js +0 -40
  126. package/js/carousel.js +0 -717
  127. package/js/cash.js +0 -960
  128. package/js/characterCounter.js +0 -136
  129. package/js/chips.js +0 -481
  130. package/js/collapsible.js +0 -275
  131. package/js/component.js +0 -44
  132. package/js/datepicker.js +0 -975
  133. package/js/dropdown.js +0 -635
  134. package/js/forms.js +0 -275
  135. package/js/global.js +0 -444
  136. package/js/materialbox.js +0 -453
  137. package/js/modal.js +0 -382
  138. package/js/parallax.js +0 -138
  139. package/js/pushpin.js +0 -148
  140. package/js/range.js +0 -263
  141. package/js/scrollspy.js +0 -295
  142. package/js/select.js +0 -450
  143. package/js/sidenav.js +0 -580
  144. package/js/slider.js +0 -359
  145. package/js/tabs.js +0 -402
  146. package/js/tapTarget.js +0 -314
  147. package/js/timepicker.js +0 -647
  148. package/js/toasts.js +0 -310
  149. package/js/tooltip.js +0 -303
  150. package/js/waves.js +0 -335
package/js/toasts.js DELETED
@@ -1,310 +0,0 @@
1
- (function($, anim) {
2
- 'use strict';
3
-
4
- let _defaults = {
5
- html: '',
6
- displayLength: 4000,
7
- inDuration: 300,
8
- outDuration: 375,
9
- classes: '',
10
- completeCallback: null,
11
- activationPercent: 0.8
12
- };
13
-
14
- class Toast {
15
- constructor(options) {
16
- /**
17
- * Options for the toast
18
- * @member Toast#options
19
- */
20
- this.options = $.extend({}, Toast.defaults, options);
21
- this.message = this.options.html;
22
-
23
- /**
24
- * Describes current pan state toast
25
- * @type {Boolean}
26
- */
27
- this.panning = false;
28
-
29
- /**
30
- * Time remaining until toast is removed
31
- */
32
- this.timeRemaining = this.options.displayLength;
33
-
34
- if (Toast._toasts.length === 0) {
35
- Toast._createContainer();
36
- }
37
-
38
- // Create new toast
39
- Toast._toasts.push(this);
40
- let toastElement = this._createToast();
41
- toastElement.M_Toast = this;
42
- this.el = toastElement;
43
- this.$el = $(toastElement);
44
- this._animateIn();
45
- this._setTimer();
46
- }
47
-
48
- static get defaults() {
49
- return _defaults;
50
- }
51
-
52
- /**
53
- * Get Instance
54
- */
55
- static getInstance(el) {
56
- let domElem = !!el.jquery ? el[0] : el;
57
- return domElem.M_Toast;
58
- }
59
-
60
- /**
61
- * Append toast container and add event handlers
62
- */
63
- static _createContainer() {
64
- let container = document.createElement('div');
65
- container.setAttribute('id', 'toast-container');
66
-
67
- // Add event handler
68
- container.addEventListener('touchstart', Toast._onDragStart);
69
- container.addEventListener('touchmove', Toast._onDragMove);
70
- container.addEventListener('touchend', Toast._onDragEnd);
71
-
72
- container.addEventListener('mousedown', Toast._onDragStart);
73
- document.addEventListener('mousemove', Toast._onDragMove);
74
- document.addEventListener('mouseup', Toast._onDragEnd);
75
-
76
- document.body.appendChild(container);
77
- Toast._container = container;
78
- }
79
-
80
- /**
81
- * Remove toast container and event handlers
82
- */
83
- static _removeContainer() {
84
- // Add event handler
85
- document.removeEventListener('mousemove', Toast._onDragMove);
86
- document.removeEventListener('mouseup', Toast._onDragEnd);
87
-
88
- $(Toast._container).remove();
89
- Toast._container = null;
90
- }
91
-
92
- /**
93
- * Begin drag handler
94
- * @param {Event} e
95
- */
96
- static _onDragStart(e) {
97
- if (e.target && $(e.target).closest('.toast').length) {
98
- let $toast = $(e.target).closest('.toast');
99
- let toast = $toast[0].M_Toast;
100
- toast.panning = true;
101
- Toast._draggedToast = toast;
102
- toast.el.classList.add('panning');
103
- toast.el.style.transition = '';
104
- toast.startingXPos = Toast._xPos(e);
105
- toast.time = Date.now();
106
- toast.xPos = Toast._xPos(e);
107
- }
108
- }
109
-
110
- /**
111
- * Drag move handler
112
- * @param {Event} e
113
- */
114
- static _onDragMove(e) {
115
- if (!!Toast._draggedToast) {
116
- e.preventDefault();
117
- let toast = Toast._draggedToast;
118
- toast.deltaX = Math.abs(toast.xPos - Toast._xPos(e));
119
- toast.xPos = Toast._xPos(e);
120
- toast.velocityX = toast.deltaX / (Date.now() - toast.time);
121
- toast.time = Date.now();
122
-
123
- let totalDeltaX = toast.xPos - toast.startingXPos;
124
- let activationDistance = toast.el.offsetWidth * toast.options.activationPercent;
125
- toast.el.style.transform = `translateX(${totalDeltaX}px)`;
126
- toast.el.style.opacity = 1 - Math.abs(totalDeltaX / activationDistance);
127
- }
128
- }
129
-
130
- /**
131
- * End drag handler
132
- */
133
- static _onDragEnd() {
134
- if (!!Toast._draggedToast) {
135
- let toast = Toast._draggedToast;
136
- toast.panning = false;
137
- toast.el.classList.remove('panning');
138
-
139
- let totalDeltaX = toast.xPos - toast.startingXPos;
140
- let activationDistance = toast.el.offsetWidth * toast.options.activationPercent;
141
- let shouldBeDismissed = Math.abs(totalDeltaX) > activationDistance || toast.velocityX > 1;
142
-
143
- // Remove toast
144
- if (shouldBeDismissed) {
145
- toast.wasSwiped = true;
146
- toast.dismiss();
147
-
148
- // Animate toast back to original position
149
- } else {
150
- toast.el.style.transition = 'transform .2s, opacity .2s';
151
- toast.el.style.transform = '';
152
- toast.el.style.opacity = '';
153
- }
154
- Toast._draggedToast = null;
155
- }
156
- }
157
-
158
- /**
159
- * Get x position of mouse or touch event
160
- * @param {Event} e
161
- */
162
- static _xPos(e) {
163
- if (e.targetTouches && e.targetTouches.length >= 1) {
164
- return e.targetTouches[0].clientX;
165
- }
166
- // mouse event
167
- return e.clientX;
168
- }
169
-
170
- /**
171
- * Remove all toasts
172
- */
173
- static dismissAll() {
174
- for (let toastIndex in Toast._toasts) {
175
- Toast._toasts[toastIndex].dismiss();
176
- }
177
- }
178
-
179
- /**
180
- * Create toast and append it to toast container
181
- */
182
- _createToast() {
183
- let toast = document.createElement('div');
184
- toast.classList.add('toast');
185
-
186
- // Add custom classes onto toast
187
- if (!!this.options.classes.length) {
188
- $(toast).addClass(this.options.classes);
189
- }
190
-
191
- // Set content
192
- if (
193
- typeof HTMLElement === 'object'
194
- ? this.message instanceof HTMLElement
195
- : this.message &&
196
- typeof this.message === 'object' &&
197
- this.message !== null &&
198
- this.message.nodeType === 1 &&
199
- typeof this.message.nodeName === 'string'
200
- ) {
201
- toast.appendChild(this.message);
202
-
203
- // Check if it is jQuery object
204
- } else if (!!this.message.jquery) {
205
- $(toast).append(this.message[0]);
206
-
207
- // Insert as html;
208
- } else {
209
- toast.innerHTML = this.message;
210
- }
211
-
212
- // Append toasft
213
- Toast._container.appendChild(toast);
214
- return toast;
215
- }
216
-
217
- /**
218
- * Animate in toast
219
- */
220
- _animateIn() {
221
- // Animate toast in
222
- anim({
223
- targets: this.el,
224
- top: 0,
225
- opacity: 1,
226
- duration: this.options.inDuration,
227
- easing: 'easeOutCubic'
228
- });
229
- }
230
-
231
- /**
232
- * Create setInterval which automatically removes toast when timeRemaining >= 0
233
- * has been reached
234
- */
235
- _setTimer() {
236
- if (this.timeRemaining !== Infinity) {
237
- this.counterInterval = setInterval(() => {
238
- // If toast is not being dragged, decrease its time remaining
239
- if (!this.panning) {
240
- this.timeRemaining -= 20;
241
- }
242
-
243
- // Animate toast out
244
- if (this.timeRemaining <= 0) {
245
- this.dismiss();
246
- }
247
- }, 20);
248
- }
249
- }
250
-
251
- /**
252
- * Dismiss toast with animation
253
- */
254
- dismiss() {
255
- window.clearInterval(this.counterInterval);
256
- let activationDistance = this.el.offsetWidth * this.options.activationPercent;
257
-
258
- if (this.wasSwiped) {
259
- this.el.style.transition = 'transform .05s, opacity .05s';
260
- this.el.style.transform = `translateX(${activationDistance}px)`;
261
- this.el.style.opacity = 0;
262
- }
263
-
264
- anim({
265
- targets: this.el,
266
- opacity: 0,
267
- marginTop: -40,
268
- duration: this.options.outDuration,
269
- easing: 'easeOutExpo',
270
- complete: () => {
271
- // Call the optional callback
272
- if (typeof this.options.completeCallback === 'function') {
273
- this.options.completeCallback();
274
- }
275
- // Remove toast from DOM
276
- this.$el.remove();
277
- Toast._toasts.splice(Toast._toasts.indexOf(this), 1);
278
- if (Toast._toasts.length === 0) {
279
- Toast._removeContainer();
280
- }
281
- }
282
- });
283
- }
284
- }
285
-
286
- /**
287
- * @static
288
- * @memberof Toast
289
- * @type {Array.<Toast>}
290
- */
291
- Toast._toasts = [];
292
-
293
- /**
294
- * @static
295
- * @memberof Toast
296
- */
297
- Toast._container = null;
298
-
299
- /**
300
- * @static
301
- * @memberof Toast
302
- * @type {Toast}
303
- */
304
- Toast._draggedToast = null;
305
-
306
- M.Toast = Toast;
307
- M.toast = function(options) {
308
- return new Toast(options);
309
- };
310
- })(cash, M.anime);
package/js/tooltip.js DELETED
@@ -1,303 +0,0 @@
1
- (function($, anim) {
2
- 'use strict';
3
-
4
- let _defaults = {
5
- exitDelay: 200,
6
- enterDelay: 0,
7
- html: null,
8
- margin: 5,
9
- inDuration: 250,
10
- outDuration: 200,
11
- position: 'bottom',
12
- transitionMovement: 10
13
- };
14
-
15
- /**
16
- * @class
17
- *
18
- */
19
- class Tooltip extends Component {
20
- /**
21
- * Construct Tooltip instance
22
- * @constructor
23
- * @param {Element} el
24
- * @param {Object} options
25
- */
26
- constructor(el, options) {
27
- super(Tooltip, el, options);
28
-
29
- this.el.M_Tooltip = this;
30
- this.options = $.extend({}, Tooltip.defaults, options);
31
-
32
- this.isOpen = false;
33
- this.isHovered = false;
34
- this.isFocused = false;
35
- this._appendTooltipEl();
36
- this._setupEventHandlers();
37
- }
38
-
39
- static get defaults() {
40
- return _defaults;
41
- }
42
-
43
- static init(els, options) {
44
- return super.init(this, els, options);
45
- }
46
-
47
- /**
48
- * Get Instance
49
- */
50
- static getInstance(el) {
51
- let domElem = !!el.jquery ? el[0] : el;
52
- return domElem.M_Tooltip;
53
- }
54
-
55
- /**
56
- * Teardown component
57
- */
58
- destroy() {
59
- $(this.tooltipEl).remove();
60
- this._removeEventHandlers();
61
- this.el.M_Tooltip = undefined;
62
- }
63
-
64
- _appendTooltipEl() {
65
- let tooltipEl = document.createElement('div');
66
- tooltipEl.classList.add('material-tooltip');
67
- this.tooltipEl = tooltipEl;
68
-
69
- let tooltipContentEl = document.createElement('div');
70
- tooltipContentEl.classList.add('tooltip-content');
71
- tooltipContentEl.innerHTML = this.options.html;
72
- tooltipEl.appendChild(tooltipContentEl);
73
- document.body.appendChild(tooltipEl);
74
- }
75
-
76
- _updateTooltipContent() {
77
- this.tooltipEl.querySelector('.tooltip-content').innerHTML = this.options.html;
78
- }
79
-
80
- _setupEventHandlers() {
81
- this._handleMouseEnterBound = this._handleMouseEnter.bind(this);
82
- this._handleMouseLeaveBound = this._handleMouseLeave.bind(this);
83
- this._handleFocusBound = this._handleFocus.bind(this);
84
- this._handleBlurBound = this._handleBlur.bind(this);
85
- this.el.addEventListener('mouseenter', this._handleMouseEnterBound);
86
- this.el.addEventListener('mouseleave', this._handleMouseLeaveBound);
87
- this.el.addEventListener('focus', this._handleFocusBound, true);
88
- this.el.addEventListener('blur', this._handleBlurBound, true);
89
- }
90
-
91
- _removeEventHandlers() {
92
- this.el.removeEventListener('mouseenter', this._handleMouseEnterBound);
93
- this.el.removeEventListener('mouseleave', this._handleMouseLeaveBound);
94
- this.el.removeEventListener('focus', this._handleFocusBound, true);
95
- this.el.removeEventListener('blur', this._handleBlurBound, true);
96
- }
97
-
98
- open(isManual) {
99
- if (this.isOpen) {
100
- return;
101
- }
102
- isManual = isManual === undefined ? true : undefined; // Default value true
103
- this.isOpen = true;
104
- // Update tooltip content with HTML attribute options
105
- this.options = $.extend({}, this.options, this._getAttributeOptions());
106
- this._updateTooltipContent();
107
- this._setEnterDelayTimeout(isManual);
108
- }
109
-
110
- close() {
111
- if (!this.isOpen) {
112
- return;
113
- }
114
-
115
- this.isHovered = false;
116
- this.isFocused = false;
117
- this.isOpen = false;
118
- this._setExitDelayTimeout();
119
- }
120
-
121
- /**
122
- * Create timeout which delays when the tooltip closes
123
- */
124
- _setExitDelayTimeout() {
125
- clearTimeout(this._exitDelayTimeout);
126
-
127
- this._exitDelayTimeout = setTimeout(() => {
128
- if (this.isHovered || this.isFocused) {
129
- return;
130
- }
131
-
132
- this._animateOut();
133
- }, this.options.exitDelay);
134
- }
135
-
136
- /**
137
- * Create timeout which delays when the toast closes
138
- */
139
- _setEnterDelayTimeout(isManual) {
140
- clearTimeout(this._enterDelayTimeout);
141
-
142
- this._enterDelayTimeout = setTimeout(() => {
143
- if (!this.isHovered && !this.isFocused && !isManual) {
144
- return;
145
- }
146
-
147
- this._animateIn();
148
- }, this.options.enterDelay);
149
- }
150
-
151
- _positionTooltip() {
152
- let origin = this.el,
153
- tooltip = this.tooltipEl,
154
- originHeight = origin.offsetHeight,
155
- originWidth = origin.offsetWidth,
156
- tooltipHeight = tooltip.offsetHeight,
157
- tooltipWidth = tooltip.offsetWidth,
158
- newCoordinates,
159
- margin = this.options.margin,
160
- targetTop,
161
- targetLeft;
162
-
163
- (this.xMovement = 0), (this.yMovement = 0);
164
-
165
- targetTop = origin.getBoundingClientRect().top + M.getDocumentScrollTop();
166
- targetLeft = origin.getBoundingClientRect().left + M.getDocumentScrollLeft();
167
-
168
- if (this.options.position === 'top') {
169
- targetTop += -tooltipHeight - margin;
170
- targetLeft += originWidth / 2 - tooltipWidth / 2;
171
- this.yMovement = -this.options.transitionMovement;
172
- } else if (this.options.position === 'right') {
173
- targetTop += originHeight / 2 - tooltipHeight / 2;
174
- targetLeft += originWidth + margin;
175
- this.xMovement = this.options.transitionMovement;
176
- } else if (this.options.position === 'left') {
177
- targetTop += originHeight / 2 - tooltipHeight / 2;
178
- targetLeft += -tooltipWidth - margin;
179
- this.xMovement = -this.options.transitionMovement;
180
- } else {
181
- targetTop += originHeight + margin;
182
- targetLeft += originWidth / 2 - tooltipWidth / 2;
183
- this.yMovement = this.options.transitionMovement;
184
- }
185
-
186
- newCoordinates = this._repositionWithinScreen(
187
- targetLeft,
188
- targetTop,
189
- tooltipWidth,
190
- tooltipHeight
191
- );
192
- $(tooltip).css({
193
- top: newCoordinates.y + 'px',
194
- left: newCoordinates.x + 'px'
195
- });
196
- }
197
-
198
- _repositionWithinScreen(x, y, width, height) {
199
- let scrollLeft = M.getDocumentScrollLeft();
200
- let scrollTop = M.getDocumentScrollTop();
201
- let newX = x - scrollLeft;
202
- let newY = y - scrollTop;
203
-
204
- let bounding = {
205
- left: newX,
206
- top: newY,
207
- width: width,
208
- height: height
209
- };
210
-
211
- let offset = this.options.margin + this.options.transitionMovement;
212
- let edges = M.checkWithinContainer(document.body, bounding, offset);
213
-
214
- if (edges.left) {
215
- newX = offset;
216
- } else if (edges.right) {
217
- newX -= newX + width - window.innerWidth;
218
- }
219
-
220
- if (edges.top) {
221
- newY = offset;
222
- } else if (edges.bottom) {
223
- newY -= newY + height - window.innerHeight;
224
- }
225
-
226
- return {
227
- x: newX + scrollLeft,
228
- y: newY + scrollTop
229
- };
230
- }
231
-
232
- _animateIn() {
233
- this._positionTooltip();
234
- this.tooltipEl.style.visibility = 'visible';
235
- anim.remove(this.tooltipEl);
236
- anim({
237
- targets: this.tooltipEl,
238
- opacity: 1,
239
- translateX: this.xMovement,
240
- translateY: this.yMovement,
241
- duration: this.options.inDuration,
242
- easing: 'easeOutCubic'
243
- });
244
- }
245
-
246
- _animateOut() {
247
- anim.remove(this.tooltipEl);
248
- anim({
249
- targets: this.tooltipEl,
250
- opacity: 0,
251
- translateX: 0,
252
- translateY: 0,
253
- duration: this.options.outDuration,
254
- easing: 'easeOutCubic'
255
- });
256
- }
257
-
258
- _handleMouseEnter() {
259
- this.isHovered = true;
260
- this.isFocused = false; // Allows close of tooltip when opened by focus.
261
- this.open(false);
262
- }
263
-
264
- _handleMouseLeave() {
265
- this.isHovered = false;
266
- this.isFocused = false; // Allows close of tooltip when opened by focus.
267
- this.close();
268
- }
269
-
270
- _handleFocus() {
271
- if (M.tabPressed) {
272
- this.isFocused = true;
273
- this.open(false);
274
- }
275
- }
276
-
277
- _handleBlur() {
278
- this.isFocused = false;
279
- this.close();
280
- }
281
-
282
- _getAttributeOptions() {
283
- let attributeOptions = {};
284
- let tooltipTextOption = this.el.getAttribute('data-tooltip');
285
- let positionOption = this.el.getAttribute('data-position');
286
-
287
- if (tooltipTextOption) {
288
- attributeOptions.html = tooltipTextOption;
289
- }
290
-
291
- if (positionOption) {
292
- attributeOptions.position = positionOption;
293
- }
294
- return attributeOptions;
295
- }
296
- }
297
-
298
- M.Tooltip = Tooltip;
299
-
300
- if (M.jQueryLoaded) {
301
- M.initializeJqueryWrapper(Tooltip, 'tooltip', 'M_Tooltip');
302
- }
303
- })(cash, M.anime);