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.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/app/assets/javascripts/materialize.js +6015 -5060
- data/app/assets/javascripts/materialize/animation.js +4 -5
- data/app/assets/javascripts/materialize/buttons.js +24 -38
- data/app/assets/javascripts/materialize/cards.js +13 -21
- data/app/assets/javascripts/materialize/carousel.js +122 -110
- data/app/assets/javascripts/materialize/character_counter.js +14 -22
- data/app/assets/javascripts/materialize/chips.js +41 -44
- data/app/assets/javascripts/materialize/collapsible.js +41 -46
- data/app/assets/javascripts/materialize/date_picker/picker.date.js +965 -1167
- data/app/assets/javascripts/materialize/date_picker/picker.js +546 -634
- data/app/assets/javascripts/materialize/date_picker/picker.time.js +166 -212
- data/app/assets/javascripts/materialize/dropdown.js +53 -68
- data/app/assets/javascripts/materialize/extras/nouislider.js +3 -1
- data/app/assets/javascripts/materialize/extras/nouislider.min.js +1 -1
- data/app/assets/javascripts/materialize/forms.js +156 -154
- data/app/assets/javascripts/materialize/global.js +34 -43
- data/app/assets/javascripts/materialize/hammer.min.js +424 -1
- data/app/assets/javascripts/materialize/initial.js +3 -3
- data/app/assets/javascripts/materialize/jquery.easing.1.4.js +120 -142
- data/app/assets/javascripts/materialize/jquery.hammer.js +9 -9
- data/app/assets/javascripts/materialize/materialbox.js +81 -107
- data/app/assets/javascripts/materialize/modal.js +373 -162
- data/app/assets/javascripts/materialize/parallax.js +11 -15
- data/app/assets/javascripts/materialize/pushpin.js +2 -5
- data/app/assets/javascripts/materialize/scrollFire.js +9 -11
- data/app/assets/javascripts/materialize/scrollspy.js +84 -92
- data/app/assets/javascripts/materialize/sideNav.js +128 -139
- data/app/assets/javascripts/materialize/slider.js +83 -112
- data/app/assets/javascripts/materialize/tabs.js +196 -196
- data/app/assets/javascripts/materialize/tapTarget.js +170 -173
- data/app/assets/javascripts/materialize/toasts.js +330 -112
- data/app/assets/javascripts/materialize/tooltip.js +134 -145
- data/app/assets/javascripts/materialize/transitions.js +43 -49
- data/app/assets/javascripts/materialize/velocity.min.js +623 -2
- data/app/assets/javascripts/materialize/waves.js +42 -47
- data/app/assets/stylesheets/materialize/components/_buttons.scss +1 -1
- data/app/assets/stylesheets/materialize/components/_carousel.scss +4 -5
- data/app/assets/stylesheets/materialize/components/_chips.scss +1 -0
- data/app/assets/stylesheets/materialize/components/_collapsible.scss +4 -7
- data/app/assets/stylesheets/materialize/components/_color.scss +1 -1
- data/app/assets/stylesheets/materialize/components/_global.scss +8 -14
- data/app/assets/stylesheets/materialize/components/_navbar.scss +0 -1
- data/app/assets/stylesheets/materialize/components/_tabs.scss +1 -7
- data/app/assets/stylesheets/materialize/components/_toast.scss +6 -12
- data/app/assets/stylesheets/materialize/components/_variables.scss +55 -43
- data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +1 -0
- data/app/assets/stylesheets/materialize/components/forms/_checkboxes.scss +2 -12
- data/app/assets/stylesheets/materialize/components/forms/_file-input.scss +6 -0
- data/app/assets/stylesheets/materialize/components/forms/_input-fields.scss +67 -37
- data/app/assets/stylesheets/materialize/components/forms/_radio-buttons.scss +1 -3
- data/app/assets/stylesheets/materialize/components/forms/_select.scss +72 -11
- data/app/assets/stylesheets/materialize/components/forms/_switches.scss +2 -4
- data/app/assets/stylesheets/materialize/extras/nouislider.css +8 -1
- data/lib/materialize-sass/version.rb +1 -1
- metadata +2 -5
- data/app/assets/javascripts/materialize/init.js +0 -214
- data/app/assets/javascripts/materialize/jquery.timeago.min.js +0 -1
- data/app/assets/javascripts/materialize/prism.js +0 -8
@@ -3,17 +3,16 @@
|
|
3
3
|
$.fn.parallax = function () {
|
4
4
|
var window_width = $(window).width();
|
5
5
|
// Parallax Scripts
|
6
|
-
return this.each(function(i) {
|
6
|
+
return this.each(function (i) {
|
7
7
|
var $this = $(this);
|
8
8
|
$this.addClass('parallax');
|
9
9
|
|
10
10
|
function updateParallax(initial) {
|
11
11
|
var container_height;
|
12
12
|
if (window_width < 601) {
|
13
|
-
container_height =
|
14
|
-
}
|
15
|
-
|
16
|
-
container_height = ($this.height() > 0) ? $this.height() : 500;
|
13
|
+
container_height = $this.height() > 0 ? $this.height() : $this.children("img").height();
|
14
|
+
} else {
|
15
|
+
container_height = $this.height() > 0 ? $this.height() : 500;
|
17
16
|
}
|
18
17
|
var $img = $this.children("img").first();
|
19
18
|
var img_height = $img.height();
|
@@ -24,35 +23,32 @@
|
|
24
23
|
var windowHeight = window.innerHeight;
|
25
24
|
var windowBottom = scrollTop + windowHeight;
|
26
25
|
var percentScrolled = (windowBottom - top) / (container_height + windowHeight);
|
27
|
-
var parallax = Math.round(
|
26
|
+
var parallax = Math.round(parallax_dist * percentScrolled);
|
28
27
|
|
29
28
|
if (initial) {
|
30
29
|
$img.css('display', 'block');
|
31
30
|
}
|
32
|
-
if (
|
31
|
+
if (bottom > scrollTop && top < scrollTop + windowHeight) {
|
33
32
|
$img.css('transform', "translate3D(-50%," + parallax + "px, 0)");
|
34
33
|
}
|
35
|
-
|
36
34
|
}
|
37
35
|
|
38
36
|
// Wait for image load
|
39
|
-
$this.children("img").one("load", function() {
|
37
|
+
$this.children("img").one("load", function () {
|
40
38
|
updateParallax(true);
|
41
|
-
}).each(function() {
|
39
|
+
}).each(function () {
|
42
40
|
if (this.complete) $(this).trigger("load");
|
43
41
|
});
|
44
42
|
|
45
|
-
$(window).scroll(function() {
|
43
|
+
$(window).scroll(function () {
|
46
44
|
window_width = $(window).width();
|
47
45
|
updateParallax(false);
|
48
46
|
});
|
49
47
|
|
50
|
-
$(window).resize(function() {
|
48
|
+
$(window).resize(function () {
|
51
49
|
window_width = $(window).width();
|
52
50
|
updateParallax(false);
|
53
51
|
});
|
54
|
-
|
55
52
|
});
|
56
|
-
|
57
53
|
};
|
58
|
-
}(
|
54
|
+
})(jQuery);
|
@@ -20,9 +20,8 @@
|
|
20
20
|
|
21
21
|
options = $.extend(defaults, options);
|
22
22
|
|
23
|
-
|
24
23
|
$index = 0;
|
25
|
-
return this.each(function() {
|
24
|
+
return this.each(function () {
|
26
25
|
var $uniqueId = Materialize.guid(),
|
27
26
|
$this = $(this),
|
28
27
|
$original_offset = $(this).offset().top;
|
@@ -64,8 +63,6 @@
|
|
64
63
|
var $scrolled = $(window).scrollTop() + options.offset;
|
65
64
|
updateElements($this, $scrolled);
|
66
65
|
});
|
67
|
-
|
68
66
|
});
|
69
|
-
|
70
67
|
};
|
71
|
-
}(
|
68
|
+
})(jQuery);
|
@@ -1,13 +1,13 @@
|
|
1
|
-
(function($) {
|
1
|
+
(function ($) {
|
2
2
|
|
3
3
|
var scrollFireEventsHandled = false;
|
4
4
|
|
5
5
|
// Input: Array of JSON objects {selector, offset, callback}
|
6
|
-
Materialize.scrollFire = function(options) {
|
7
|
-
var onScroll = function() {
|
6
|
+
Materialize.scrollFire = function (options) {
|
7
|
+
var onScroll = function () {
|
8
8
|
var windowScroll = window.pageYOffset + window.innerHeight;
|
9
9
|
|
10
|
-
for (var i = 0
|
10
|
+
for (var i = 0; i < options.length; i++) {
|
11
11
|
// Get options from each line
|
12
12
|
var value = options[i];
|
13
13
|
var selector = value.selector,
|
@@ -15,14 +15,14 @@
|
|
15
15
|
callback = value.callback;
|
16
16
|
|
17
17
|
var currentElement = document.querySelector(selector);
|
18
|
-
if (
|
18
|
+
if (currentElement !== null) {
|
19
19
|
var elementOffset = currentElement.getBoundingClientRect().top + window.pageYOffset;
|
20
20
|
|
21
|
-
if (windowScroll >
|
21
|
+
if (windowScroll > elementOffset + offset) {
|
22
22
|
if (value.done !== true) {
|
23
|
-
if (typeof
|
23
|
+
if (typeof callback === 'function') {
|
24
24
|
callback.call(this, currentElement);
|
25
|
-
} else if (typeof
|
25
|
+
} else if (typeof callback === 'string') {
|
26
26
|
var callbackFunc = new Function(callback);
|
27
27
|
callbackFunc(currentElement);
|
28
28
|
}
|
@@ -33,8 +33,7 @@
|
|
33
33
|
}
|
34
34
|
};
|
35
35
|
|
36
|
-
|
37
|
-
var throttledScroll = Materialize.throttle(function() {
|
36
|
+
var throttledScroll = Materialize.throttle(function () {
|
38
37
|
onScroll();
|
39
38
|
}, options.throttle || 100);
|
40
39
|
|
@@ -47,5 +46,4 @@
|
|
47
46
|
// perform a scan once, after current execution context, and after dom is ready
|
48
47
|
setTimeout(throttledScroll, 0);
|
49
48
|
};
|
50
|
-
|
51
49
|
})(jQuery);
|
@@ -10,7 +10,7 @@
|
|
10
10
|
* @see https://github.com/thesmart
|
11
11
|
* @version 0.1.2
|
12
12
|
*/
|
13
|
-
(function($) {
|
13
|
+
(function ($) {
|
14
14
|
|
15
15
|
var jWindow = $(window);
|
16
16
|
var elements = [];
|
@@ -19,33 +19,29 @@
|
|
19
19
|
var ticks = 0;
|
20
20
|
var unique_id = 1;
|
21
21
|
var offset = {
|
22
|
-
top
|
23
|
-
right
|
24
|
-
bottom
|
25
|
-
left
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
function findElements(top, right, bottom, left) {
|
22
|
+
top: 0,
|
23
|
+
right: 0,
|
24
|
+
bottom: 0,
|
25
|
+
left: 0
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Find elements that are within the boundary
|
29
|
+
* @param {number} top
|
30
|
+
* @param {number} right
|
31
|
+
* @param {number} bottom
|
32
|
+
* @param {number} left
|
33
|
+
* @return {jQuery} A collection of elements
|
34
|
+
*/
|
35
|
+
};function findElements(top, right, bottom, left) {
|
37
36
|
var hits = $();
|
38
|
-
$.each(elements, function(i, element) {
|
37
|
+
$.each(elements, function (i, element) {
|
39
38
|
if (element.height() > 0) {
|
40
39
|
var elTop = element.offset().top,
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
elLeft = element.offset().left,
|
41
|
+
elRight = elLeft + element.width(),
|
42
|
+
elBottom = elTop + element.height();
|
44
43
|
|
45
|
-
var isIntersect = !(elLeft > right ||
|
46
|
-
elRight < left ||
|
47
|
-
elTop > bottom ||
|
48
|
-
elBottom < top);
|
44
|
+
var isIntersect = !(elLeft > right || elRight < left || elTop > bottom || elBottom < top);
|
49
45
|
|
50
46
|
if (isIntersect) {
|
51
47
|
hits.push(element);
|
@@ -56,23 +52,22 @@
|
|
56
52
|
return hits;
|
57
53
|
}
|
58
54
|
|
59
|
-
|
60
55
|
/**
|
61
|
-
|
62
|
-
|
56
|
+
* Called when the user scrolls the window
|
57
|
+
*/
|
63
58
|
function onScroll(scrollOffset) {
|
64
59
|
// unique tick id
|
65
60
|
++ticks;
|
66
61
|
|
67
62
|
// viewport rectangle
|
68
63
|
var top = jWindow.scrollTop(),
|
69
|
-
|
70
|
-
|
71
|
-
|
64
|
+
left = jWindow.scrollLeft(),
|
65
|
+
right = left + jWindow.width(),
|
66
|
+
bottom = top + jWindow.height();
|
72
67
|
|
73
68
|
// determine which elements are in view
|
74
|
-
var intersections = findElements(top+offset.top + scrollOffset || 200, right+offset.right, bottom+offset.bottom, left+offset.left);
|
75
|
-
$.each(intersections, function(i, element) {
|
69
|
+
var intersections = findElements(top + offset.top + scrollOffset || 200, right + offset.right, bottom + offset.bottom, left + offset.left);
|
70
|
+
$.each(intersections, function (i, element) {
|
76
71
|
|
77
72
|
var lastTick = element.data('scrollSpy:ticks');
|
78
73
|
if (typeof lastTick != 'number') {
|
@@ -85,7 +80,7 @@
|
|
85
80
|
});
|
86
81
|
|
87
82
|
// determine which elements are no longer in view
|
88
|
-
$.each(elementsInView, function(i, element) {
|
83
|
+
$.each(elementsInView, function (i, element) {
|
89
84
|
var lastTick = element.data('scrollSpy:ticks');
|
90
85
|
if (typeof lastTick == 'number' && lastTick !== ticks) {
|
91
86
|
// exited from view
|
@@ -99,47 +94,46 @@
|
|
99
94
|
}
|
100
95
|
|
101
96
|
/**
|
102
|
-
|
103
|
-
|
97
|
+
* Called when window is resized
|
98
|
+
*/
|
104
99
|
function onWinSize() {
|
105
100
|
jWindow.trigger('scrollSpy:winSize');
|
106
101
|
}
|
107
102
|
|
108
|
-
|
109
103
|
/**
|
110
|
-
|
111
|
-
|
112
|
-
|
104
|
+
* Enables ScrollSpy using a selector
|
105
|
+
* @param {jQuery|string} selector The elements collection, or a selector
|
106
|
+
* @param {Object=} options Optional.
|
113
107
|
throttle : number -> scrollspy throttling. Default: 100 ms
|
114
108
|
offsetTop : number -> offset from top. Default: 0
|
115
109
|
offsetRight : number -> offset from right. Default: 0
|
116
110
|
offsetBottom : number -> offset from bottom. Default: 0
|
117
111
|
offsetLeft : number -> offset from left. Default: 0
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
$.scrollSpy = function(selector, options) {
|
122
|
-
|
112
|
+
activeClass : string -> Class name to be added to the active link. Default: active
|
113
|
+
* @returns {jQuery}
|
114
|
+
*/
|
115
|
+
$.scrollSpy = function (selector, options) {
|
116
|
+
var defaults = {
|
123
117
|
throttle: 100,
|
124
118
|
scrollOffset: 200, // offset - 200 allows elements near bottom of page to scroll
|
125
119
|
activeClass: 'active',
|
126
|
-
getActiveElement: function(id) {
|
120
|
+
getActiveElement: function (id) {
|
127
121
|
return 'a[href="#' + id + '"]';
|
128
122
|
}
|
129
|
-
|
130
|
-
|
123
|
+
};
|
124
|
+
options = $.extend(defaults, options);
|
131
125
|
|
132
126
|
var visible = [];
|
133
127
|
selector = $(selector);
|
134
|
-
selector.each(function(i, element) {
|
128
|
+
selector.each(function (i, element) {
|
135
129
|
elements.push($(element));
|
136
130
|
$(element).data("scrollSpy:id", i);
|
137
131
|
// Smooth scroll to section
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
132
|
+
$('a[href="#' + $(element).attr('id') + '"]').click(function (e) {
|
133
|
+
e.preventDefault();
|
134
|
+
var offset = $(Materialize.escapeHash(this.hash)).offset().top + 1;
|
135
|
+
$('html, body').animate({ scrollTop: offset - options.scrollOffset }, { duration: 400, queue: false, easing: 'easeOutCubic' });
|
136
|
+
});
|
143
137
|
});
|
144
138
|
|
145
139
|
offset.top = options.offsetTop || 0;
|
@@ -147,10 +141,10 @@
|
|
147
141
|
offset.bottom = options.offsetBottom || 0;
|
148
142
|
offset.left = options.offsetLeft || 0;
|
149
143
|
|
150
|
-
var throttledScroll = Materialize.throttle(function() {
|
144
|
+
var throttledScroll = Materialize.throttle(function () {
|
151
145
|
onScroll(options.scrollOffset);
|
152
146
|
}, options.throttle || 100);
|
153
|
-
var readyScroll = function(){
|
147
|
+
var readyScroll = function () {
|
154
148
|
$(document).on('ready turbolinks:load', throttledScroll);
|
155
149
|
};
|
156
150
|
|
@@ -163,11 +157,10 @@
|
|
163
157
|
// perform a scan once, after current execution context, and after dom is ready
|
164
158
|
setTimeout(readyScroll, 0);
|
165
159
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
});
|
160
|
+
selector.on('scrollSpy:enter', function () {
|
161
|
+
visible = $.grep(visible, function (value) {
|
162
|
+
return value.height() != 0;
|
163
|
+
});
|
171
164
|
|
172
165
|
var $this = $(this);
|
173
166
|
|
@@ -175,32 +168,30 @@
|
|
175
168
|
$(options.getActiveElement(visible[0].attr('id'))).removeClass(options.activeClass);
|
176
169
|
if ($this.data('scrollSpy:id') < visible[0].data('scrollSpy:id')) {
|
177
170
|
visible.unshift($(this));
|
178
|
-
}
|
179
|
-
else {
|
171
|
+
} else {
|
180
172
|
visible.push($(this));
|
181
173
|
}
|
182
|
-
}
|
183
|
-
else {
|
174
|
+
} else {
|
184
175
|
visible.push($(this));
|
185
176
|
}
|
186
177
|
|
187
|
-
|
188
178
|
$(options.getActiveElement(visible[0].attr('id'))).addClass(options.activeClass);
|
189
179
|
});
|
190
|
-
selector.on('scrollSpy:exit', function() {
|
191
|
-
visible = $.grep(visible, function(value) {
|
192
|
-
|
193
|
-
|
180
|
+
selector.on('scrollSpy:exit', function () {
|
181
|
+
visible = $.grep(visible, function (value) {
|
182
|
+
return value.height() != 0;
|
183
|
+
});
|
194
184
|
|
195
185
|
if (visible[0]) {
|
196
186
|
$(options.getActiveElement(visible[0].attr('id'))).removeClass(options.activeClass);
|
197
187
|
var $this = $(this);
|
198
|
-
visible = $.grep(visible, function(value) {
|
199
|
-
|
200
|
-
|
201
|
-
|
188
|
+
visible = $.grep(visible, function (value) {
|
189
|
+
return value.attr('id') != $this.attr('id');
|
190
|
+
});
|
191
|
+
if (visible[0]) {
|
192
|
+
// Check if empty
|
202
193
|
$(options.getActiveElement(visible[0].attr('id'))).addClass(options.activeClass);
|
203
|
-
|
194
|
+
}
|
204
195
|
}
|
205
196
|
});
|
206
197
|
|
@@ -208,12 +199,14 @@
|
|
208
199
|
};
|
209
200
|
|
210
201
|
/**
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
$.winSizeSpy = function(options) {
|
216
|
-
$.winSizeSpy = function() {
|
202
|
+
* Listen for window resize events
|
203
|
+
* @param {Object=} options Optional. Set { throttle: number } to change throttling. Default: 100 ms
|
204
|
+
* @returns {jQuery} $(window)
|
205
|
+
*/
|
206
|
+
$.winSizeSpy = function (options) {
|
207
|
+
$.winSizeSpy = function () {
|
208
|
+
return jWindow;
|
209
|
+
}; // lock from multiple calls
|
217
210
|
options = options || {
|
218
211
|
throttle: 100
|
219
212
|
};
|
@@ -221,18 +214,17 @@
|
|
221
214
|
};
|
222
215
|
|
223
216
|
/**
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
$.fn.scrollSpy = function(options) {
|
217
|
+
* Enables ScrollSpy on a collection of elements
|
218
|
+
* e.g. $('.scrollSpy').scrollSpy()
|
219
|
+
* @param {Object=} options Optional.
|
220
|
+
throttle : number -> scrollspy throttling. Default: 100 ms
|
221
|
+
offsetTop : number -> offset from top. Default: 0
|
222
|
+
offsetRight : number -> offset from right. Default: 0
|
223
|
+
offsetBottom : number -> offset from bottom. Default: 0
|
224
|
+
offsetLeft : number -> offset from left. Default: 0
|
225
|
+
* @returns {jQuery}
|
226
|
+
*/
|
227
|
+
$.fn.scrollSpy = function (options) {
|
235
228
|
return $.scrollSpy($(this), options);
|
236
229
|
};
|
237
|
-
|
238
230
|
})(jQuery);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
(function ($) {
|
2
2
|
|
3
3
|
var methods = {
|
4
|
-
init
|
4
|
+
init: function (options) {
|
5
5
|
var defaults = {
|
6
6
|
menuWidth: 300,
|
7
7
|
edge: 'left',
|
@@ -12,10 +12,10 @@
|
|
12
12
|
};
|
13
13
|
options = $.extend(defaults, options);
|
14
14
|
|
15
|
-
$(this).each(function(){
|
15
|
+
$(this).each(function () {
|
16
16
|
var $this = $(this);
|
17
17
|
var menuId = $this.attr('data-activates');
|
18
|
-
var menu = $("#"+ menuId);
|
18
|
+
var menu = $("#" + menuId);
|
19
19
|
|
20
20
|
// Set to width
|
21
21
|
if (options.menuWidth != 300) {
|
@@ -38,57 +38,52 @@
|
|
38
38
|
|
39
39
|
if (options.edge == 'left') {
|
40
40
|
menu.css('transform', 'translateX(-100%)');
|
41
|
-
$dragTarget.css({'left': 0}); // Add Touch Area
|
42
|
-
}
|
43
|
-
else {
|
41
|
+
$dragTarget.css({ 'left': 0 }); // Add Touch Area
|
42
|
+
} else {
|
44
43
|
menu.addClass('right-aligned') // Change text-alignment to right
|
45
|
-
|
46
|
-
$dragTarget.css({'right': 0}); // Add Touch Area
|
44
|
+
.css('transform', 'translateX(100%)');
|
45
|
+
$dragTarget.css({ 'right': 0 }); // Add Touch Area
|
47
46
|
}
|
48
47
|
|
49
48
|
// If fixed sidenav, bring menu out
|
50
49
|
if (menu.hasClass('fixed')) {
|
51
|
-
|
52
|
-
|
53
|
-
}
|
50
|
+
if (window.innerWidth > 992) {
|
51
|
+
menu.css('transform', 'translateX(0)');
|
54
52
|
}
|
53
|
+
}
|
55
54
|
|
56
55
|
// Window resize to reset on large screens fixed
|
57
56
|
if (menu.hasClass('fixed')) {
|
58
|
-
$(window).resize(
|
57
|
+
$(window).resize(function () {
|
59
58
|
if (window.innerWidth > 992) {
|
60
59
|
// Close menu if window is resized bigger than 992 and user has fixed sidenav
|
61
60
|
if ($('#sidenav-overlay').length !== 0 && menuOut) {
|
62
61
|
removeMenu(true);
|
63
|
-
}
|
64
|
-
else {
|
62
|
+
} else {
|
65
63
|
// menu.removeAttr('style');
|
66
64
|
menu.css('transform', 'translateX(0%)');
|
67
65
|
// menu.css('width', options.menuWidth);
|
68
66
|
}
|
69
|
-
}
|
70
|
-
else if (menuOut === false){
|
67
|
+
} else if (menuOut === false) {
|
71
68
|
if (options.edge === 'left') {
|
72
69
|
menu.css('transform', 'translateX(-100%)');
|
73
70
|
} else {
|
74
71
|
menu.css('transform', 'translateX(100%)');
|
75
72
|
}
|
76
|
-
|
77
73
|
}
|
78
|
-
|
79
74
|
});
|
80
75
|
}
|
81
76
|
|
82
77
|
// if closeOnClick, then add close event for all a tags in side sideNav
|
83
78
|
if (options.closeOnClick === true) {
|
84
|
-
menu.on("click.itemclick", "a:not(.collapsible-header)", function(){
|
85
|
-
if (!(window.innerWidth > 992 && menu.hasClass('fixed'))){
|
79
|
+
menu.on("click.itemclick", "a:not(.collapsible-header)", function () {
|
80
|
+
if (!(window.innerWidth > 992 && menu.hasClass('fixed'))) {
|
86
81
|
removeMenu();
|
87
82
|
}
|
88
83
|
});
|
89
84
|
}
|
90
85
|
|
91
|
-
var removeMenu = function(restoreNav) {
|
86
|
+
var removeMenu = function (restoreNav) {
|
92
87
|
panning = false;
|
93
88
|
menuOut = false;
|
94
89
|
// Reenable scrolling
|
@@ -97,61 +92,54 @@
|
|
97
92
|
width: ''
|
98
93
|
});
|
99
94
|
|
100
|
-
$('#sidenav-overlay').velocity({opacity: 0}, {duration: 200,
|
101
|
-
|
102
|
-
complete: function() {
|
95
|
+
$('#sidenav-overlay').velocity({ opacity: 0 }, { duration: 200,
|
96
|
+
queue: false, easing: 'easeOutQuad',
|
97
|
+
complete: function () {
|
103
98
|
$(this).remove();
|
104
99
|
} });
|
105
100
|
if (options.edge === 'left') {
|
106
101
|
// Reset phantom div
|
107
|
-
$dragTarget.css({width: '', right: '', left: '0'});
|
108
|
-
menu.velocity(
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
menu.removeAttr('style');
|
117
|
-
menu.css('width', options.menuWidth);
|
118
|
-
}
|
102
|
+
$dragTarget.css({ width: '', right: '', left: '0' });
|
103
|
+
menu.velocity({ 'translateX': '-100%' }, { duration: 200,
|
104
|
+
queue: false,
|
105
|
+
easing: 'easeOutCubic',
|
106
|
+
complete: function () {
|
107
|
+
if (restoreNav === true) {
|
108
|
+
// Restore Fixed sidenav
|
109
|
+
menu.removeAttr('style');
|
110
|
+
menu.css('width', options.menuWidth);
|
119
111
|
}
|
112
|
+
}
|
120
113
|
|
121
114
|
});
|
122
|
-
}
|
123
|
-
else {
|
115
|
+
} else {
|
124
116
|
// Reset phantom div
|
125
|
-
$dragTarget.css({width: '', right: '0', left: ''});
|
126
|
-
menu.velocity(
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
menu.removeAttr('style');
|
135
|
-
menu.css('width', options.menuWidth);
|
136
|
-
}
|
117
|
+
$dragTarget.css({ width: '', right: '0', left: '' });
|
118
|
+
menu.velocity({ 'translateX': '100%' }, { duration: 200,
|
119
|
+
queue: false,
|
120
|
+
easing: 'easeOutCubic',
|
121
|
+
complete: function () {
|
122
|
+
if (restoreNav === true) {
|
123
|
+
// Restore Fixed sidenav
|
124
|
+
menu.removeAttr('style');
|
125
|
+
menu.css('width', options.menuWidth);
|
137
126
|
}
|
138
|
-
}
|
127
|
+
}
|
128
|
+
});
|
139
129
|
}
|
140
130
|
|
141
131
|
// Callback
|
142
|
-
if (typeof
|
132
|
+
if (typeof options.onClose === 'function') {
|
143
133
|
options.onClose.call(this, menu);
|
144
134
|
}
|
145
|
-
}
|
146
|
-
|
147
|
-
|
135
|
+
};
|
148
136
|
|
149
137
|
// Touch Event
|
150
138
|
var panning = false;
|
151
139
|
var menuOut = false;
|
152
140
|
|
153
141
|
if (options.draggable) {
|
154
|
-
$dragTarget.on('click', function(){
|
142
|
+
$dragTarget.on('click', function () {
|
155
143
|
if (menuOut) {
|
156
144
|
removeMenu();
|
157
145
|
}
|
@@ -159,7 +147,7 @@
|
|
159
147
|
|
160
148
|
$dragTarget.hammer({
|
161
149
|
prevent_default: false
|
162
|
-
}).on('pan', function(e) {
|
150
|
+
}).on('pan', function (e) {
|
163
151
|
|
164
152
|
if (e.gesture.pointerType == "touch") {
|
165
153
|
|
@@ -183,41 +171,47 @@
|
|
183
171
|
// If overlay does not exist, create one and if it is clicked, close menu
|
184
172
|
if ($overlay.length === 0) {
|
185
173
|
$overlay = $('<div id="sidenav-overlay"></div>');
|
186
|
-
$overlay.css('opacity', 0).click(
|
174
|
+
$overlay.css('opacity', 0).click(function () {
|
187
175
|
removeMenu();
|
188
176
|
});
|
189
|
-
|
177
|
+
|
190
178
|
// Run 'onOpen' when sidenav is opened via touch/swipe if applicable
|
191
|
-
if (typeof
|
179
|
+
if (typeof options.onOpen === 'function') {
|
192
180
|
options.onOpen.call(this, menu);
|
193
181
|
}
|
194
|
-
|
182
|
+
|
195
183
|
$('body').append($overlay);
|
196
184
|
}
|
197
185
|
|
198
186
|
// Keep within boundaries
|
199
187
|
if (options.edge === 'left') {
|
200
|
-
if (x > options.menuWidth) {
|
201
|
-
|
188
|
+
if (x > options.menuWidth) {
|
189
|
+
x = options.menuWidth;
|
190
|
+
} else if (x < 0) {
|
191
|
+
x = 0;
|
192
|
+
}
|
202
193
|
}
|
203
194
|
|
204
195
|
if (options.edge === 'left') {
|
205
196
|
// Left Direction
|
206
|
-
if (x <
|
197
|
+
if (x < options.menuWidth / 2) {
|
198
|
+
menuOut = false;
|
199
|
+
}
|
207
200
|
// Right Direction
|
208
|
-
else if (x >=
|
201
|
+
else if (x >= options.menuWidth / 2) {
|
202
|
+
menuOut = true;
|
203
|
+
}
|
209
204
|
menu.css('transform', 'translateX(' + (x - options.menuWidth) + 'px)');
|
210
|
-
}
|
211
|
-
else {
|
205
|
+
} else {
|
212
206
|
// Left Direction
|
213
|
-
if (x <
|
207
|
+
if (x < window.innerWidth - options.menuWidth / 2) {
|
214
208
|
menuOut = true;
|
215
209
|
}
|
216
210
|
// Right Direction
|
217
|
-
else if (x >=
|
218
|
-
|
219
|
-
|
220
|
-
var rightPos =
|
211
|
+
else if (x >= window.innerWidth - options.menuWidth / 2) {
|
212
|
+
menuOut = false;
|
213
|
+
}
|
214
|
+
var rightPos = x - options.menuWidth / 2;
|
221
215
|
if (rightPos < 0) {
|
222
216
|
rightPos = 0;
|
223
217
|
}
|
@@ -225,20 +219,17 @@
|
|
225
219
|
menu.css('transform', 'translateX(' + rightPos + 'px)');
|
226
220
|
}
|
227
221
|
|
228
|
-
|
229
222
|
// Percentage overlay
|
230
223
|
var overlayPerc;
|
231
224
|
if (options.edge === 'left') {
|
232
225
|
overlayPerc = x / options.menuWidth;
|
233
|
-
$overlay.velocity({opacity: overlayPerc }, {duration: 10, queue: false, easing: 'easeOutQuad'});
|
234
|
-
}
|
235
|
-
else {
|
226
|
+
$overlay.velocity({ opacity: overlayPerc }, { duration: 10, queue: false, easing: 'easeOutQuad' });
|
227
|
+
} else {
|
236
228
|
overlayPerc = Math.abs((x - window.innerWidth) / options.menuWidth);
|
237
|
-
$overlay.velocity({opacity: overlayPerc }, {duration: 10, queue: false, easing: 'easeOutQuad'});
|
229
|
+
$overlay.velocity({ opacity: overlayPerc }, { duration: 10, queue: false, easing: 'easeOutQuad' });
|
238
230
|
}
|
239
231
|
}
|
240
|
-
|
241
|
-
}).on('panend', function(e) {
|
232
|
+
}).on('panend', function (e) {
|
242
233
|
|
243
234
|
if (e.gesture.pointerType == "touch") {
|
244
235
|
var $overlay = $('#sidenav-overlay');
|
@@ -246,7 +237,7 @@
|
|
246
237
|
var x = e.gesture.center.x;
|
247
238
|
var leftPos = x - options.menuWidth;
|
248
239
|
var rightPos = x - options.menuWidth / 2;
|
249
|
-
if (leftPos > 0
|
240
|
+
if (leftPos > 0) {
|
250
241
|
leftPos = 0;
|
251
242
|
}
|
252
243
|
if (rightPos < 0) {
|
@@ -256,48 +247,45 @@
|
|
256
247
|
|
257
248
|
if (options.edge === 'left') {
|
258
249
|
// If velocityX <= 0.3 then the user is flinging the menu closed so ignore menuOut
|
259
|
-
if (
|
250
|
+
if (menuOut && velocityX <= 0.3 || velocityX < -0.5) {
|
260
251
|
// Return menu to open
|
261
252
|
if (leftPos !== 0) {
|
262
|
-
menu.velocity({'translateX': [0, leftPos]}, {duration: 300, queue: false, easing: 'easeOutQuad'});
|
253
|
+
menu.velocity({ 'translateX': [0, leftPos] }, { duration: 300, queue: false, easing: 'easeOutQuad' });
|
263
254
|
}
|
264
255
|
|
265
|
-
$overlay.velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
|
266
|
-
$dragTarget.css({width: '50%', right: 0, left: ''});
|
256
|
+
$overlay.velocity({ opacity: 1 }, { duration: 50, queue: false, easing: 'easeOutQuad' });
|
257
|
+
$dragTarget.css({ width: '50%', right: 0, left: '' });
|
267
258
|
menuOut = true;
|
268
|
-
}
|
269
|
-
else if (!menuOut || velocityX > 0.3) {
|
259
|
+
} else if (!menuOut || velocityX > 0.3) {
|
270
260
|
// Enable Scrolling
|
271
261
|
$('body').css({
|
272
262
|
overflow: '',
|
273
263
|
width: ''
|
274
264
|
});
|
275
265
|
// Slide menu closed
|
276
|
-
menu.velocity({'translateX': [-1 * options.menuWidth - 10, leftPos]}, {duration: 200, queue: false, easing: 'easeOutQuad'});
|
277
|
-
$overlay.velocity({opacity: 0 }, {duration: 200, queue: false, easing: 'easeOutQuad',
|
266
|
+
menu.velocity({ 'translateX': [-1 * options.menuWidth - 10, leftPos] }, { duration: 200, queue: false, easing: 'easeOutQuad' });
|
267
|
+
$overlay.velocity({ opacity: 0 }, { duration: 200, queue: false, easing: 'easeOutQuad',
|
278
268
|
complete: function () {
|
279
269
|
// Run 'onClose' when sidenav is closed via touch/swipe if applicable
|
280
|
-
if (typeof
|
270
|
+
if (typeof options.onClose === 'function') {
|
281
271
|
options.onClose.call(this, menu);
|
282
272
|
}
|
283
|
-
|
273
|
+
|
284
274
|
$(this).remove();
|
285
|
-
}});
|
286
|
-
$dragTarget.css({width: '10px', right: '', left: 0});
|
275
|
+
} });
|
276
|
+
$dragTarget.css({ width: '10px', right: '', left: 0 });
|
287
277
|
}
|
288
|
-
}
|
289
|
-
|
290
|
-
if ((menuOut && velocityX >= -0.3) || velocityX > 0.5) {
|
278
|
+
} else {
|
279
|
+
if (menuOut && velocityX >= -0.3 || velocityX > 0.5) {
|
291
280
|
// Return menu to open
|
292
281
|
if (rightPos !== 0) {
|
293
|
-
menu.velocity({'translateX': [0, rightPos]}, {duration: 300, queue: false, easing: 'easeOutQuad'});
|
282
|
+
menu.velocity({ 'translateX': [0, rightPos] }, { duration: 300, queue: false, easing: 'easeOutQuad' });
|
294
283
|
}
|
295
284
|
|
296
|
-
$overlay.velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
|
297
|
-
$dragTarget.css({width: '50%', right: '', left: 0});
|
285
|
+
$overlay.velocity({ opacity: 1 }, { duration: 50, queue: false, easing: 'easeOutQuad' });
|
286
|
+
$dragTarget.css({ width: '50%', right: '', left: 0 });
|
298
287
|
menuOut = true;
|
299
|
-
}
|
300
|
-
else if (!menuOut || velocityX < -0.3) {
|
288
|
+
} else if (!menuOut || velocityX < -0.3) {
|
301
289
|
// Enable Scrolling
|
302
290
|
$('body').css({
|
303
291
|
overflow: '',
|
@@ -305,26 +293,29 @@
|
|
305
293
|
});
|
306
294
|
|
307
295
|
// Slide menu closed
|
308
|
-
menu.velocity({'translateX': [options.menuWidth + 10, rightPos]}, {duration: 200, queue: false, easing: 'easeOutQuad'});
|
309
|
-
$overlay.velocity({opacity: 0 }, {duration: 200, queue: false, easing: 'easeOutQuad',
|
296
|
+
menu.velocity({ 'translateX': [options.menuWidth + 10, rightPos] }, { duration: 200, queue: false, easing: 'easeOutQuad' });
|
297
|
+
$overlay.velocity({ opacity: 0 }, { duration: 200, queue: false, easing: 'easeOutQuad',
|
310
298
|
complete: function () {
|
299
|
+
// Run 'onClose' when sidenav is closed via touch/swipe if applicable
|
300
|
+
if (typeof options.onClose === 'function') {
|
301
|
+
options.onClose.call(this, menu);
|
302
|
+
}
|
303
|
+
|
311
304
|
$(this).remove();
|
312
|
-
}});
|
313
|
-
$dragTarget.css({width: '10px', right: 0, left: ''});
|
305
|
+
} });
|
306
|
+
$dragTarget.css({ width: '10px', right: 0, left: '' });
|
314
307
|
}
|
315
308
|
}
|
316
|
-
|
317
309
|
}
|
318
310
|
});
|
319
311
|
}
|
320
312
|
|
321
|
-
$this.off('click.sidenav').on('click.sidenav', function() {
|
313
|
+
$this.off('click.sidenav').on('click.sidenav', function () {
|
322
314
|
if (menuOut === true) {
|
323
315
|
menuOut = false;
|
324
316
|
panning = false;
|
325
317
|
removeMenu();
|
326
|
-
}
|
327
|
-
else {
|
318
|
+
} else {
|
328
319
|
|
329
320
|
// Disable Scrolling
|
330
321
|
var $body = $('body');
|
@@ -337,35 +328,36 @@
|
|
337
328
|
$('body').append($dragTarget);
|
338
329
|
|
339
330
|
if (options.edge === 'left') {
|
340
|
-
$dragTarget.css({width: '50%', right: 0, left: ''});
|
341
|
-
menu.velocity({'translateX': [0, -1 * options.menuWidth]}, {duration: 300, queue: false, easing: 'easeOutQuad'});
|
342
|
-
}
|
343
|
-
|
344
|
-
|
345
|
-
menu.velocity({'translateX': [0, options.menuWidth]}, {duration: 300, queue: false, easing: 'easeOutQuad'});
|
331
|
+
$dragTarget.css({ width: '50%', right: 0, left: '' });
|
332
|
+
menu.velocity({ 'translateX': [0, -1 * options.menuWidth] }, { duration: 300, queue: false, easing: 'easeOutQuad' });
|
333
|
+
} else {
|
334
|
+
$dragTarget.css({ width: '50%', right: '', left: 0 });
|
335
|
+
menu.velocity({ 'translateX': [0, options.menuWidth] }, { duration: 300, queue: false, easing: 'easeOutQuad' });
|
346
336
|
}
|
347
337
|
|
348
|
-
|
349
|
-
.click(function(){
|
338
|
+
// Overlay close on click
|
339
|
+
$overlay.css('opacity', 0).click(function () {
|
350
340
|
menuOut = false;
|
351
341
|
panning = false;
|
352
342
|
removeMenu();
|
353
|
-
$overlay.velocity({opacity: 0}, {duration: 300, queue: false, easing: 'easeOutQuad',
|
354
|
-
complete: function() {
|
355
|
-
$(this).remove();
|
356
|
-
} });
|
357
|
-
|
358
|
-
});
|
359
|
-
$('body').append($overlay);
|
360
|
-
$overlay.velocity({opacity: 1}, {duration: 300, queue: false, easing: 'easeOutQuad',
|
343
|
+
$overlay.velocity({ opacity: 0 }, { duration: 300, queue: false, easing: 'easeOutQuad',
|
361
344
|
complete: function () {
|
362
|
-
|
363
|
-
panning = false;
|
345
|
+
$(this).remove();
|
364
346
|
}
|
365
347
|
});
|
348
|
+
});
|
349
|
+
|
350
|
+
// Append body
|
351
|
+
$('body').append($overlay);
|
352
|
+
$overlay.velocity({ opacity: 1 }, { duration: 300, queue: false, easing: 'easeOutQuad',
|
353
|
+
complete: function () {
|
354
|
+
menuOut = true;
|
355
|
+
panning = false;
|
356
|
+
}
|
357
|
+
});
|
366
358
|
|
367
359
|
// Callback
|
368
|
-
if (typeof
|
360
|
+
if (typeof options.onOpen === 'function') {
|
369
361
|
options.onOpen.call(this, menu);
|
370
362
|
}
|
371
363
|
}
|
@@ -373,8 +365,6 @@
|
|
373
365
|
return false;
|
374
366
|
});
|
375
367
|
});
|
376
|
-
|
377
|
-
|
378
368
|
},
|
379
369
|
destroy: function () {
|
380
370
|
var $overlay = $('#sidenav-overlay');
|
@@ -384,23 +374,22 @@
|
|
384
374
|
$(this).off('click');
|
385
375
|
$overlay.remove();
|
386
376
|
},
|
387
|
-
show
|
377
|
+
show: function () {
|
388
378
|
this.trigger('click');
|
389
379
|
},
|
390
|
-
hide
|
380
|
+
hide: function () {
|
391
381
|
$('#sidenav-overlay').trigger('click');
|
392
382
|
}
|
393
383
|
};
|
394
384
|
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
} else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
|
385
|
+
$.fn.sideNav = function (methodOrOptions) {
|
386
|
+
if (methods[methodOrOptions]) {
|
387
|
+
return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
|
388
|
+
} else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
|
400
389
|
// Default to "init"
|
401
|
-
return methods.init.apply(
|
390
|
+
return methods.init.apply(this, arguments);
|
402
391
|
} else {
|
403
|
-
$.error(
|
392
|
+
$.error('Method ' + methodOrOptions + ' does not exist on jQuery.sideNav');
|
404
393
|
}
|
405
394
|
}; // Plugin end
|
406
|
-
}(
|
395
|
+
})(jQuery);
|