materialize-sass 0.100.2.1 → 1.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +18 -42
  3. data/Rakefile +17 -17
  4. data/{app/assets → assets}/javascripts/materialize-sprockets.js +8 -12
  5. data/assets/javascripts/materialize.js +11877 -0
  6. data/assets/javascripts/materialize/autocomplete.js +420 -0
  7. data/assets/javascripts/materialize/buttons.js +388 -0
  8. data/assets/javascripts/materialize/cards.js +28 -0
  9. data/assets/javascripts/materialize/carousel.js +791 -0
  10. data/assets/javascripts/materialize/cash.js +992 -0
  11. data/assets/javascripts/materialize/characterCounter.js +180 -0
  12. data/assets/javascripts/materialize/chips.js +555 -0
  13. data/assets/javascripts/materialize/collapsible.js +275 -0
  14. data/assets/javascripts/materialize/datepicker.js +898 -0
  15. data/assets/javascripts/materialize/dropdown.js +530 -0
  16. data/{app/assets → assets}/javascripts/materialize/extras/nouislider.js +1 -1
  17. data/{app/assets → assets}/javascripts/materialize/extras/nouislider.min.js +1 -1
  18. data/assets/javascripts/materialize/forms.js +223 -0
  19. data/assets/javascripts/materialize/global.js +353 -0
  20. data/assets/javascripts/materialize/materialbox.js +432 -0
  21. data/{app/assets → assets}/javascripts/materialize/modal.js +82 -113
  22. data/assets/javascripts/materialize/parallax.js +135 -0
  23. data/assets/javascripts/materialize/pushpin.js +158 -0
  24. data/assets/javascripts/materialize/range.js +305 -0
  25. data/assets/javascripts/materialize/scrollspy.js +322 -0
  26. data/assets/javascripts/materialize/select.js +426 -0
  27. data/assets/javascripts/materialize/sidenav.js +584 -0
  28. data/assets/javascripts/materialize/slider.js +383 -0
  29. data/assets/javascripts/materialize/tabs.js +460 -0
  30. data/assets/javascripts/materialize/tapTarget.js +347 -0
  31. data/assets/javascripts/materialize/timepicker.js +616 -0
  32. data/{app/assets → assets}/javascripts/materialize/toasts.js +42 -46
  33. data/assets/javascripts/materialize/tooltip.js +325 -0
  34. data/assets/javascripts/materialize/velocity.min.js +782 -0
  35. data/{app/assets → assets}/javascripts/materialize/waves.js +0 -0
  36. data/{app/assets → assets}/stylesheets/materialize.scss +5 -6
  37. data/{app/assets → assets}/stylesheets/materialize/components/_badges.scss +1 -1
  38. data/{app/assets → assets}/stylesheets/materialize/components/_buttons.scss +34 -2
  39. data/{app/assets → assets}/stylesheets/materialize/components/_cards.scss +0 -0
  40. data/{app/assets → assets}/stylesheets/materialize/components/_carousel.scss +1 -1
  41. data/{app/assets → assets}/stylesheets/materialize/components/_chips.scss +6 -5
  42. data/{app/assets → assets}/stylesheets/materialize/components/_collapsible.scss +3 -3
  43. data/{app/assets → assets}/stylesheets/materialize/components/_color.scss +0 -0
  44. data/assets/stylesheets/materialize/components/_datepicker.scss +180 -0
  45. data/{app/assets → assets}/stylesheets/materialize/components/_dropdown.scss +16 -15
  46. data/{app/assets → assets}/stylesheets/materialize/components/_global.scss +49 -14
  47. data/{app/assets → assets}/stylesheets/materialize/components/_grid.scss +1 -1
  48. data/{app/assets → assets}/stylesheets/materialize/components/_icons-material-design.scss +0 -0
  49. data/{app/assets → assets}/stylesheets/materialize/components/_materialbox.scss +0 -0
  50. data/assets/stylesheets/materialize/components/_mixins.scss +5 -0
  51. data/{app/assets → assets}/stylesheets/materialize/components/_modal.scss +1 -1
  52. data/{app/assets → assets}/stylesheets/materialize/components/_navbar.scss +0 -0
  53. data/assets/stylesheets/materialize/components/_normalize.scss +447 -0
  54. data/{app/assets → assets}/stylesheets/materialize/components/_preloader.scss +0 -0
  55. data/{app/assets → assets}/stylesheets/materialize/components/_pulse.scss +0 -0
  56. data/{app/assets/stylesheets/materialize/components/_sideNav.scss → assets/stylesheets/materialize/components/_sidenav.scss} +23 -21
  57. data/{app/assets → assets}/stylesheets/materialize/components/_slider.scss +0 -0
  58. data/{app/assets → assets}/stylesheets/materialize/components/_table_of_contents.scss +3 -3
  59. data/{app/assets → assets}/stylesheets/materialize/components/_tabs.scss +2 -2
  60. data/{app/assets → assets}/stylesheets/materialize/components/_tapTarget.scss +0 -0
  61. data/assets/stylesheets/materialize/components/_timepicker.scss +182 -0
  62. data/{app/assets → assets}/stylesheets/materialize/components/_toast.scss +0 -0
  63. data/{app/assets → assets}/stylesheets/materialize/components/_tooltip.scss +1 -0
  64. data/{app/assets → assets}/stylesheets/materialize/components/_transitions.scss +0 -0
  65. data/{app/assets → assets}/stylesheets/materialize/components/_typography.scss +8 -8
  66. data/{app/assets → assets}/stylesheets/materialize/components/_variables.scss +42 -44
  67. data/{app/assets → assets}/stylesheets/materialize/components/_waves.scss +0 -0
  68. data/{app/assets → assets}/stylesheets/materialize/components/forms/_checkboxes.scss +24 -24
  69. data/{app/assets → assets}/stylesheets/materialize/components/forms/_file-input.scss +0 -0
  70. data/{app/assets → assets}/stylesheets/materialize/components/forms/_forms.scss +0 -0
  71. data/{app/assets → assets}/stylesheets/materialize/components/forms/_input-fields.scss +49 -35
  72. data/{app/assets → assets}/stylesheets/materialize/components/forms/_radio-buttons.scss +29 -29
  73. data/{app/assets → assets}/stylesheets/materialize/components/forms/_range.scss +32 -31
  74. data/{app/assets → assets}/stylesheets/materialize/components/forms/_select.scss +20 -11
  75. data/{app/assets → assets}/stylesheets/materialize/components/forms/_switches.scss +0 -0
  76. data/{app/assets → assets}/stylesheets/materialize/extras/nouislider.css +1 -1
  77. data/lib/materialize-sass.rb +13 -23
  78. data/lib/materialize-sass/engine.rb +6 -9
  79. data/lib/materialize-sass/version.rb +1 -1
  80. data/materialize-sass.gemspec +2 -1
  81. metadata +97 -97
  82. data/app/assets/fonts/roboto/Roboto-Bold.woff +0 -0
  83. data/app/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
  84. data/app/assets/fonts/roboto/Roboto-Light.woff +0 -0
  85. data/app/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
  86. data/app/assets/fonts/roboto/Roboto-Medium.woff +0 -0
  87. data/app/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
  88. data/app/assets/fonts/roboto/Roboto-Regular.woff +0 -0
  89. data/app/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
  90. data/app/assets/fonts/roboto/Roboto-Thin.woff +0 -0
  91. data/app/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
  92. data/app/assets/javascripts/materialize.js +0 -10021
  93. data/app/assets/javascripts/materialize/animation.js +0 -7
  94. data/app/assets/javascripts/materialize/buttons.js +0 -253
  95. data/app/assets/javascripts/materialize/cards.js +0 -28
  96. data/app/assets/javascripts/materialize/carousel.js +0 -543
  97. data/app/assets/javascripts/materialize/character_counter.js +0 -64
  98. data/app/assets/javascripts/materialize/chips.js +0 -315
  99. data/app/assets/javascripts/materialize/collapsible.js +0 -178
  100. data/app/assets/javascripts/materialize/date_picker/picker.date.js +0 -1399
  101. data/app/assets/javascripts/materialize/date_picker/picker.js +0 -1196
  102. data/app/assets/javascripts/materialize/date_picker/picker.time.js +0 -646
  103. data/app/assets/javascripts/materialize/dropdown.js +0 -257
  104. data/app/assets/javascripts/materialize/forms.js +0 -806
  105. data/app/assets/javascripts/materialize/global.js +0 -170
  106. data/app/assets/javascripts/materialize/hammer.min.js +0 -424
  107. data/app/assets/javascripts/materialize/initial.js +0 -10
  108. data/app/assets/javascripts/materialize/jquery.easing.1.4.js +0 -144
  109. data/app/assets/javascripts/materialize/jquery.hammer.js +0 -33
  110. data/app/assets/javascripts/materialize/materialbox.js +0 -263
  111. data/app/assets/javascripts/materialize/parallax.js +0 -54
  112. data/app/assets/javascripts/materialize/pushpin.js +0 -68
  113. data/app/assets/javascripts/materialize/scrollFire.js +0 -49
  114. data/app/assets/javascripts/materialize/scrollspy.js +0 -230
  115. data/app/assets/javascripts/materialize/sideNav.js +0 -395
  116. data/app/assets/javascripts/materialize/slider.js +0 -295
  117. data/app/assets/javascripts/materialize/tabs.js +0 -244
  118. data/app/assets/javascripts/materialize/tapTarget.js +0 -184
  119. data/app/assets/javascripts/materialize/tooltip.js +0 -227
  120. data/app/assets/javascripts/materialize/transitions.js +0 -163
  121. data/app/assets/javascripts/materialize/velocity.min.js +0 -626
  122. data/app/assets/stylesheets/materialize/components/_normalize.scss +0 -424
  123. data/app/assets/stylesheets/materialize/components/_roboto.scss +0 -39
  124. data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +0 -469
  125. data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +0 -216
  126. data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +0 -267
