materialize-sass 0.97.8 → 0.98.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +1 -1
  4. data/app/assets/javascripts/materialize.js +5 -5
  5. data/app/assets/javascripts/materialize/animation.js +8 -9
  6. data/app/assets/javascripts/materialize/carousel.js +52 -25
  7. data/app/assets/javascripts/materialize/character_counter.js +2 -2
  8. data/app/assets/javascripts/materialize/chips.js +39 -10
  9. data/app/assets/javascripts/materialize/dropdown.js +12 -12
  10. data/app/assets/javascripts/materialize/extras/nouislider.js +1917 -1438
  11. data/app/assets/javascripts/materialize/extras/nouislider.min.js +1 -1
  12. data/app/assets/javascripts/materialize/forms.js +131 -35
  13. data/app/assets/javascripts/materialize/global.js +55 -0
  14. data/app/assets/javascripts/materialize/init.js +41 -4
  15. data/app/assets/javascripts/materialize/jquery.hammer.js +0 -0
  16. data/app/assets/javascripts/materialize/materialbox.js +86 -77
  17. data/app/assets/javascripts/materialize/modal.js +12 -12
  18. data/app/assets/javascripts/materialize/parallax.js +48 -48
  19. data/app/assets/javascripts/materialize/scrollFire.js +40 -37
  20. data/app/assets/javascripts/materialize/scrollspy.js +2 -53
  21. data/app/assets/javascripts/materialize/sideNav.js +46 -40
  22. data/app/assets/javascripts/materialize/slider.js +15 -12
  23. data/app/assets/javascripts/materialize/tabs.js +104 -35
  24. data/app/assets/javascripts/materialize/toasts.js +122 -123
  25. data/app/assets/javascripts/materialize/tooltip.js +15 -13
  26. data/app/assets/javascripts/materialize/transitions.js +24 -24
  27. data/app/assets/stylesheets/materialize.scss +2 -0
  28. data/app/assets/stylesheets/materialize/components/_badges.scss +46 -0
  29. data/app/assets/stylesheets/materialize/components/_buttons.scss +29 -17
  30. data/app/assets/stylesheets/materialize/components/_cards.scss +9 -3
  31. data/app/assets/stylesheets/materialize/components/_carousel.scss +1 -1
  32. data/app/assets/stylesheets/materialize/components/_collapsible.scss +3 -7
  33. data/app/assets/stylesheets/materialize/components/_global.scss +6 -62
  34. data/app/assets/stylesheets/materialize/components/_icons-material-design.scss +0 -0
  35. data/app/assets/stylesheets/materialize/components/_materialbox.scss +13 -12
  36. data/app/assets/stylesheets/materialize/components/_navbar.scss +26 -7
  37. data/app/assets/stylesheets/materialize/components/_prefixer.scss +0 -0
  38. data/app/assets/stylesheets/materialize/components/_sideNav.scss +8 -5
  39. data/app/assets/stylesheets/materialize/components/_table_of_contents.scss +2 -2
  40. data/app/assets/stylesheets/materialize/components/_tabs.scss +0 -0
  41. data/app/assets/stylesheets/materialize/components/_toast.scss +1 -1
  42. data/app/assets/stylesheets/materialize/components/_tooltip.scss +2 -3
  43. data/app/assets/stylesheets/materialize/components/_transitions.scss +13 -0
  44. data/app/assets/stylesheets/materialize/components/_typography.scss +0 -0
  45. data/app/assets/stylesheets/materialize/components/_variables.scss +7 -1
  46. data/app/assets/stylesheets/materialize/components/_waves.scss +80 -143
  47. data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +0 -0
  48. data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +0 -0
  49. data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +0 -0
  50. data/app/assets/stylesheets/materialize/components/forms/_input-fields.scss +4 -4
  51. data/app/assets/stylesheets/materialize/extras/nouislider.css +263 -123
  52. data/lib/materialize-sass/version.rb +1 -1
  53. metadata +4 -2
@@ -180,10 +180,13 @@
180
180
  var direction = e.gesture.direction;
181
181
  var x = e.gesture.deltaX;
182
182
  var velocityX = e.gesture.velocityX;
183
+ var velocityY = e.gesture.velocityY;
183
184
 
184
185
  $curr_slide = $slider.find('.active');
185
- $curr_slide.velocity({ translateX: x
186
- }, {duration: 50, queue: false, easing: 'easeOutQuad'});
186
+ if (Math.abs(velocityX) > Math.abs(velocityY)) {
187
+ $curr_slide.velocity({ translateX: x
188
+ }, {duration: 50, queue: false, easing: 'easeOutQuad'});
189
+ }
187
190
 
