materialize-sass 0.99.0 → 0.100.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/app/assets/javascripts/materialize.js +6015 -5060
  4. data/app/assets/javascripts/materialize/animation.js +4 -5
  5. data/app/assets/javascripts/materialize/buttons.js +24 -38
  6. data/app/assets/javascripts/materialize/cards.js +13 -21
  7. data/app/assets/javascripts/materialize/carousel.js +122 -110
  8. data/app/assets/javascripts/materialize/character_counter.js +14 -22
  9. data/app/assets/javascripts/materialize/chips.js +41 -44
  10. data/app/assets/javascripts/materialize/collapsible.js +41 -46
  11. data/app/assets/javascripts/materialize/date_picker/picker.date.js +965 -1167
  12. data/app/assets/javascripts/materialize/date_picker/picker.js +546 -634
  13. data/app/assets/javascripts/materialize/date_picker/picker.time.js +166 -212
  14. data/app/assets/javascripts/materialize/dropdown.js +53 -68
  15. data/app/assets/javascripts/materialize/extras/nouislider.js +3 -1
  16. data/app/assets/javascripts/materialize/extras/nouislider.min.js +1 -1
  17. data/app/assets/javascripts/materialize/forms.js +156 -154
  18. data/app/assets/javascripts/materialize/global.js +34 -43
  19. data/app/assets/javascripts/materialize/hammer.min.js +424 -1
  20. data/app/assets/javascripts/materialize/initial.js +3 -3
  21. data/app/assets/javascripts/materialize/jquery.easing.1.4.js +120 -142
  22. data/app/assets/javascripts/materialize/jquery.hammer.js +9 -9
  23. data/app/assets/javascripts/materialize/materialbox.js +81 -107
  24. data/app/assets/javascripts/materialize/modal.js +373 -162
  25. data/app/assets/javascripts/materialize/parallax.js +11 -15
  26. data/app/assets/javascripts/materialize/pushpin.js +2 -5
  27. data/app/assets/javascripts/materialize/scrollFire.js +9 -11
  28. data/app/assets/javascripts/materialize/scrollspy.js +84 -92
  29. data/app/assets/javascripts/materialize/sideNav.js +128 -139
  30. data/app/assets/javascripts/materialize/slider.js +83 -112
  31. data/app/assets/javascripts/materialize/tabs.js +196 -196
  32. data/app/assets/javascripts/materialize/tapTarget.js +170 -173
  33. data/app/assets/javascripts/materialize/toasts.js +330 -112
  34. data/app/assets/javascripts/materialize/tooltip.js +134 -145
  35. data/app/assets/javascripts/materialize/transitions.js +43 -49
  36. data/app/assets/javascripts/materialize/velocity.min.js +623 -2
  37. data/app/assets/javascripts/materialize/waves.js +42 -47
  38. data/app/assets/stylesheets/materialize/components/_buttons.scss +1 -1
  39. data/app/assets/stylesheets/materialize/components/_carousel.scss +4 -5
  40. data/app/assets/stylesheets/materialize/components/_chips.scss +1 -0
  41. data/app/assets/stylesheets/materialize/components/_collapsible.scss +4 -7
  42. data/app/assets/stylesheets/materialize/components/_color.scss +1 -1
  43. data/app/assets/stylesheets/materialize/components/_global.scss +8 -14
  44. data/app/assets/stylesheets/materialize/components/_navbar.scss +0 -1
  45. data/app/assets/stylesheets/materialize/components/_tabs.scss +1 -7
  46. data/app/assets/stylesheets/materialize/components/_toast.scss +6 -12
  47. data/app/assets/stylesheets/materialize/components/_variables.scss +55 -43
  48. data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +1 -0
  49. data/app/assets/stylesheets/materialize/components/forms/_checkboxes.scss +2 -12
  50. data/app/assets/stylesheets/materialize/components/forms/_file-input.scss +6 -0
  51. data/app/assets/stylesheets/materialize/components/forms/_input-fields.scss +67 -37
  52. data/app/assets/stylesheets/materialize/components/forms/_radio-buttons.scss +1 -3
  53. data/app/assets/stylesheets/materialize/components/forms/_select.scss +72 -11
  54. data/app/assets/stylesheets/materialize/components/forms/_switches.scss +2 -4
  55. data/app/assets/stylesheets/materialize/extras/nouislider.css +8 -1
  56. data/lib/materialize-sass/version.rb +1 -1
  57. metadata +2 -5
  58. data/app/assets/javascripts/materialize/init.js +0 -214
  59. data/app/assets/javascripts/materialize/jquery.timeago.min.js +0 -1
  60. data/app/assets/javascripts/materialize/prism.js +0 -8
