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,513 @@
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
+ var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
4
+
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+
7
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
+
9
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
10
+
11
+ (function ($, anim) {
12
+ 'use strict';
13
+
14
+ var _defaults = {
15
+ inDuration: 275,
16
+ outDuration: 200,
17
+ onOpenStart: null,
18
+ onOpenEnd: null,
19
+ onCloseStart: null,
20
+ onCloseEnd: null
21
+ };
22
+
23
+ /**
24
+ * @class
25
+ *
26
+ */
27
+
28
+ var Materialbox = function (_Component) {
29
+ _inherits(Materialbox, _Component);
30
+
31
+ /**
32
+ * Construct Materialbox instance
33
+ * @constructor
34
+ * @param {Element} el
35
+ * @param {Object} options
36
+ */
37
+ function Materialbox(el, options) {
38
+ _classCallCheck(this, Materialbox);
39
+
40
+ var _this = _possibleConstructorReturn(this, (Materialbox.__proto__ || Object.getPrototypeOf(Materialbox)).call(this, Materialbox, el, options));
41
+
42
+ _this.el.M_Materialbox = _this;
43
+
44
+ /**
45
+ * Options for the modal
46
+ * @member Materialbox#options
47
+ * @prop {Number} [inDuration=275] - Length in ms of enter transition
48
+ * @prop {Number} [outDuration=200] - Length in ms of exit transition
49
+ * @prop {Function} onOpenStart - Callback function called before materialbox is opened
50
+ * @prop {Function} onOpenEnd - Callback function called after materialbox is opened
51
+ * @prop {Function} onCloseStart - Callback function called before materialbox is closed
52
+ * @prop {Function} onCloseEnd - Callback function called after materialbox is closed
53
+ */
54
+ _this.options = $.extend({}, Materialbox.defaults, options);
55
+
56
+ _this.overlayActive = false;
57
+ _this.doneAnimating = true;
58
+ _this.placeholder = $('<div></div>').addClass('material-placeholder');
59
+ _this.originalWidth = 0;
60
+ _this.originalHeight = 0;
61
+ _this.originInlineStyles = _this.$el.attr('style');
62
+ _this.caption = _this.el.getAttribute('data-caption') || '';
63
+
64
+ // Wrap
65
+ _this.$el.before(_this.placeholder);
66
+ _this.placeholder.append(_this.$el);
67
+
68
+ _this._setupEventHandlers();
69
+ return _this;
70
+ }
71
+
72
+ _createClass(Materialbox, [{
73
+ key: 'destroy',
74
+
75
+
76
+ /**
77
+ * Teardown component
78
+ */
79
+ value: function destroy() {
80
+ this._removeEventHandlers();
81
+ this.el.M_Materialbox = undefined;
82
+
83
+ // Unwrap image
84
+ $(this.placeholder).after(this.el).remove();
85
+
86
+ this.$el.removeAttr('style');
87
+ }
88
+
89
+ /**
90
+ * Setup Event Handlers
91
+ */
92
+
93
+ }, {
94
+ key: '_setupEventHandlers',
95
+ value: function _setupEventHandlers() {
96
+ this._handleMaterialboxClickBound = this._handleMaterialboxClick.bind(this);
97
+ this.el.addEventListener('click', this._handleMaterialboxClickBound);
98
+ }
99
+
100
+ /**
101
+ * Remove Event Handlers
102
+ */
103
+
104
+ }, {
105
+ key: '_removeEventHandlers',
106
+ value: function _removeEventHandlers() {
107
+ this.el.removeEventListener('click', this._handleMaterialboxClickBound);
108
+ }
109
+
110
+ /**
111
+ * Handle Materialbox Click
112
+ * @param {Event} e
113
+ */
114
+
115
+ }, {
116
+ key: '_handleMaterialboxClick',
117
+ value: function _handleMaterialboxClick(e) {
118
+ // If already modal, return to original
119
+ if (this.doneAnimating === false || this.overlayActive && this.doneAnimating) {
120
+ this.close();
121
+ } else {
122
+ this.open();
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Handle Window Scroll
128
+ */
129
+
130
+ }, {
131
+ key: '_handleWindowScroll',
132
+ value: function _handleWindowScroll() {
133
+ if (this.overlayActive) {
134
+ this.close();
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Handle Window Resize
140
+ */
141
+
142
+ }, {
143
+ key: '_handleWindowResize',
144
+ value: function _handleWindowResize() {
145
+ if (this.overlayActive) {
146
+ this.close();
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Handle Window Resize
152
+ * @param {Event} e
153
+ */
154
+
155
+ }, {
156
+ key: '_handleWindowEscape',
157
+ value: function _handleWindowEscape(e) {
158
+ // ESC key
159
+ if (e.keyCode === 27 && this.doneAnimating && this.overlayActive) {
160
+ this.close();
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Find ancestors with overflow: hidden; and make visible
166
+ */
167
+
168
+ }, {
169
+ key: '_makeAncestorsOverflowVisible',
170
+ value: function _makeAncestorsOverflowVisible() {
171
+ this.ancestorsChanged = $();
172
+ var ancestor = this.placeholder[0].parentNode;
173
+ while (ancestor !== null && !$(ancestor).is(document)) {
174
+ var curr = $(ancestor);
175
+ if (curr.css('overflow') !== 'visible') {
176
+ curr.css('overflow', 'visible');
177
+ if (this.ancestorsChanged === undefined) {
178
+ this.ancestorsChanged = curr;
179
+ } else {
180
+ this.ancestorsChanged = this.ancestorsChanged.add(curr);
181
+ }
182
+ }
183
+ ancestor = ancestor.parentNode;
184
+ }
185
+ }
186
+
187
+ /**
188
+ * Animate image in
189
+ */
190
+
191
+ }, {
192
+ key: '_animateImageIn',
193
+ value: function _animateImageIn() {
194
+ var _this2 = this;
195
+
196
+ var animOptions = {
197
+ targets: this.el,
198
+ height: [this.originalHeight, this.newHeight],
199
+ width: [this.originalWidth, this.newWidth],
200
+ left: M.getDocumentScrollLeft() + this.windowWidth / 2 - this.placeholder.offset().left - this.newWidth / 2,
201
+ top: M.getDocumentScrollTop() + this.windowHeight / 2 - this.placeholder.offset().top - this.newHeight / 2,
202
+ duration: this.options.inDuration,
203
+ easing: 'easeOutQuad',
204
+ complete: function () {
205
+ _this2.doneAnimating = true;
206
+
207
+ // onOpenEnd callback
208
+ if (typeof _this2.options.onOpenEnd === 'function') {
209
+ _this2.options.onOpenEnd.call(_this2, _this2.el);
210
+ }
211
+ }
212
+ };
213
+
214
+ // Override max-width or max-height if needed
215
+ this.maxWidth = this.$el.css('max-width');
216
+ this.maxHeight = this.$el.css('max-height');
217
+ if (this.maxWidth !== 'none') {
218
+ animOptions.maxWidth = this.newWidth;
219
+ }
220
+ if (this.maxHeight !== 'none') {
221
+ animOptions.maxHeight = this.newHeight;
222
+ }
223
+
224
+ anim(animOptions);
225
+ }
226
+
227
+ /**
228
+ * Animate image out
229
+ */
230
+
231
+ }, {
232
+ key: '_animateImageOut',
233
+ value: function _animateImageOut() {
234
+ var _this3 = this;
235
+
236
+ var animOptions = {
237
+ targets: this.el,
238
+ width: this.originalWidth,
239
+ height: this.originalHeight,
240
+ left: 0,
241
+ top: 0,
242
+ duration: this.options.outDuration,
243
+ easing: 'easeOutQuad',
244
+ complete: function () {
245
+ _this3.placeholder.css({
246
+ height: '',
247
+ width: '',
248
+ position: '',
249
+ top: '',
250
+ left: ''
251
+ });
252
+
253
+ // Revert to width or height attribute
254
+ if (_this3.attrWidth) {
255
+ _this3.$el.attr('width', _this3.attrWidth);
256
+ }
257
+ if (_this3.attrHeight) {
258
+ _this3.$el.attr('height', _this3.attrHeight);
259
+ }
260
+
261
+ _this3.$el.removeAttr('style');
262
+ _this3.originInlineStyles && _this3.$el.attr('style', _this3.originInlineStyles);
263
+
264
+ // Remove class
265
+ _this3.$el.removeClass('active');
266
+ _this3.doneAnimating = true;
267
+
268
+ // Remove overflow overrides on ancestors
269
+ if (_this3.ancestorsChanged.length) {
270
+ _this3.ancestorsChanged.css('overflow', '');
271
+ }
272
+
273
+ // onCloseEnd callback
274
+ if (typeof _this3.options.onCloseEnd === 'function') {
275
+ _this3.options.onCloseEnd.call(_this3, _this3.el);
276
+ }
277
+ }
278
+ };
279
+
280
+ anim(animOptions);
281
+ }
282
+
283
+ /**
284
+ * Update open and close vars
285
+ */
286
+
287
+ }, {
288
+ key: '_updateVars',
289
+ value: function _updateVars() {
290
+ this.windowWidth = window.innerWidth;
291
+ this.windowHeight = window.innerHeight;
292
+ this.caption = this.el.getAttribute('data-caption') || '';
293
+ }
294
+
295
+ /**
296
+ * Open Materialbox
297
+ */
298
+
299
+ }, {
300
+ key: 'open',
301
+ value: function open() {
302
+ var _this4 = this;
303
+
304
+ this._updateVars();
305
+ this.originalWidth = this.el.getBoundingClientRect().width;
306
+ this.originalHeight = this.el.getBoundingClientRect().height;
307
+
308
+ // Set states
309
+ this.doneAnimating = false;
310
+ this.$el.addClass('active');
311
+ this.overlayActive = true;
312
+
313
+ // onOpenStart callback
314
+ if (typeof this.options.onOpenStart === 'function') {
315
+ this.options.onOpenStart.call(this, this.el);
316
+ }
317
+
318
+ // Set positioning for placeholder
319
+ this.placeholder.css({
320
+ width: this.placeholder[0].getBoundingClientRect().width + 'px',
321
+ height: this.placeholder[0].getBoundingClientRect().height + 'px',
322
+ position: 'relative',
323
+ top: 0,
324
+ left: 0
325
+ });
326
+
327
+ this._makeAncestorsOverflowVisible();
328
+
329
+ // Set css on origin
330
+ this.$el.css({
331
+ position: 'absolute',
332
+ 'z-index': 1000,
333
+ 'will-change': 'left, top, width, height'
334
+ });
335
+
336
+ // Change from width or height attribute to css
337
+ this.attrWidth = this.$el.attr('width');
338
+ this.attrHeight = this.$el.attr('height');
339
+ if (this.attrWidth) {
340
+ this.$el.css('width', this.attrWidth + 'px');
341
+ this.$el.removeAttr('width');
342
+ }
343
+ if (this.attrHeight) {
344
+ this.$el.css('width', this.attrHeight + 'px');
345
+ this.$el.removeAttr('height');
346
+ }
347
+
348
+ // Add overlay
349
+ this.$overlay = $('<div id="materialbox-overlay"></div>').css({
350
+ opacity: 0
351
+ }).one('click', function () {
352
+ if (_this4.doneAnimating) {
353
+ _this4.close();
354
+ }
355
+ });
356
+
357
+ // Put before in origin image to preserve z-index layering.
358
+ this.$el.before(this.$overlay);
359
+
360
+ // Set dimensions if needed
361
+ var overlayOffset = this.$overlay[0].getBoundingClientRect();
362
+ this.$overlay.css({
363
+ width: this.windowWidth + 'px',
364
+ height: this.windowHeight + 'px',
365
+ left: -1 * overlayOffset.left + 'px',
366
+ top: -1 * overlayOffset.top + 'px'
367
+ });
368
+
369
+ anim.remove(this.el);
370
+ anim.remove(this.$overlay[0]);
371
+
372
+ // Animate Overlay
373
+ anim({
374
+ targets: this.$overlay[0],
375
+ opacity: 1,
376
+ duration: this.options.inDuration,
377
+ easing: 'easeOutQuad'
378
+ });
379
+
380
+ // Add and animate caption if it exists
381
+ if (this.caption !== '') {
382
+ if (this.$photocaption) {
383
+ anim.remove(this.$photoCaption[0]);
384
+ }
385
+ this.$photoCaption = $('<div class="materialbox-caption"></div>');
386
+ this.$photoCaption.text(this.caption);
387
+ $('body').append(this.$photoCaption);
388
+ this.$photoCaption.css({ display: 'inline' });
389
+
390
+ anim({
391
+ targets: this.$photoCaption[0],
392
+ opacity: 1,
393
+ duration: this.options.inDuration,
394
+ easing: 'easeOutQuad'
395
+ });
396
+ }
397
+
398
+ // Resize Image
399
+ var ratio = 0;
400
+ var widthPercent = this.originalWidth / this.windowWidth;
401
+ var heightPercent = this.originalHeight / this.windowHeight;
402
+ this.newWidth = 0;
403
+ this.newHeight = 0;
404
+
405
+ if (widthPercent > heightPercent) {
406
+ ratio = this.originalHeight / this.originalWidth;
407
+ this.newWidth = this.windowWidth * 0.9;
408
+ this.newHeight = this.windowWidth * 0.9 * ratio;
409
+ } else {
410
+ ratio = this.originalWidth / this.originalHeight;
411
+ this.newWidth = this.windowHeight * 0.9 * ratio;
412
+ this.newHeight = this.windowHeight * 0.9;
413
+ }
414
+
415
+ this._animateImageIn();
416
+
417
+ // Handle Exit triggers
418
+ this._handleWindowScrollBound = this._handleWindowScroll.bind(this);
419
+ this._handleWindowResizeBound = this._handleWindowResize.bind(this);
420
+ this._handleWindowEscapeBound = this._handleWindowEscape.bind(this);
421
+
422
+ window.addEventListener('scroll', this._handleWindowScrollBound);
423
+ window.addEventListener('resize', this._handleWindowResizeBound);
424
+ window.addEventListener('keyup', this._handleWindowEscapeBound);
425
+ }
426
+
427
+ /**
428
+ * Close Materialbox
429
+ */
430
+
431
+ }, {
432
+ key: 'close',
433
+ value: function close() {
434
+ var _this5 = this;
435
+
436
+ this._updateVars();
437
+ this.doneAnimating = false;
438
+
439
+ // onCloseStart callback
440
+ if (typeof this.options.onCloseStart === 'function') {
441
+ this.options.onCloseStart.call(this, this.el);
442
+ }
443
+
444
+ anim.remove(this.el);
445
+ anim.remove(this.$overlay[0]);
446
+
447
+ if (this.caption !== '') {
448
+ anim.remove(this.$photoCaption[0]);
449
+ }
450
+
451
+ // disable exit handlers
452
+ window.removeEventListener('scroll', this._handleWindowScrollBound);
453
+ window.removeEventListener('resize', this._handleWindowResizeBound);
454
+ window.removeEventListener('keyup', this._handleWindowEscapeBound);
455
+
456
+ anim({
457
+ targets: this.$overlay[0],
458
+ opacity: 0,
459
+ duration: this.options.outDuration,
460
+ easing: 'easeOutQuad',
461
+ complete: function () {
462
+ _this5.overlayActive = false;
463
+ _this5.$overlay.remove();
464
+ }
465
+ });
466
+
467
+ this._animateImageOut();
468
+
469
+ // Remove Caption + reset css settings on image
470
+ if (this.caption !== '') {
471
+ anim({
472
+ targets: this.$photoCaption[0],
473
+ opacity: 0,
474
+ duration: this.options.outDuration,
475
+ easing: 'easeOutQuad',
476
+ complete: function () {
477
+ _this5.$photoCaption.remove();
478
+ }
479
+ });
480
+ }
481
+ }
482
+ }], [{
483
+ key: 'init',
484
+ value: function init(els, options) {
485
+ return _get(Materialbox.__proto__ || Object.getPrototypeOf(Materialbox), 'init', this).call(this, this, els, options);
486
+ }
487
+
488
+ /**
489
+ * Get Instance
490
+ */
491
+
492
+ }, {
493
+ key: 'getInstance',
494
+ value: function getInstance(el) {
495
+ var domElem = !!el.jquery ? el[0] : el;
496
+ return domElem.M_Materialbox;
497
+ }
498
+ }, {
499
+ key: 'defaults',
500
+ get: function () {
501
+ return _defaults;
502
+ }
503
+ }]);
504
+
505
+ return Materialbox;
506
+ }(Component);
507
+
508
+ M.Materialbox = Materialbox;
509
+
510
+ if (M.jQueryLoaded) {
511
+ M.initializeJqueryWrapper(Materialbox, 'materialbox', 'M_Materialbox');
512
+ }
513
+ })(cash, M.anime);