188
191
  // Swipe Left
189
192
  if (direction === 4 && (x > ($this.innerWidth() / 2) || velocityX < -0.65)) {
@@ -308,14 +311,14 @@
308
311
  };
309
312
 
310
313
 
311
- $.fn.slider = function(methodOrOptions) {
312
- if ( methods[methodOrOptions] ) {
313
- return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
314
- } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
315
- // Default to "init"
316
- return methods.init.apply( this, arguments );
317
- } else {
318
- $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.tooltip' );
319
- }
320
- }; // Plugin end
314
+ $.fn.slider = function(methodOrOptions) {
315
+ if ( methods[methodOrOptions] ) {
316
+ return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
317
+ } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
318
+ // Default to "init"
319
+ return methods.init.apply( this, arguments );
320
+ } else {
321
+ $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.tooltip' );
322
+ }
323
+ }; // Plugin end
321
324
  }( jQuery ));
@@ -3,7 +3,9 @@
3
3
  var methods = {
4
4
  init : function(options) {
5
5
  var defaults = {
6
- onShow: null
6
+ onShow: null,
7
+ swipeable: false,
8
+ responsiveThreshold: Infinity, // breakpoint for swipeable
7
9
  };
8
10
  options = $.extend(defaults, options);
9
11
 
@@ -16,8 +18,15 @@
16
18
 
17
19
  var $active, $content, $links = $this.find('li.tab a'),
18
20
  $tabs_width = $this.width(),
21
+ $tabs_content = $(),
22
+ $tabs_wrapper,
19
23
  $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length,
20
- $index = 0;
24
+ $indicator,
25
+ index = prev_index = 0,
26
+ clicked = false,
27
+ clickedTimeout,
28
+ transition = 300;
29
+
21
30
 
22
31
  // Finds right attribute for indicator based on active tab.
23
32
  // el: jQuery Object
@@ -31,6 +40,27 @@
31
40
  return el.position().left + $this.scrollLeft();
32
41
  };
33
42
 
43
+ // Animates Indicator to active tab.
44
+ // prev_index: Number
45
+ var animateIndicator = function(prev_index) {
46
+ if ((index - prev_index) >= 0) {
47
+ $indicator.velocity({"right": calcRightPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad'});
48
+ $indicator.velocity({"left": calcLeftPos($active) }, {duration: transition, queue: false, easing: 'easeOutQuad', delay: 90});
49
+
50
+ } else {
51
+ $indicator.velocity({"left": calcLeftPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad'});
52
+ $indicator.velocity({"right": calcRightPos($active) }, {duration: transition, queue: false, easing: 'easeOutQuad', delay: 90});
53
+ }
54
+ };
55
+
56
+ // Change swipeable according to responsive threshold
57
+ if (options.swipeable) {
58
+ if (window_width > options.responsiveThreshold) {
59
+ options.swipeable = false;
60
+ }
61
+ }
62
+
63
+
34
64
  // If the location.hash matches one of the links, use that as the active tab.
35
65
  $active = $($links.filter('[href="'+location.hash+'"]'));
36
66
 
@@ -43,21 +73,28 @@
43
73
  }
44
74
 
45
75
  $active.addClass('active');
46
- $index = $links.index($active);
47
- if ($index < 0) {
48
- $index = 0;
76
+ index = $links.index($active);
77
+ if (index < 0) {
78
+ index = 0;
49
79
  }
50
80
 
51
81
  if ($active[0] !== undefined) {
52
82
  $content = $($active[0].hash);
83
+ $content.addClass('active');
53
84
  }
54
85
 
55
86
  // append indicator then set indicator width to tab width
56
- $this.append('<div class="indicator"></div>');
57
- var $indicator = $this.find('.indicator');
87
+ if (!$this.find('.indicator').length) {
88
+ $this.append('<div class="indicator"></div>');
89
+ }
90
+ $indicator = $this.find('.indicator');
91
+
92
+ // we make sure that the indicator is at the end of the tabs
93
+ $this.append($indicator);
94
+
58
95
  if ($this.is(":visible")) {
59
- // $indicator.css({"right": $tabs_width - (($index + 1) * $tab_width)});
60
- // $indicator.css({"left": $index * $tab_width});
96
+ // $indicator.css({"right": $tabs_width - ((index + 1) * $tab_width)});
97
+ // $indicator.css({"left": index * $tab_width});
61
98
  setTimeout(function() {
62
99
  $indicator.css({"right": calcRightPos($active) });
63
100
  $indicator.css({"left": calcLeftPos($active) });
@@ -66,8 +103,8 @@
66
103
  $(window).resize(function () {
67
104
  $tabs_width = $this.width();
68
105
  $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length;
69
- if ($index < 0) {
70
- $index = 0;
106
+ if (index < 0) {
107
+ index = 0;
71
108
  }
72
109
  if ($tab_width !== 0 && $tabs_width !== 0) {
73
110
  $indicator.css({"right": calcRightPos($active) });
@@ -75,10 +112,34 @@
75
112
  }
76
113
  });
77
114
 
78
- // Hide the remaining content
79
- $links.not($active).each(function () {
80
- $(Materialize.escapeHash(this.hash)).hide();
81
- });
115
+ // Initialize Tabs Content.
116
+ if (options.swipeable) {
117
+ // TODO: Duplicate calls with swipeable? handle multiple div wrapping.
118
+ $links.each(function () {
119
+ var $curr_content = $(Materialize.escapeHash(this.hash));
120
+ $curr_content.addClass('carousel-item');
121
+ $tabs_content = $tabs_content.add($curr_content);
122
+ });
123
+ $tabs_wrapper = $tabs_content.wrapAll('<div class="tabs-content carousel"></div>');
124
+ $tabs_content.css('display', '');
125
+ $('.tabs-content.carousel').carousel({
126
+ fullWidth: true,
127
+ noWrap: true,
128
+ onCycleTo: function(item) {
129
+ if (!clicked) {
130
+ var prev_index = index;
131
+ index = $tabs_wrapper.index(item);
132
+ $active = $links.eq(index);
133
+ animateIndicator(prev_index);
134
+ }
135
+ },
136
+ });
137
+ } else {
138
+ // Hide the remaining content
139
+ $links.not($active).each(function () {
140
+ $(Materialize.escapeHash(this.hash)).hide();
141
+ });
142
+ }
82
143
 
83
144
 
84
145
  // Bind the click event handler
@@ -93,14 +154,13 @@
93
154
  return;
94
155
  }
95
156
 
157
+ clicked = true;
96
158
  $tabs_width = $this.width();
97
159
  $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length;
98
160
 
99
161
  // Make the old tab inactive.
100
162
  $active.removeClass('active');
101
- if ($content !== undefined) {
102
- $content.hide();
103
- }
163
+ var $oldContent = $content
104
164
 
105
165
  // Update the variables with the new link and content
106
166
  $active = $(this);
@@ -110,31 +170,40 @@
110
170
 
111
171
  // Make the tab active.
112
172
  $active.addClass('active');
113
- var $prev_index = $index;
114
- $index = $links.index($(this));
115
- if ($index < 0) {
116
- $index = 0;
173
+ prev_index = index;
174
+ index = $links.index($(this));
175
+ if (index < 0) {
176
+ index = 0;
117
177
  }
118
178
  // Change url to current tab
119
179
  // window.location.hash = $active.attr('href');
120
180
 
121
- if ($content !== undefined) {
122
- $content.show();
123
- if (typeof(options.onShow) === "function") {
124
- options.onShow.call(this, $content);
181
+ // Swap content
182
+ if (options.swipeable) {
183
+ if ($tabs_content.length) {
184
+ $tabs_content.carousel('set', index);
185
+ }
186
+ } else {
187
+ if ($content !== undefined) {
188
+ $content.show();
189
+ $content.addClass('active');
190
+ if (typeof(options.onShow) === "function") {
191
+ options.onShow.call(this, $content);
192
+ }
125
193
  }
126
- }
127
194
 
128
- // Update indicator
195
+ if ($oldContent !== undefined &&
196
+ !$oldContent.is($content)) {
197
+ $oldContent.hide();
198
+ $oldContent.removeClass('active');
199
+ }
200
+ }
129
201
 
130
- if (($index - $prev_index) >= 0) {
131
- $indicator.velocity({"right": calcRightPos($active) }, { duration: 300, queue: false, easing: 'easeOutQuad'});
132
- $indicator.velocity({"left": calcLeftPos($active) }, {duration: 300, queue: false, easing: 'easeOutQuad', delay: 90});
202
+ // Reset clicked state
203
+ clickedTimeout = setTimeout(function(){ clicked = false; }, transition);
133
204
 
134
- } else {
135
- $indicator.velocity({"left": calcLeftPos($active) }, { duration: 300, queue: false, easing: 'easeOutQuad'});
136
- $indicator.velocity({"right": calcRightPos($active) }, {duration: 300, queue: false, easing: 'easeOutQuad', delay: 90});
137
- }
205
+ // Update indicator
206
+ animateIndicator(prev_index);
138
207
 
139
208
  // Prevent the anchor's default click action
140
209
  e.preventDefault();
@@ -1,137 +1,136 @@
1
1
  Materialize.toast = function (message, displayLength, className, completeCallback) {
2
- className = className || "";
2
+ className = className || "";
3
+
4
+ var container = document.getElementById('toast-container');
5
+
6
+ // Create toast container if it does not exist
7
+ if (container === null) {
8
+ // create notification container
9
+ container = document.createElement('div');
10
+ container.id = 'toast-container';
11
+ document.body.appendChild(container);
12
+ }
13
+
14
+ // Select and append toast
15
+ var newToast = createToast(message);
16
+
17
+ // only append toast if message is not undefined
18
+ if(message){
19
+ container.appendChild(newToast);
20
+ }
21
+
22
+ newToast.style.opacity = 0;
23
+
24
+ // Animate toast in
25
+ Vel(newToast, {translateY: '-35px', opacity: 1 }, {duration: 300,
26
+ easing: 'easeOutCubic',
27
+ queue: false});
28
+
29
+ // Allows timer to be pause while being panned
30
+ var timeLeft = displayLength;
31
+ var counterInterval;
32
+ if (timeLeft != null) {
33
+ counterInterval = setInterval (function(){
34
+ if (newToast.parentNode === null)
35
+ window.clearInterval(counterInterval);
36
+
37
+ // If toast is not being dragged, decrease its time remaining
38
+ if (!newToast.classList.contains('panning')) {
39
+ timeLeft -= 20;
40
+ }
41
+
42
+ if (timeLeft <= 0) {
43
+ // Animate toast out
44
+ Vel(newToast, {"opacity": 0, marginTop: '-40px'}, { duration: 375,
45
+ easing: 'easeOutExpo',
46
+ queue: false,
47
+ complete: function(){
48
+ // Call the optional callback
49
+ if(typeof(completeCallback) === "function")
50
+ completeCallback();
51
+ // Remove toast after it times out
52
+ this[0].parentNode.removeChild(this[0]);
53
+ }
54
+ });
55
+ window.clearInterval(counterInterval);
56
+ }
57
+ }, 20);
58
+ }
3
59
 
4
- var container = document.getElementById('toast-container');
5
60
 
6
- // Create toast container if it does not exist
7
- if (container === null) {
8
- // create notification container
9
- container = document.createElement('div');
10
- container.id = 'toast-container';
11
- document.body.appendChild(container);
12
- }
13
61
 
14
- // Select and append toast
15
- var newToast = createToast(message);
62
+ function createToast(html) {
16
63
 
17
- // only append toast if message is not undefined
18
- if(message){
19
- container.appendChild(newToast);
20
- }
64
+ // Create toast
65
+ var toast = document.createElement('div');
66
+ toast.classList.add('toast');
67
+ if (className) {
68
+ var classes = className.split(' ');
21
69
 
22
- newToast.style.top = '35px';
23
- newToast.style.opacity = 0;
24
-
25
- // Animate toast in
26
- Vel(newToast, { "top" : "0px", opacity: 1 }, {duration: 300,
27
- easing: 'easeOutCubic',
28
- queue: false});
29
-
30
- // Allows timer to be pause while being panned
31
- var timeLeft = displayLength;
32
- var counterInterval;
33
- if (timeLeft != null) {
34
- counterInterval = setInterval (function(){
35
- if (newToast.parentNode === null)
36
- window.clearInterval(counterInterval);
37
-
38
- // If toast is not being dragged, decrease its time remaining
39
- if (!newToast.classList.contains('panning')) {
40
- timeLeft -= 20;
41
- }
42
-
43
- if (timeLeft <= 0) {
44
- // Animate toast out
45
- Vel(newToast, {"opacity": 0, marginTop: '-40px'}, { duration: 375,
46
- easing: 'easeOutExpo',
47
- queue: false,
48
- complete: function(){
49
- // Call the optional callback
50
- if(typeof(completeCallback) === "function")
51
- completeCallback();
52
- // Remove toast after it times out
53
- this[0].parentNode.removeChild(this[0]);
54
- }
55
- });
56
- window.clearInterval(counterInterval);
57
- }
58
- }, 20);
70
+ for (var i = 0, count = classes.length; i < count; i++) {
71
+ toast.classList.add(classes[i]);
72
+ }
59
73
  }
60
-
61
-
62
-
63
- function createToast(html) {
64
-
65
- // Create toast
66
- var toast = document.createElement('div');
67
- toast.classList.add('toast');
68
- if (className) {
69
- var classes = className.split(' ');
70
-
71
- for (var i = 0, count = classes.length; i < count; i++) {
72
- toast.classList.add(classes[i]);
73
- }
74
- }
75
- // If type of parameter is HTML Element
76
- if ( typeof HTMLElement === "object" ? html instanceof HTMLElement : html && typeof html === "object" && html !== null && html.nodeType === 1 && typeof html.nodeName==="string"
74
+ // If type of parameter is HTML Element
75
+ if ( typeof HTMLElement === "object" ? html instanceof HTMLElement : html && typeof html === "object" && html !== null && html.nodeType === 1 && typeof html.nodeName==="string"
77
76
  ) {
78
- toast.appendChild(html);
79
- }
80
- else if (html instanceof jQuery) {
81
- // Check if it is jQuery object
82
- toast.appendChild(html[0]);
83
- }
84
- else {
85
- // Insert as text;
86
- toast.innerHTML = html;
87
- }
88
- // Bind hammer
89
- var hammerHandler = new Hammer(toast, {prevent_default: false});
90
- hammerHandler.on('pan', function(e) {
91
- var deltaX = e.deltaX;
92
- var activationDistance = 80;
93
-
94
- // Change toast state
95
- if (!toast.classList.contains('panning')){
96
- toast.classList.add('panning');
77
+ toast.appendChild(html);
78
+ }
79
+ else if (html instanceof jQuery) {
80
+ // Check if it is jQuery object
81
+ toast.appendChild(html[0]);
82
+ }
83
+ else {
84
+ // Insert as text;
85
+ toast.innerHTML = html;
86
+ }
87
+ // Bind hammer
88
+ var hammerHandler = new Hammer(toast, {prevent_default: false});
89
+ hammerHandler.on('pan', function(e) {
90
+ var deltaX = e.deltaX;
91
+ var activationDistance = 80;
92
+
93
+ // Change toast state
94
+ if (!toast.classList.contains('panning')){
95
+ toast.classList.add('panning');
96
+ }
97
+
98
+ var opacityPercent = 1-Math.abs(deltaX / activationDistance);
99
+ if (opacityPercent < 0)
100
+ opacityPercent = 0;
101
+
102
+ Vel(toast, {left: deltaX, opacity: opacityPercent }, {duration: 50, queue: false, easing: 'easeOutQuad'});
103
+
104
+ });
105
+
106
+ hammerHandler.on('panend', function(e) {
107
+ var deltaX = e.deltaX;
108
+ var activationDistance = 80;
109
+
110
+ // If toast dragged past activation point
111
+ if (Math.abs(deltaX) > activationDistance) {
112
+ Vel(toast, {marginTop: '-40px'}, { duration: 375,
113
+ easing: 'easeOutExpo',
114
+ queue: false,
115
+ complete: function(){
116
+ if(typeof(completeCallback) === "function") {
117
+ completeCallback();
118
+ }
119
+ toast.parentNode.removeChild(toast);
97
120
  }
98
-
99
- var opacityPercent = 1-Math.abs(deltaX / activationDistance);
100
- if (opacityPercent < 0)
101
- opacityPercent = 0;
102
-
103
- Vel(toast, {left: deltaX, opacity: opacityPercent }, {duration: 50, queue: false, easing: 'easeOutQuad'});
104
-
105
121
  });
106
122
 
107
- hammerHandler.on('panend', function(e) {
108
- var deltaX = e.deltaX;
109
- var activationDistance = 80;
110
-
111
- // If toast dragged past activation point
112
- if (Math.abs(deltaX) > activationDistance) {
113
- Vel(toast, {marginTop: '-40px'}, { duration: 375,
114
- easing: 'easeOutExpo',
115
- queue: false,
116
- complete: function(){
117
- if(typeof(completeCallback) === "function") {
118
- completeCallback();
119
- }
120
- toast.parentNode.removeChild(toast);
121
- }
122
- });
123
-
124
- } else {
125
- toast.classList.remove('panning');
126
- // Put toast back into original position
127
- Vel(toast, { left: 0, opacity: 1 }, { duration: 300,
128
- easing: 'easeOutExpo',
129
- queue: false
130
- });
131
-
132
- }
123
+ } else {
124
+ toast.classList.remove('panning');
125
+ // Put toast back into original position
126
+ Vel(toast, { left: 0, opacity: 1 }, { duration: 300,
127
+ easing: 'easeOutExpo',
128
+ queue: false
133
129
  });
134
130
 
135
- return toast;
136
- }
131
+ }
132
+ });
133
+
134
+ return toast;
135
+ }
137
136
  };