materialize-sass 0.97.0 → 1.0.0.1

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