@materializecss/materialize 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/Gruntfile.js +38 -24
  2. package/LICENSE +21 -21
  3. package/README.md +91 -97
  4. package/dist/css/materialize.css +8608 -8631
  5. package/dist/css/materialize.min.css +12 -12
  6. package/dist/js/materialize.js +12816 -12669
  7. package/dist/js/materialize.min.js +6 -6
  8. package/extras/noUiSlider/nouislider.css +404 -406
  9. package/extras/noUiSlider/nouislider.js +2147 -2147
  10. package/extras/noUiSlider/nouislider.min.js +0 -0
  11. package/js/anime.min.js +34 -34
  12. package/js/autocomplete.js +479 -479
  13. package/js/buttons.js +354 -354
  14. package/js/cards.js +40 -40
  15. package/js/carousel.js +732 -732
  16. package/js/cash.js +960 -960
  17. package/js/characterCounter.js +136 -136
  18. package/js/chips.js +486 -486
  19. package/js/collapsible.js +275 -275
  20. package/js/component.js +44 -44
  21. package/js/datepicker.js +983 -983
  22. package/js/dropdown.js +669 -669
  23. package/js/forms.js +285 -275
  24. package/js/global.js +428 -424
  25. package/js/materialbox.js +453 -453
  26. package/js/modal.js +382 -382
  27. package/js/parallax.js +138 -138
  28. package/js/pushpin.js +148 -148
  29. package/js/range.js +263 -263
  30. package/js/scrollspy.js +295 -295
  31. package/js/select.js +391 -310
  32. package/js/sidenav.js +583 -583
  33. package/js/slider.js +359 -359
  34. package/js/tabs.js +402 -402
  35. package/js/tapTarget.js +315 -315
  36. package/js/timepicker.js +712 -648
  37. package/js/toasts.js +325 -322
  38. package/js/tooltip.js +320 -320
  39. package/js/waves.js +614 -614
  40. package/package.json +87 -82
  41. package/sass/_style.scss +929 -929
  42. package/sass/components/_badges.scss +55 -55
  43. package/sass/components/_buttons.scss +322 -322
  44. package/sass/components/_cards.scss +195 -195
  45. package/sass/components/_carousel.scss +90 -90
  46. package/sass/components/_chips.scss +96 -96
  47. package/sass/components/_collapsible.scss +91 -91
  48. package/sass/components/_collection.scss +106 -106
  49. package/sass/components/_color-classes.scss +32 -32
  50. package/sass/components/_color-variables.scss +370 -370
  51. package/sass/components/_datepicker.scss +191 -191
  52. package/sass/components/_dropdown.scss +84 -84
  53. package/sass/components/_global.scss +646 -642
  54. package/sass/components/_grid.scss +158 -158
  55. package/sass/components/_icons-material-design.scss +5 -5
  56. package/sass/components/_materialbox.scss +42 -42
  57. package/sass/components/_modal.scss +97 -97
  58. package/sass/components/_navbar.scss +208 -208
  59. package/sass/components/_normalize.scss +447 -447
  60. package/sass/components/_preloader.scss +334 -334
  61. package/sass/components/_pulse.scss +34 -34
  62. package/sass/components/_sidenav.scss +214 -214
  63. package/sass/components/_slider.scss +91 -91
  64. package/sass/components/_table_of_contents.scss +33 -33
  65. package/sass/components/_tabs.scss +99 -99
  66. package/sass/components/_tapTarget.scss +103 -103
  67. package/sass/components/_timepicker.scss +199 -183
  68. package/sass/components/_toast.scss +58 -58
  69. package/sass/components/_tooltip.scss +32 -32
  70. package/sass/components/_transitions.scss +12 -12
  71. package/sass/components/_typography.scss +62 -62
  72. package/sass/components/_variables.scss +352 -352
  73. package/sass/components/_waves.scss +187 -187
  74. package/sass/components/forms/_checkboxes.scss +200 -200
  75. package/sass/components/forms/_file-input.scss +44 -44
  76. package/sass/components/forms/_forms.scss +22 -22
  77. package/sass/components/forms/_input-fields.scss +388 -379
  78. package/sass/components/forms/_radio-buttons.scss +115 -115
  79. package/sass/components/forms/_range.scss +161 -161
  80. package/sass/components/forms/_select.scss +199 -199
  81. package/sass/components/forms/_switches.scss +91 -91
  82. package/sass/ghpages-materialize.scss +7 -7
  83. package/sass/materialize.scss +42 -42