@@ -1,185 +1,396 @@
1
- (function($) {
2
- var _stack = 0,
3
- _lastID = 0,
4
- _generateID = function() {
5
- _lastID++;
6
- return 'materialize-modal-overlay-' + _lastID;
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 ($) {
6
+ 'use strict';
7
+
8
+ var _defaults = {
9
+ opacity: 0.5,
10
+ inDuration: 250,
11
+ outDuration: 250,
12
+ ready: undefined,
13
+ complete: undefined,
14
+ dismissible: true,
15
+ startingTop: '4%',
16
+ endingTop: '10%'
7
17
  };
8
18
 
9
- var methods = {
10
- init : function(options) {
11
- var defaults = {
12
- opacity: 0.5,
13
- inDuration: 350,
14
- outDuration: 250,
15
- ready: undefined,
16
- complete: undefined,
17
- dismissible: true,
18
- startingTop: '4%',
19
- endingTop: '10%'
20
- };
21
-
22
- // Override defaults
23
- options = $.extend(defaults, options);
24
-
25
- return this.each(function() {
26
- var $modal = $(this);
27
- var modal_id = $(this).attr("id") || '#' + $(this).data('target');
28
-
29
- var closeModal = function() {
30
- var overlayID = $modal.data('overlay-id');
31
- var $overlay = $('#' + overlayID);
32
- $modal.removeClass('open');
33
-
34
- // Enable scrolling
35
- $('body').css({
36
- overflow: '',
37
- width: ''
38
- });
39
-
40
- $modal.find('.modal-close').off('click.close');
41
- $(document).off('keyup.modal' + overlayID);
42
-
43
- $overlay.velocity( { opacity: 0}, {duration: options.outDuration, queue: false, ease: "easeOutQuart"});
44
-
45
-
46
- // Define Bottom Sheet animation
47
- var exitVelocityOptions = {
48
- duration: options.outDuration,
49
- queue: false,
50
- ease: "easeOutCubic",
51
- // Handle modal ready callback
52
- complete: function() {
53
- $(this).css({display:"none"});
54
-
55
- // Call complete callback
56
- if (typeof(options.complete) === "function") {
57
- options.complete.call(this, $modal);
58
- }
59
- $overlay.remove();
60
- _stack--;
61
- }
62
- };
63
- if ($modal.hasClass('bottom-sheet')) {
64
- $modal.velocity({bottom: "-100%", opacity: 0}, exitVelocityOptions);
19
+ /**
20
+ * @class
21
+ *
22
+ */
23
+
24
+ var Modal = function () {
25
+ /**
26
+ * Construct Modal instance and set up overlay
27
+ * @constructor
28
+ * @param {jQuery} $el
29
+ * @param {Object} options
30
+ */
31
+ function Modal($el, options) {
32
+ _classCallCheck(this, Modal);
33
+
34
+ // If exists, destroy and reinitialize
35
+ if (!!$el[0].M_Modal) {
36
+ $el[0].M_Modal.destroy();
37
+ }
38
+
39
+ /**
40
+ * The jQuery element
41
+ * @type {jQuery}
42
+ */
43
+ this.$el = $el;
44
+
45
+ /**
46
+ * Options for the modal
47
+ * @member Modal#options
48
+ * @prop {Number} [opacity=0.5] - Opacity of the modal overlay
49
+ * @prop {Number} [inDuration=250] - Length in ms of enter transition
50
+ * @prop {Number} [outDuration=250] - Length in ms of exit transition
51
+ * @prop {Function} ready - Callback function called when modal is finished entering
52
+ * @prop {Function} complete - Callback function called when modal is finished exiting
53
+ * @prop {Boolean} [dismissible=true] - Allow modal to be dismissed by keyboard or overlay click
54
+ * @prop {String} [startingTop='4%'] - startingTop
55
+ * @prop {String} [endingTop='10%'] - endingTop
56
+ */
57
+ this.options = $.extend({}, Modal.defaults, options);
58
+
59
+ /**
60
+ * Describes open/close state of modal
61
+ * @type {Boolean}
62
+ */
63
+ this.isOpen = false;
64
+
65
+ this.$el[0].M_Modal = this;
66
+ this.id = $el.attr('id');
67
+ this.openingTrigger = undefined;
68
+ this.$overlay = $('<div class="modal-overlay"></div>');
69
+
70
+ Modal._increment++;
71
+ Modal._count++;
72
+ this.$overlay[0].style.zIndex = 1000 + Modal._increment * 2;
73
+ this.$el[0].style.zIndex = 1000 + Modal._increment * 2 + 1;
74
+ this.setupEventHandlers();
75
+ }
76
+
77
+ _createClass(Modal, [{
78
+ key: 'getInstance',
79
+
80
+
81
+ /**
82
+ * Get Instance
83
+ */
84
+ value: function getInstance() {
85
+ return this;
86
+ }
87
+
88
+ /**
89
+ * Teardown component
90
+ */
91
+
92
+ }, {
93
+ key: 'destroy',
94
+ value: function destroy() {
95
+ this.removeEventHandlers();
96
+ this.$el[0].removeAttribute('style');
97
+ if (!!this.$overlay[0].parentNode) {
98
+ this.$overlay[0].parentNode.removeChild(this.$overlay[0]);
99
+ }
100
+ this.$el[0].M_Modal = undefined;
101
+ Modal._count--;
102
+ }
103
+
104
+ /**
105
+ * Setup Event Handlers
106
+ */
107
+
108
+ }, {
109
+ key: 'setupEventHandlers',
110
+ value: function setupEventHandlers() {
111
+ this.handleOverlayClickBound = this.handleOverlayClick.bind(this);
112
+ this.handleModalCloseClickBound = this.handleModalCloseClick.bind(this);
113
+
114
+ if (Modal._count === 1) {
115
+ document.addEventListener('click', this.handleTriggerClick);
116
+ }
117
+ this.$overlay[0].addEventListener('click', this.handleOverlayClickBound);
118
+ this.$el[0].addEventListener('click', this.handleModalCloseClickBound);
119
+ }
120
+
121
+ /**
122
+ * Remove Event Handlers
123
+ */
124
+
125
+ }, {
126
+ key: 'removeEventHandlers',
127
+ value: function removeEventHandlers() {
128
+ if (Modal._count === 0) {
129
+ document.removeEventListener('click', this.handleTriggerClick);
130
+ }
131
+ this.$overlay[0].removeEventListener('click', this.handleOverlayClickBound);
132
+ this.$el[0].removeEventListener('click', this.handleModalCloseClickBound);
133
+ }
134
+
135
+ /**
136
+ * Handle Trigger Click
137
+ * @param {Event} e
138
+ */
139
+
140
+ }, {
141
+ key: 'handleTriggerClick',
142
+ value: function handleTriggerClick(e) {
143
+ var $trigger = $(e.target).closest('.modal-trigger');
144
+ if (e.target && $trigger.length) {
145
+ var modalId = $trigger[0].getAttribute('href');
146
+ if (modalId) {
147
+ modalId = modalId.slice(1);
148
+ } else {
149
+ modalId = $trigger[0].getAttribute('data-target');
65
150
  }
66
- else {
67
- $modal.velocity(
68
- { top: options.startingTop, opacity: 0, scaleX: 0.7},
69
- exitVelocityOptions
70
- );
151
+ var modalInstance = document.getElementById(modalId).M_Modal;
152
+ if (modalInstance) {
153
+ modalInstance.open($trigger);
71
154
  }
72
- };
155
+ e.preventDefault();
156
+ }
157
+ }
73
158
 
74
- var openModal = function($trigger) {
75
- var $body = $('body');
76
- var oldWidth = $body.innerWidth();
77
- $body.css('overflow', 'hidden');
78
- $body.width(oldWidth);
159
+ /**
160
+ * Handle Overlay Click
161
+ */
79
162
 
80
- if ($modal.hasClass('open')) {
81
- return;
82
- }
163
+ }, {
164
+ key: 'handleOverlayClick',
165
+ value: function handleOverlayClick() {
166
+ if (this.options.dismissible) {
167
+ this.close();
168
+ }
169
+ }
83
170
 
84
- var overlayID = _generateID();
85
- var $overlay = $('<div class="modal-overlay"></div>');
86
- var lStack = (++_stack);
87
-
88
- // Store a reference of the overlay
89
- $overlay.attr('id', overlayID).css('z-index', 1000 + lStack * 2);
90
- $modal.data('overlay-id', overlayID).css('z-index', 1000 + lStack * 2 + 1);
91
- $modal.addClass('open');
92
-
93
- $("body").append($overlay);
94
-
95
- if (options.dismissible) {
96
- $overlay.click(function() {
97
- closeModal();
98
- });
99
- // Return on ESC
100
- $(document).on('keyup.modal' + overlayID, function(e) {
101
- if (e.keyCode === 27) { // ESC key
102
- closeModal();
103
- }
104
- });
105
- }
171
+ /**
172
+ * Handle Modal Close Click
173
+ * @param {Event} e
174
+ */
175
+
176
+ }, {
177
+ key: 'handleModalCloseClick',
178
+ value: function handleModalCloseClick(e) {
179
+ if (e.target && e.target.classList.contains('modal-close')) {
180
+ this.close();
181
+ }
182
+ }
183
+
184
+ /**
185
+ * Handle Keydown
186
+ * @param {Event} e
187
+ */
188
+
189
+ }, {
190
+ key: 'handleKeydown',
191
+ value: function handleKeydown(e) {
192
+ // ESC key
193
+ if (e.keyCode === 27 && this.options.dismissible) {
194
+ this.close();
195
+ }
196
+ }
106
197
 
107
- $modal.find(".modal-close").on('click.close', function(e) {
108
- closeModal();
109
- });
110
-
111
- $overlay.css({ display : "block", opacity : 0 });
112
-
113
- $modal.css({
114
- display : "block",
115
- opacity: 0
116
- });
117
-
118
- $overlay.velocity({opacity: options.opacity}, {duration: options.inDuration, queue: false, ease: "easeOutCubic"});
119
- $modal.data('associated-overlay', $overlay[0]);
120
-
121
- // Define Bottom Sheet animation
122
- var enterVelocityOptions = {
123
- duration: options.inDuration,
124
- queue: false,
125
- ease: "easeOutCubic",
126
- // Handle modal ready callback
127
- complete: function() {
128
- if (typeof(options.ready) === "function") {
129
- options.ready.call(this, $modal, $trigger);
130
- }
198
+ /**
199
+ * Animate in modal
200
+ */
201
+
202
+ }, {
203
+ key: 'animateIn',
204
+ value: function animateIn() {
205
+ var _this = this;
206
+
207
+ // Set initial styles
208
+ $.extend(this.$el[0].style, {
209
+ display: 'block',
210
+ opacity: 0
211
+ });
212
+ $.extend(this.$overlay[0].style, {
213
+ display: 'block',
214
+ opacity: 0
215
+ });
216
+
217
+ // Animate overlay
218
+ Vel(this.$overlay[0], { opacity: this.options.opacity }, { duration: this.options.inDuration, queue: false, ease: 'easeOutCubic' });
219
+
220
+ // Define modal animation options
221
+ var enterVelocityOptions = {
222
+ duration: this.options.inDuration,
223
+ queue: false,
224
+ ease: 'easeOutCubic',
225
+ // Handle modal ready callback
226
+ complete: function () {
227
+ if (typeof _this.options.ready === 'function') {
228
+ _this.options.ready.call(_this, _this.$el, _this.openingTrigger);
131
229
  }
132
- };
133
- if ($modal.hasClass('bottom-sheet')) {
134
- $modal.velocity({bottom: "0", opacity: 1}, enterVelocityOptions);
135
- }
136
- else {
137
- $.Velocity.hook($modal, "scaleX", 0.7);
138
- $modal.css({ top: options.startingTop });
139
- $modal.velocity({top: options.endingTop, opacity: 1, scaleX: '1'}, enterVelocityOptions);
140
230
  }
231
+ };
232
+
233
+ // Bottom sheet animation
234
+ if (this.$el[0].classList.contains('bottom-sheet')) {
235
+ Vel(this.$el[0], { bottom: 0, opacity: 1 }, enterVelocityOptions);
236
+
237
+ // Normal modal animation
238
+ } else {
239
+ Vel.hook(this.$el[0], 'scaleX', 0.7);
240
+ this.$el[0].style.top = this.options.startingTop;
241
+ Vel(this.$el[0], { top: this.options.endingTop, opacity: 1, scaleX: 1 }, enterVelocityOptions);
242
+ }
243
+ }
244
+
245
+ /**
246
+ * Animate out modal
247
+ */
248
+
249
+ }, {
250
+ key: 'animateOut',
251
+ value: function animateOut() {
252
+ var _this2 = this;
253
+
254
+ // Animate overlay
255
+ Vel(this.$overlay[0], { opacity: 0 }, { duration: this.options.outDuration, queue: false, ease: 'easeOutQuart' });
141
256
 
257
+ // Define modal animation options
258
+ var exitVelocityOptions = {
259
+ duration: this.options.outDuration,
260
+ queue: false,
261
+ ease: 'easeOutCubic',
262
+ // Handle modal ready callback
263
+ complete: function () {
264
+ _this2.$el[0].style.display = 'none';
265
+ // Call complete callback
266
+ if (typeof _this2.options.complete === 'function') {
267
+ _this2.options.complete.call(_this2, _this2.$el);
268
+ }
269
+ _this2.$overlay[0].remove();
270
+ }
142
271
  };
143
272
 
144
- // Reset handlers
145
- $(document).off('click.modalTrigger', 'a[href="#' + modal_id + '"], [data-target="' + modal_id + '"]');
146
- $(this).off('openModal');
147
- $(this).off('closeModal');
273
+ // Bottom sheet animation
274
+ if (this.$el[0].classList.contains('bottom-sheet')) {
275
+ Vel(this.$el[0], { bottom: '-100%', opacity: 0 }, exitVelocityOptions);
148
276
 
149
- // Close Handlers
150
- $(document).on('click.modalTrigger', 'a[href="#' + modal_id + '"], [data-target="' + modal_id + '"]', function(e) {
151
- options.startingTop = ($(this).offset().top - $(window).scrollTop()) /1.15;
152
- openModal($(this));
153
- e.preventDefault();
154
- }); // done set on click
277
+ // Normal modal animation
278
+ } else {
279
+ Vel(this.$el[0], { top: this.options.startingTop, opacity: 0, scaleX: 0.7 }, exitVelocityOptions);
280
+ }
281
+ }
282
+
283
+ /**
284
+ * Open Modal
285
+ * @param {jQuery} [$trigger]
286
+ */
287
+
288
+ }, {
289
+ key: 'open',
290
+ value: function open($trigger) {
291
+ if (this.isOpen) {
292
+ return;
293
+ }
294
+
295
+ this.isOpen = true;
296
+ var body = document.body;
297
+ body.style.overflow = 'hidden';
298
+ this.$el[0].classList.add('open');
299
+ body.appendChild(this.$overlay[0]);
300
+
301
+ // Set opening trigger, undefined indicates modal was opened by javascript
302
+ this.openingTrigger = !!$trigger ? $trigger : undefined;
303
+
304
+ if (this.options.dismissible) {
305
+ this.handleKeydownBound = this.handleKeydown.bind(this);
306
+ document.addEventListener('keydown', this.handleKeydownBound);
307
+ }
155
308
 
156
- $(this).on('openModal', function() {
157
- var modal_id = $(this).attr("href") || '#' + $(this).data('target');
158
- openModal();
309
+ this.animateIn();
310
+
311
+ return this;
312
+ }
313
+
314
+ /**
315
+ * Close Modal
316
+ */
317
+
318
+ }, {
319
+ key: 'close',
320
+ value: function close() {
321
+ if (!this.isOpen) {
322
+ return;
323
+ }
324
+
325
+ this.isOpen = false;
326
+ this.$el[0].classList.remove('open');
327
+ document.body.style.overflow = null;
328
+
329
+ if (this.options.dismissible) {
330
+ document.removeEventListener('keydown', this.handleKeydownBound);
331
+ }
332
+
333
+ this.animateOut();
334
+
335
+ return this;
336
+ }
337
+ }], [{
338
+ key: 'init',
339
+ value: function init($els, options) {
340
+ var arr = [];
341
+ $els.each(function () {
342
+ arr.push(new Modal($(this), options));
159
343
  });
344
+ return arr;
345
+ }
346
+ }, {
347
+ key: 'defaults',
348
+ get: function () {
349
+ return _defaults;
350
+ }
351
+ }]);
352
+
353
+ return Modal;
354
+ }();
355
+
356
+ /**
357
+ * @static
358
+ * @memberof Modal
359
+ */
160
360
 
161
- $(this).on('closeModal', function() {
162
- closeModal();
361
+
362
+ Modal._increment = 0;
363
+
364
+ /**
365
+ * @static
366
+ * @memberof Modal
367
+ */
368
+ Modal._count = 0;
369
+
370
+ window.Materialize.Modal = Modal;
371
+
372
+ $.fn.modal = function (methodOrOptions) {
373
+ // Call plugin method if valid method name is passed in
374
+ if (Modal.prototype[methodOrOptions]) {
375
+ // Getter methods
376
+ if (methodOrOptions.slice(0, 3) === 'get') {
377
+ return this.first()[0].M_Modal[methodOrOptions]();
378
+
379
+ // Void methods
380
+ } else {
381
+ return this.each(function () {
382
+ this.M_Modal[methodOrOptions]();
163
383
  });
164
- }); // done return
165
- },
166
- open : function() {
167
- methods.init.apply( this, arguments );
168
- $(this).trigger('openModal');
169
- },
170
- close : function() {
171
- $(this).trigger('closeModal');
172
- }
173
- };
384
+ }
385
+
386
+ // Initialize plugin if options or no argument is passed in
387
+ } else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
388
+ Modal.init(this, arguments[0]);
389
+ return this;
174
390
 
175
- $.fn.modal = function(methodOrOptions) {
176
- if ( methods[methodOrOptions] ) {
177
- return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
178
- } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
179
- // Default to "init"
180
- return methods.init.apply( this, arguments );
391
+ // Return error if an unrecognized method name is passed in
181
392
  } else {
182
- $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.modal' );
393
+ $.error('Method ' + methodOrOptions + ' does not exist on jQuery.modal');
183
394
  }
184
395
  };
185
396
  })(jQuery);