@@ -6,34 +6,25 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
6
6
  'use strict';
7
7
 
8
8
  var _defaults = {
9
- displayLength: Infinity,
9
+ html: '',
10
+ displayLength: 4000,
10
11
  inDuration: 300,
11
12
  outDuration: 375,
12
- className: undefined,
13
- completeCallback: undefined,
13
+ classes: '',
14
+ completeCallback: null,
14
15
  activationPercent: 0.8
15
16
  };
16
17
 
17
18
  var Toast = function () {
18
- function Toast(message, displayLength, className, completeCallback) {
19
+ function Toast(options) {
19
20
  _classCallCheck(this, Toast);
20
21
 
21
- if (!message) {
22
- return;
23
- }
24
-
25
22
  /**
26
23
  * Options for the toast
27
24
  * @member Toast#options
28
25
  */
29
- this.options = {
30
- displayLength: displayLength,
31
- className: className,
32
- completeCallback: completeCallback
33
- };
34
-
35
- this.options = $.extend({}, Toast.defaults, this.options);
36
- this.message = message;
26
+ this.options = $.extend({}, Toast.defaults, options);
27
+ this.message = this.options.html;
37
28
 
38
29
  /**
39
30
  * Describes current pan state toast
@@ -52,32 +43,27 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
52
43
 
53
44
  // Create new toast
54
45
  Toast._toasts.push(this);
55
- var toastElement = this.createToast();
46
+ var toastElement = this._createToast();
56
47
  toastElement.M_Toast = this;
57
48
  this.el = toastElement;
58
49
  this._animateIn();
59
- this.setTimer();
50
+ this._setTimer();
60
51
  }
61
52
 
62
53
  _createClass(Toast, [{
63
- key: 'createToast',
54
+ key: '_createToast',
64
55
 
65
56
 
66
57
  /**
67
58
  * Create toast and append it to toast container
68
59
  */
69
- value: function createToast() {
60
+ value: function _createToast() {
70
61
  var toast = document.createElement('div');
71
62
  toast.classList.add('toast');
72
63
 
73
64
  // Add custom classes onto toast
74
- if (this.options.className) {
75
- var classes = this.options.className.split(' ');
76
- var i = void 0,
77
- count = void 0;
78
- for (i = 0, count = classes.length; i < count; i++) {
79
- toast.classList.add(classes[i]);
80
- }
65
+ if (!!this.options.classes.length) {
66
+ $(toast).addClass(this.options.classes);
81
67
  }
82
68
 
83
69
  // Set content
@@ -85,10 +71,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
85
71
  toast.appendChild(this.message);
86
72
 
87
73
  // Check if it is jQuery object
88
- } else if (this.message instanceof jQuery) {
89
- $(toast).append(this.message);
74
+ } else if (!!this.message.jquery) {
75
+ $(toast).append(this.message[0]);
90
76
 
91
- // Insert as text;
77
+ // Insert as html;
92
78
  } else {
93
79
  toast.innerHTML = this.message;
94
80
  }
@@ -119,8 +105,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
119
105
  */
120
106
 
121
107
  }, {
122
- key: 'setTimer',
123
- value: function setTimer() {
108
+ key: '_setTimer',
109
+ value: function _setTimer() {
124
110
  var _this = this;
125
111
 
126
112
  if (this.timeRemaining !== Infinity) {
@@ -132,7 +118,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
132
118
 
133
119
  // Animate toast out
134
120
  if (_this.timeRemaining <= 0) {
135
- _this.remove();
121
+ _this.dismiss();
136
122
  }
137
123
  }, 20);
138
124
  }
@@ -143,8 +129,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
143
129
  */
144
130
 
145
131
  }, {
146
- key: 'remove',
147
- value: function remove() {
132
+ key: 'dismiss',
133
+ value: function dismiss() {
148
134
  var _this2 = this;
149
135
 
150
136
  window.clearInterval(this.counterInterval);
@@ -175,12 +161,23 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
175
161
  });
176
162
  }
177
163
  }], [{
178
- key: '_createContainer',
164
+ key: 'getInstance',
179
165
 
180
166
 
167
+ /**
168
+ * Get Instance
169
+ */
170
+ value: function getInstance(el) {
171
+ var domElem = !!el.jquery ? el[0] : el;
172
+ return domElem.M_Toast;
173
+ }
174
+
181
175
  /**
182
176
  * Append toast container and add event handlers
183
177
  */
178
+
179
+ }, {
180
+ key: '_createContainer',
184
181
  value: function _createContainer() {
185
182
  var container = document.createElement('div');
186
183
  container.setAttribute('id', 'toast-container');
@@ -259,12 +256,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
259
256
 
260
257
  /**
261
258
  * End drag handler
262
- * @param {Event} e
263
259
  */
264
260
 
265
261
  }, {
266
262
  key: '_onDragEnd',
267
- value: function _onDragEnd(e) {
263
+ value: function _onDragEnd() {
268
264
  if (!!Toast._draggedToast) {
269
265
  var toast = Toast._draggedToast;
270
266
  toast.panning = false;
@@ -277,7 +273,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
277
273
  // Remove toast
278
274
  if (shouldBeDismissed) {
279
275
  toast.wasSwiped = true;
280
- toast.remove();
276
+ toast.dismiss();
281
277
 
282
278
  // Animate toast back to original position
283
279
  } else {
@@ -309,10 +305,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
309
305
  */
310
306
 
311
307
  }, {
312
- key: 'removeAll',
313
- value: function removeAll() {
308
+ key: 'dismissAll',
309
+ value: function dismissAll() {
314
310
  for (var toastIndex in Toast._toasts) {
315
- Toast._toasts[toastIndex].remove();
311
+ Toast._toasts[toastIndex].dismiss();
316
312
  }
317
313
  }
318
314
  }, {
@@ -347,8 +343,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
347
343
  */
348
344
  Toast._draggedToast = null;
349
345
 
350
- Materialize.Toast = Toast;
351
- Materialize.toast = function (message, displayLength, className, completeCallback) {
352
- return new Toast(message, displayLength, className, completeCallback);
346
+ M.Toast = Toast;
347
+ M.toast = function (options) {
348
+ return new Toast(options);
353
349
  };
354
- })(jQuery, Materialize.Vel);
350
+ })(cash, M.Vel);
@@ -0,0 +1,325 @@
1
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2
+
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
+
5
+ (function ($, Vel) {
6
+ 'use strict';
7
+
8
+ var _defaults = {
9
+ exitDelay: 200,
10
+ enterDelay: 0,
11
+ html: null,
12
+ margin: 5,
13
+ inDuration: 300,
14
+ outDuration: 250,
15
+ position: 'bottom',
16
+ transitionMovement: 10
17
+ };
18
+
19
+ /**
20
+ * @class
21
+ *
22
+ */
23
+
24
+ var Tooltip = function () {
25
+ /**
26
+ * Construct Tooltip instance
27
+ * @constructor
28
+ * @param {Element} el
29
+ * @param {Object} options
30
+ */
31
+ function Tooltip(el, options) {
32
+ _classCallCheck(this, Tooltip);
33
+
34
+ // If exists, destroy and reinitialize
35
+ if (!!el.M_Tooltip) {
36
+ el.M_Tooltip.destroy();
37
+ }
38
+
39
+ this.el = el;
40
+ this.$el = $(el);
41
+ this.el.M_Tooltip = this;
42
+ this.options = $.extend({}, Tooltip.defaults, options);
43
+
44
+ this.isOpen = false;
45
+ this.isHovered = false;
46
+ this._appendTooltipEl();
47
+ this._setupEventHandlers();
48
+ }
49
+
50
+ _createClass(Tooltip, [{
51
+ key: 'destroy',
52
+
53
+
54
+ /**
55
+ * Teardown component
56
+ */
57
+ value: function destroy() {
58
+ $(this.tooltipEl).remove();
59
+ this._removeEventHandlers();
60
+ this.$el[0].M_Tooltip = undefined;
61
+ }
62
+ }, {
63
+ key: '_appendTooltipEl',
64
+ value: function _appendTooltipEl() {
65
+ var tooltipEl = document.createElement('div');
66
+ tooltipEl.classList.add('material-tooltip');
67
+ this.tooltipEl = tooltipEl;
68
+
69
+ var 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
+ key: '_updateTooltipContent',
77
+ value: function _updateTooltipContent() {
78
+ this.tooltipEl.querySelector('.tooltip-content').innerHTML = this.options.html;
79
+ }
80
+ }, {
81
+ key: '_setupEventHandlers',
82
+ value: function _setupEventHandlers() {
83
+ this.handleMouseEnterBound = this._handleMouseEnter.bind(this);
84
+ this.handleMouseLeaveBound = this._handleMouseLeave.bind(this);
85
+ this.$el[0].addEventListener('mouseenter', this.handleMouseEnterBound);
86
+ this.$el[0].addEventListener('mouseleave', this.handleMouseLeaveBound);
87
+ }
88
+ }, {
89
+ key: '_removeEventHandlers',
90
+ value: function _removeEventHandlers() {
91
+ this.$el[0].removeEventListener('mouseenter', this.handleMouseEnterBound);
92
+ this.$el[0].removeEventListener('mouseleave', this.handleMouseLeaveBound);
93
+ }
94
+ }, {
95
+ key: 'open',
96
+ value: function open() {
97
+ if (this.isOpen) {
98
+ return;
99
+ }
100
+
101
+ this.isOpen = true;
102
+ // Update tooltip content with HTML attribute options
103
+ this.options = $.extend({}, this.options, this._getAttributeOptions());
104
+ this._updateTooltipContent();
105
+ this._setEnterDelayTimeout();
106
+ }
107
+ }, {
108
+ key: 'close',
109
+ value: function close() {
110
+ if (!this.isOpen) {
111
+ return;
112
+ }
113
+
114
+ this.isOpen = false;
115
+ this._setExitDelayTimeout();
116
+ }
117
+
118
+ /**
119
+ * Create timeout which delays when the tooltip closes
120
+ */
121
+
122
+ }, {
123
+ key: '_setExitDelayTimeout',
124
+ value: function _setExitDelayTimeout() {
125
+ var _this = this;
126
+
127
+ clearTimeout(this._exitDelayTimeout);
128
+
129
+ this._exitDelayTimeout = setTimeout(function () {
130
+ if (_this.isHovered) {
131
+ return;
132
+ } else {
133
+ _this._animateOut();
134
+ }
135
+ }, this.options.exitDelay);
136
+ }
137
+
138
+ /**
139
+ * Create timeout which delays when the toast closes
140
+ */
141
+
142
+ }, {
143
+ key: '_setEnterDelayTimeout',
144
+ value: function _setEnterDelayTimeout() {
145
+ var _this2 = this;
146
+
147
+ clearTimeout(this._enterDelayTimeout);
148
+
149
+ this._enterDelayTimeout = setTimeout(function () {
150
+ if (!_this2.isHovered) {
151
+ return;
152
+ } else {
153
+ _this2._animateIn();
154
+ }
155
+ }, this.options.enterDelay);
156
+ }
157
+ }, {
158
+ key: '_positionTooltip',
159
+ value: function _positionTooltip() {
160
+ var origin = this.$el[0],
161
+ tooltip = this.tooltipEl,
162
+ originHeight = origin.offsetHeight,
163
+ originWidth = origin.offsetWidth,
164
+ tooltipHeight = tooltip.offsetHeight,
165
+ tooltipWidth = tooltip.offsetWidth,
166
+ newCoordinates = void 0,
167
+ margin = this.options.margin,
168
+ targetTop = void 0,
169
+ targetLeft = void 0;
170
+
171
+ this.xMovement = 0, this.yMovement = 0;
172
+
173
+ targetTop = origin.offsetTop;
174
+ targetLeft = origin.offsetLeft;
175
+
176
+ if (this.options.position === 'top') {
177
+ targetTop += -tooltipHeight - margin;
178
+ targetLeft += originWidth / 2 - tooltipWidth / 2;
179
+ this.yMovement = -this.options.transitionMovement;
180
+ } else if (this.options.position === 'right') {
181
+ targetTop += originHeight / 2 - tooltipHeight / 2;
182
+ targetLeft += originWidth + margin;
183
+ this.xMovement = this.options.transitionMovement;
184
+ } else if (this.options.position === 'left') {
185
+ targetTop += originHeight / 2 - tooltipHeight / 2;
186
+ targetLeft += -tooltipWidth - margin;
187
+ this.xMovement = -this.options.transitionMovement;
188
+ } else {
189
+ targetTop += originHeight + margin;
190
+ targetLeft += originWidth / 2 - tooltipWidth / 2;
191
+ this.yMovement = this.options.transitionMovement;
192
+ }
193
+
194
+ newCoordinates = this._repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
195
+ $(tooltip).css({
196
+ top: newCoordinates.y + 'px',
197
+ left: newCoordinates.x + 'px'
198
+ });
199
+ }
200
+ }, {
201
+ key: '_repositionWithinScreen',
202
+ value: function _repositionWithinScreen(x, y, width, height) {
203
+ var scrollLeft = M.getDocumentScrollLeft();
204
+ var scrollTop = M.getDocumentScrollTop();
205
+ var newX = x - scrollLeft;
206
+ var newY = y - scrollTop;
207
+
208
+ var bounding = {
209
+ left: newX,
210
+ top: newY,
211
+ width: width,
212
+ height: height
213
+ };
214
+
215
+ var offset = this.options.margin + this.options.transitionMovement;
216
+ var edges = M.checkWithinContainer(document.body, bounding, offset);
217
+
218
+ if (edges.left) {
219
+ newX = offset;
220
+ } else if (edges.right) {
221
+ newX -= newX + width - window.innerWidth;
222
+ }
223
+
224
+ if (edges.top) {
225
+ newY = offset;
226
+ } else if (edges.bottom) {
227
+ newY -= newY + height - window.innerHeight;
228
+ }
229
+
230
+ return { x: newX + scrollLeft, y: newY + scrollTop };
231
+ }
232
+ }, {
233
+ key: '_animateIn',
234
+ value: function _animateIn() {
235
+ this._positionTooltip();
236
+ this.tooltipEl.style.visibility = 'visible';
237
+ Vel(this.tooltipEl, 'stop');
238
+ Vel(this.tooltipEl, {
239
+ opacity: 1,
240
+ translateX: this.xMovement,
241
+ translateY: this.yMovement
242
+ }, {
243
+ duration: this.options.inDuration,
244
+ easing: 'easeOutCubic',
245
+ queue: false
246
+ });
247
+ }
248
+ }, {
249
+ key: '_animateOut',
250
+ value: function _animateOut() {
251
+ Vel(this.tooltipEl, 'stop');
252
+ Vel(this.tooltipEl, {
253
+ opacity: 0,
254
+ translateX: 0,
255
+ translateY: 0
256
+ }, {
257
+ duration: this.options.outDuration,
258
+ easing: 'easeOutCubic',
259
+ queue: false
260
+ });
261
+ }
262
+ }, {
263
+ key: '_handleMouseEnter',
264
+ value: function _handleMouseEnter() {
265
+ this.isHovered = true;
266
+ this.open();
267
+ }
268
+ }, {
269
+ key: '_handleMouseLeave',
270
+ value: function _handleMouseLeave() {
271
+ this.isHovered = false;
272
+ this.close();
273
+ }
274
+ }, {
275
+ key: '_getAttributeOptions',
276
+ value: function _getAttributeOptions() {
277
+ var attributeOptions = {};
278
+ var tooltipTextOption = this.$el[0].getAttribute('data-tooltip');
279
+ var positionOption = this.$el[0].getAttribute('data-position');
280
+
281
+ if (tooltipTextOption) {
282
+ attributeOptions.html = tooltipTextOption;
283
+ }
284
+
285
+ if (positionOption) {
286
+ attributeOptions.position = positionOption;
287
+ }
288
+ return attributeOptions;
289
+ }
290
+ }], [{
291
+ key: 'init',
292
+ value: function init($els, options) {
293
+ var arr = [];
294
+ $els.each(function () {
295
+ arr.push(new Tooltip(this, options));
296
+ });
297
+ return arr;
298
+ }
299
+
300
+ /**
301
+ * Get Instance
302
+ */
303
+
304
+ }, {
305
+ key: 'getInstance',
306
+ value: function getInstance(el) {
307
+ var domElem = !!el.jquery ? el[0] : el;
308
+ return domElem.M_Tooltip;
309
+ }
310
+ }, {
311
+ key: 'defaults',
312
+ get: function () {
313
+ return _defaults;
314
+ }
315
+ }]);
316
+
317
+ return Tooltip;
318
+ }();
319
+
320
+ M.Tooltip = Tooltip;
321
+
322
+ if (M.jQueryLoaded) {
323
+ M.initializeJqueryWrapper(Tooltip, 'tooltip', 'M_Tooltip');
324
+ }
325
+ })(cash, M.Vel);