package/js/tooltip.js CHANGED
@@ -1,320 +1,320 @@
1
- (function($, anim) {
2
- 'use strict';
3
-
4
- let _defaults = {
5
- exitDelay: 200,
6
- enterDelay: 0,
7
- html: null,
8
- text: '',
9
- unsafeHTML: null,
10
- margin: 5,
11
- inDuration: 250,
12
- outDuration: 200,
13
- position: 'bottom',
14
- transitionMovement: 10
15
- };
16
-
17
- /**
18
- * @class
19
- *
20
- */
21
- class Tooltip extends Component {
22
- /**
23
- * Construct Tooltip instance
24
- * @constructor
25
- * @param {Element} el
26
- * @param {Object} options
27
- */
28
- constructor(el, options) {
29
- super(Tooltip, el, options);
30
-
31
- this.el.M_Tooltip = this;
32
- this.options = $.extend({}, Tooltip.defaults, options);
33
-
34
- this.isOpen = false;
35
- this.isHovered = false;
36
- this.isFocused = false;
37
- this._appendTooltipEl();
38
- this._setupEventHandlers();
39
- }
40
-
41
- static get defaults() {
42
- return _defaults;
43
- }
44
-
45
- static init(els, options) {
46
- return super.init(this, els, options);
47
- }
48
-
49
- /**
50
- * Get Instance
51
- */
52
- static getInstance(el) {
53
- let domElem = !!el.jquery ? el[0] : el;
54
- return domElem.M_Tooltip;
55
- }
56
-
57
- /**
58
- * Teardown component
59
- */
60
- destroy() {
61
- $(this.tooltipEl).remove();
62
- this._removeEventHandlers();
63
- this.el.M_Tooltip = undefined;
64
- }
65
-
66
- _appendTooltipEl() {
67
- let tooltipEl = document.createElement('div');
68
- tooltipEl.classList.add('material-tooltip');
69
- this.tooltipEl = tooltipEl;
70
-
71
- let tooltipContentEl = document.createElement('div');
72
- tooltipContentEl.classList.add('tooltip-content');
73
- this._setTooltipContent(tooltipContentEl);
74
-
75
- tooltipEl.appendChild(tooltipContentEl);
76
- document.body.appendChild(tooltipEl);
77
- }
78
-
79
- _setTooltipContent(tooltipContentEl) {
80
- tooltipContentEl.textContent = this.options.text;
81
- if (!!this.options.html) {
82
- // Warn when using html
83
- console.warn(
84
- 'The html option is deprecated and will be removed in the future. See https://github.com/materializecss/materialize/pull/49'
85
- );
86
- $(tooltipContentEl).append(this.options.html);
87
- }
88
- if (!!this.options.unsafeHTML) {
89
- $(tooltipContentEl).append(this.options.unsafeHTML);
90
- }
91
- }
92
-
93
- _updateTooltipContent() {
94
- this._setTooltipContent(this.tooltipEl.querySelector('.tooltip-content'));
95
- }
96
-
97
- _setupEventHandlers() {
98
- this._handleMouseEnterBound = this._handleMouseEnter.bind(this);
99
- this._handleMouseLeaveBound = this._handleMouseLeave.bind(this);
100
- this._handleFocusBound = this._handleFocus.bind(this);
101
- this._handleBlurBound = this._handleBlur.bind(this);
102
- this.el.addEventListener('mouseenter', this._handleMouseEnterBound);
103
- this.el.addEventListener('mouseleave', this._handleMouseLeaveBound);
104
- this.el.addEventListener('focus', this._handleFocusBound, true);
105
- this.el.addEventListener('blur', this._handleBlurBound, true);
106
- }
107
-
108
- _removeEventHandlers() {
109
- this.el.removeEventListener('mouseenter', this._handleMouseEnterBound);
110
- this.el.removeEventListener('mouseleave', this._handleMouseLeaveBound);
111
- this.el.removeEventListener('focus', this._handleFocusBound, true);
112
- this.el.removeEventListener('blur', this._handleBlurBound, true);
113
- }
114
-
115
- open(isManual) {
116
- if (this.isOpen) {
117
- return;
118
- }
119
- isManual = isManual === undefined ? true : undefined; // Default value true
120
- this.isOpen = true;
121
- // Update tooltip content with HTML attribute options
122
- this.options = $.extend({}, this.options, this._getAttributeOptions());
123
- this._updateTooltipContent();
124
- this._setEnterDelayTimeout(isManual);
125
- }
126
-
127
- close() {
128
- if (!this.isOpen) {
129
- return;
130
- }
131
-
132
- this.isHovered = false;
133
- this.isFocused = false;
134
- this.isOpen = false;
135
- this._setExitDelayTimeout();
136
- }
137
-
138
- /**
139
- * Create timeout which delays when the tooltip closes
140
- */
141
- _setExitDelayTimeout() {
142
- clearTimeout(this._exitDelayTimeout);
143
-
144
- this._exitDelayTimeout = setTimeout(() => {
145
- if (this.isHovered || this.isFocused) {
146
- return;
147
- }
148
-
149
- this._animateOut();
150
- }, this.options.exitDelay);
151
- }
152
-
153
- /**
154
- * Create timeout which delays when the toast closes
155
- */
156
- _setEnterDelayTimeout(isManual) {
157
- clearTimeout(this._enterDelayTimeout);
158
-
159
- this._enterDelayTimeout = setTimeout(() => {
160
- if (!this.isHovered && !this.isFocused && !isManual) {
161
- return;
162
- }
163
-
164
- this._animateIn();
165
- }, this.options.enterDelay);
166
- }
167
-
168
- _positionTooltip() {
169
- let origin = this.el,
170
- tooltip = this.tooltipEl,
171
- originHeight = origin.offsetHeight,
172
- originWidth = origin.offsetWidth,
173
- tooltipHeight = tooltip.offsetHeight,
174
- tooltipWidth = tooltip.offsetWidth,
175
- newCoordinates,
176
- margin = this.options.margin,
177
- targetTop,
178
- targetLeft;
179
-
180
- (this.xMovement = 0), (this.yMovement = 0);
181
-
182
- targetTop = origin.getBoundingClientRect().top + M.getDocumentScrollTop();
183
- targetLeft = origin.getBoundingClientRect().left + M.getDocumentScrollLeft();
184
-
185
- if (this.options.position === 'top') {
186
- targetTop += -tooltipHeight - margin;
187
- targetLeft += originWidth / 2 - tooltipWidth / 2;
188
- this.yMovement = -this.options.transitionMovement;
189
- } else if (this.options.position === 'right') {
190
- targetTop += originHeight / 2 - tooltipHeight / 2;
191
- targetLeft += originWidth + margin;
192
- this.xMovement = this.options.transitionMovement;
193
- } else if (this.options.position === 'left') {
194
- targetTop += originHeight / 2 - tooltipHeight / 2;
195
- targetLeft += -tooltipWidth - margin;
196
- this.xMovement = -this.options.transitionMovement;
197
- } else {
198
- targetTop += originHeight + margin;
199
- targetLeft += originWidth / 2 - tooltipWidth / 2;
200
- this.yMovement = this.options.transitionMovement;
201
- }
202
-
203
- newCoordinates = this._repositionWithinScreen(
204
- targetLeft,
205
- targetTop,
206
- tooltipWidth,
207
- tooltipHeight
208
- );
209
- $(tooltip).css({
210
- top: newCoordinates.y + 'px',
211
- left: newCoordinates.x + 'px'
212
- });
213
- }
214
-
215
- _repositionWithinScreen(x, y, width, height) {
216
- let scrollLeft = M.getDocumentScrollLeft();
217
- let scrollTop = M.getDocumentScrollTop();
218
- let newX = x - scrollLeft;
219
- let newY = y - scrollTop;
220
-
221
- let bounding = {
222
- left: newX,
223
- top: newY,
224
- width: width,
225
- height: height
226
- };
227
-
228
- let offset = this.options.margin + this.options.transitionMovement;
229
- let edges = M.checkWithinContainer(document.body, bounding, offset);
230
-
231
- if (edges.left) {
232
- newX = offset;
233
- } else if (edges.right) {
234
- newX -= newX + width - window.innerWidth;
235
- }
236
-
237
- if (edges.top) {
238
- newY = offset;
239
- } else if (edges.bottom) {
240
- newY -= newY + height - window.innerHeight;
241
- }
242
-
243
- return {
244
- x: newX + scrollLeft,
245
- y: newY + scrollTop
246
- };
247
- }
248
-
249
- _animateIn() {
250
- this._positionTooltip();
251
- this.tooltipEl.style.visibility = 'visible';
252
- anim.remove(this.tooltipEl);
253
- anim({
254
- targets: this.tooltipEl,
255
- opacity: this.options.opacity || 1,
256
- translateX: this.xMovement,
257
- translateY: this.yMovement,
258
- duration: this.options.inDuration,
259
- easing: 'easeOutCubic'
260
- });
261
- }
262
-
263
- _animateOut() {
264
- anim.remove(this.tooltipEl);
265
- anim({
266
- targets: this.tooltipEl,
267
- opacity: 0,
268
- translateX: 0,
269
- translateY: 0,
270
- duration: this.options.outDuration,
271
- easing: 'easeOutCubic'
272
- });
273
- }
274
-
275
- _handleMouseEnter() {
276
- this.isHovered = true;
277
- this.isFocused = false; // Allows close of tooltip when opened by focus.
278
- this.open(false);
279
- }
280
-
281
- _handleMouseLeave() {
282
- this.isHovered = false;
283
- this.isFocused = false; // Allows close of tooltip when opened by focus.
284
- this.close();
285
- }
286
-
287
- _handleFocus() {
288
- if (M.tabPressed) {
289
- this.isFocused = true;
290
- this.open(false);
291
- }
292
- }
293
-
294
- _handleBlur() {
295
- this.isFocused = false;
296
- this.close();
297
- }
298
-
299
- _getAttributeOptions() {
300
- let attributeOptions = {};
301
- let tooltipTextOption = this.el.getAttribute('data-tooltip');
302
- let positionOption = this.el.getAttribute('data-position');
303
-
304
- if (tooltipTextOption) {
305
- attributeOptions.text = tooltipTextOption;
306
- }
307
-
308
- if (positionOption) {
309
- attributeOptions.position = positionOption;
310
- }
311
- return attributeOptions;
312
- }
313
- }
314
-
315
- M.Tooltip = Tooltip;
316
-
317
- if (M.jQueryLoaded) {
318
- M.initializeJqueryWrapper(Tooltip, 'tooltip', 'M_Tooltip');
319
- }
320
- })(cash, M.anime);
1
+ (function($, anim) {
2
+ 'use strict';
3
+
4
+ let _defaults = {
5
+ exitDelay: 200,
6
+ enterDelay: 0,
7
+ html: null,
8
+ text: '',
9
+ unsafeHTML: null,
10
+ margin: 5,
11
+ inDuration: 250,
12
+ outDuration: 200,
13
+ position: 'bottom',
14
+ transitionMovement: 10
15
+ };
16
+
17
+ /**
18
+ * @class
19
+ *
20
+ */
21
+ class Tooltip extends Component {
22
+ /**
23
+ * Construct Tooltip instance
24
+ * @constructor
25
+ * @param {Element} el
26
+ * @param {Object} options
27
+ */
28
+ constructor(el, options) {
29
+ super(Tooltip, el, options);
30
+
31
+ this.el.M_Tooltip = this;
32
+ this.options = $.extend({}, Tooltip.defaults, options);
33
+
34
+ this.isOpen = false;
35
+ this.isHovered = false;
36
+ this.isFocused = false;
37
+ this._appendTooltipEl();
38
+ this._setupEventHandlers();
39
+ }
40
+
41
+ static get defaults() {
42
+ return _defaults;
43
+ }
44
+
45
+ static init(els, options) {
46
+ return super.init(this, els, options);
47
+ }
48
+
49
+ /**
50
+ * Get Instance
51
+ */
52
+ static getInstance(el) {
53
+ let domElem = !!el.jquery ? el[0] : el;
54
+ return domElem.M_Tooltip;
55
+ }
56
+
57
+ /**
58
+ * Teardown component
59
+ */
60
+ destroy() {
61
+ $(this.tooltipEl).remove();
62
+ this._removeEventHandlers();
63
+ this.el.M_Tooltip = undefined;
64
+ }
65
+
66
+ _appendTooltipEl() {
67
+ let tooltipEl = document.createElement('div');
68
+ tooltipEl.classList.add('material-tooltip');
69
+ this.tooltipEl = tooltipEl;
70
+
71
+ let tooltipContentEl = document.createElement('div');
72
+ tooltipContentEl.classList.add('tooltip-content');
73
+ this._setTooltipContent(tooltipContentEl);
74
+
75
+ tooltipEl.appendChild(tooltipContentEl);
76
+ document.body.appendChild(tooltipEl);
77
+ }
78
+
79
+ _setTooltipContent(tooltipContentEl) {
80
+ tooltipContentEl.textContent = this.options.text;
81
+ if (!!this.options.html) {
82
+ // Warn when using html
83
+ console.warn(
84
+ 'The html option is deprecated and will be removed in the future. See https://github.com/materializecss/materialize/pull/49'
85
+ );
86
+ $(tooltipContentEl).append(this.options.html);
87
+ }
88
+ if (!!this.options.unsafeHTML) {
89
+ $(tooltipContentEl).append(this.options.unsafeHTML);
90
+ }
91
+ }
92
+
93
+ _updateTooltipContent() {
94
+ this._setTooltipContent(this.tooltipEl.querySelector('.tooltip-content'));
95
+ }
96
+
97
+ _setupEventHandlers() {
98
+ this._handleMouseEnterBound = this._handleMouseEnter.bind(this);
99
+ this._handleMouseLeaveBound = this._handleMouseLeave.bind(this);
100
+ this._handleFocusBound = this._handleFocus.bind(this);
101
+ this._handleBlurBound = this._handleBlur.bind(this);
102
+ this.el.addEventListener('mouseenter', this._handleMouseEnterBound);
103
+ this.el.addEventListener('mouseleave', this._handleMouseLeaveBound);
104
+ this.el.addEventListener('focus', this._handleFocusBound, true);
105
+ this.el.addEventListener('blur', this._handleBlurBound, true);
106
+ }
107
+
108
+ _removeEventHandlers() {
109
+ this.el.removeEventListener('mouseenter', this._handleMouseEnterBound);
110
+ this.el.removeEventListener('mouseleave', this._handleMouseLeaveBound);
111
+ this.el.removeEventListener('focus', this._handleFocusBound, true);
112
+ this.el.removeEventListener('blur', this._handleBlurBound, true);
113
+ }
114
+
115
+ open(isManual) {
116
+ if (this.isOpen) {
117
+ return;
118
+ }
119
+ isManual = isManual === undefined ? true : undefined; // Default value true
120
+ this.isOpen = true;
121
+ // Update tooltip content with HTML attribute options
122
+ this.options = $.extend({}, this.options, this._getAttributeOptions());
123
+ this._updateTooltipContent();
124
+ this._setEnterDelayTimeout(isManual);
125
+ }
126
+
127
+ close() {
128
+ if (!this.isOpen) {
129
+ return;
130
+ }
131
+
132
+ this.isHovered = false;
133
+ this.isFocused = false;
134
+ this.isOpen = false;
135
+ this._setExitDelayTimeout();
136
+ }
137
+
138
+ /**
139
+ * Create timeout which delays when the tooltip closes
140
+ */
141
+ _setExitDelayTimeout() {
142
+ clearTimeout(this._exitDelayTimeout);
143
+
144
+ this._exitDelayTimeout = setTimeout(() => {
145
+ if (this.isHovered || this.isFocused) {
146
+ return;
147
+ }
148
+
149
+ this._animateOut();
150
+ }, this.options.exitDelay);
151
+ }
152
+
153
+ /**
154
+ * Create timeout which delays when the toast closes
155
+ */
156
+ _setEnterDelayTimeout(isManual) {
157
+ clearTimeout(this._enterDelayTimeout);
158
+
159
+ this._enterDelayTimeout = setTimeout(() => {
160
+ if (!this.isHovered && !this.isFocused && !isManual) {
161
+ return;
162
+ }
163
+
164
+ this._animateIn();
165
+ }, this.options.enterDelay);
166
+ }
167
+
168
+ _positionTooltip() {
169
+ let origin = this.el,
170
+ tooltip = this.tooltipEl,
171
+ originHeight = origin.offsetHeight,
172
+ originWidth = origin.offsetWidth,
173
+ tooltipHeight = tooltip.offsetHeight,
174
+ tooltipWidth = tooltip.offsetWidth,
175
+ newCoordinates,
176
+ margin = this.options.margin,
177
+ targetTop,
178
+ targetLeft;
179
+
180
+ (this.xMovement = 0), (this.yMovement = 0);
181
+
182
+ targetTop = origin.getBoundingClientRect().top + M.getDocumentScrollTop();
183
+ targetLeft = origin.getBoundingClientRect().left + M.getDocumentScrollLeft();
184
+
185
+ if (this.options.position === 'top') {
186
+ targetTop += -tooltipHeight - margin;
187
+ targetLeft += originWidth / 2 - tooltipWidth / 2;
188
+ this.yMovement = -this.options.transitionMovement;
189
+ } else if (this.options.position === 'right') {
190
+ targetTop += originHeight / 2 - tooltipHeight / 2;
191
+ targetLeft += originWidth + margin;
192
+ this.xMovement = this.options.transitionMovement;
193
+ } else if (this.options.position === 'left') {
194
+ targetTop += originHeight / 2 - tooltipHeight / 2;
195
+ targetLeft += -tooltipWidth - margin;
196
+ this.xMovement = -this.options.transitionMovement;
197
+ } else {
198
+ targetTop += originHeight + margin;
199
+ targetLeft += originWidth / 2 - tooltipWidth / 2;
200
+ this.yMovement = this.options.transitionMovement;
201
+ }
202
+
203
+ newCoordinates = this._repositionWithinScreen(
204
+ targetLeft,
205
+ targetTop,
206
+ tooltipWidth,
207
+ tooltipHeight
208
+ );
209
+ $(tooltip).css({
210
+ top: newCoordinates.y + 'px',
211
+ left: newCoordinates.x + 'px'
212
+ });
213
+ }
214
+
215
+ _repositionWithinScreen(x, y, width, height) {
216
+ let scrollLeft = M.getDocumentScrollLeft();
217
+ let scrollTop = M.getDocumentScrollTop();
218
+ let newX = x - scrollLeft;
219
+ let newY = y - scrollTop;
220
+
221
+ let bounding = {
222
+ left: newX,
223
+ top: newY,
224
+ width: width,
225
+ height: height
226
+ };
227
+
228
+ let offset = this.options.margin + this.options.transitionMovement;
229
+ let edges = M.checkWithinContainer(document.body, bounding, offset);
230
+
231
+ if (edges.left) {
232
+ newX = offset;
233
+ } else if (edges.right) {
234
+ newX -= newX + width - window.innerWidth;
235
+ }
236
+
237
+ if (edges.top) {
238
+ newY = offset;
239
+ } else if (edges.bottom) {
240
+ newY -= newY + height - window.innerHeight;
241
+ }
242
+
243
+ return {
244
+ x: newX + scrollLeft,
245
+ y: newY + scrollTop
246
+ };
247
+ }
248
+
249
+ _animateIn() {
250
+ this._positionTooltip();
251
+ this.tooltipEl.style.visibility = 'visible';
252
+ anim.remove(this.tooltipEl);
253
+ anim({
254
+ targets: this.tooltipEl,
255
+ opacity: this.options.opacity || 1,
256
+ translateX: this.xMovement,
257
+ translateY: this.yMovement,
258
+ duration: this.options.inDuration,
259
+ easing: 'easeOutCubic'
260
+ });
261
+ }
262
+
263
+ _animateOut() {
264
+ anim.remove(this.tooltipEl);
265
+ anim({
266
+ targets: this.tooltipEl,
267
+ opacity: 0,
268
+ translateX: 0,
269
+ translateY: 0,
270
+ duration: this.options.outDuration,
271
+ easing: 'easeOutCubic'
272
+ });
273
+ }
274
+
275
+ _handleMouseEnter() {
276
+ this.isHovered = true;
277
+ this.isFocused = false; // Allows close of tooltip when opened by focus.
278
+ this.open(false);
279
+ }
280
+
281
+ _handleMouseLeave() {
282
+ this.isHovered = false;
283
+ this.isFocused = false; // Allows close of tooltip when opened by focus.
284
+ this.close();
285
+ }
286
+
287
+ _handleFocus() {
288
+ if (M.tabPressed) {
289
+ this.isFocused = true;
290
+ this.open(false);
291
+ }
292
+ }
293
+
294
+ _handleBlur() {
295
+ this.isFocused = false;
296
+ this.close();
297
+ }
298
+
299
+ _getAttributeOptions() {
300
+ let attributeOptions = {};
301
+ let tooltipTextOption = this.el.getAttribute('data-tooltip');
302
+ let positionOption = this.el.getAttribute('data-position');
303
+
304
+ if (tooltipTextOption) {
305
+ attributeOptions.text = tooltipTextOption;
306
+ }
307
+
308
+ if (positionOption) {
309
+ attributeOptions.position = positionOption;
310
+ }
311
+ return attributeOptions;
312
+ }
313
+ }
314
+
315
+ M.Tooltip = Tooltip;
316
+
317
+ if (M.jQueryLoaded) {
318
+ M.initializeJqueryWrapper(Tooltip, 'tooltip', 'M_Tooltip');
319
+ }
320
+ })(cash, M.anime);