dae-material 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/app/assets/fonts/material-design-icons/LICENSE.txt +428 -0
- data/app/assets/fonts/material-design-icons/Material-Design-Icons.eot +0 -0
- data/app/assets/fonts/material-design-icons/Material-Design-Icons.svg +751 -0
- data/app/assets/fonts/material-design-icons/Material-Design-Icons.ttf +0 -0
- data/app/assets/fonts/material-design-icons/Material-Design-Icons.woff +0 -0
- data/app/assets/fonts/material-design-icons/Material-Design-Icons.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
- data/app/assets/fonts/roboto/Roboto-Bold.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Light.ttf +0 -0
- data/app/assets/fonts/roboto/Roboto-Light.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
- data/app/assets/fonts/roboto/Roboto-Medium.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
- data/app/assets/fonts/roboto/Roboto-Regular.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
- data/app/assets/fonts/roboto/Roboto-Thin.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
- data/app/assets/javascripts/materialize-sprockets.js +27 -0
- data/app/assets/javascripts/materialize.js +6023 -0
- data/app/assets/javascripts/materialize/animation.js +9 -0
- data/app/assets/javascripts/materialize/buttons.js +35 -0
- data/app/assets/javascripts/materialize/cards.js +27 -0
- data/app/assets/javascripts/materialize/character_counter.js +59 -0
- data/app/assets/javascripts/materialize/collapsible.js +139 -0
- data/app/assets/javascripts/materialize/date_picker/picker.date.js +1430 -0
- data/app/assets/javascripts/materialize/date_picker/picker.js +1123 -0
- data/app/assets/javascripts/materialize/dropdown.js +176 -0
- data/app/assets/javascripts/materialize/forms.js +397 -0
- data/app/assets/javascripts/materialize/global.js +31 -0
- data/app/assets/javascripts/materialize/hammer.min.js +1 -0
- data/app/assets/javascripts/materialize/init.js +137 -0
- data/app/assets/javascripts/materialize/jquery.easing.1.3.js +205 -0
- data/app/assets/javascripts/materialize/jquery.hammer.js +33 -0
- data/app/assets/javascripts/materialize/jquery.timeago.min.js +1 -0
- data/app/assets/javascripts/materialize/leanModal.js +139 -0
- data/app/assets/javascripts/materialize/materialbox.js +249 -0
- data/app/assets/javascripts/materialize/parallax.js +58 -0
- data/app/assets/javascripts/materialize/prism.js +8 -0
- data/app/assets/javascripts/materialize/pushpin.js +62 -0
- data/app/assets/javascripts/materialize/scrollFire.js +69 -0
- data/app/assets/javascripts/materialize/scrollspy.js +284 -0
- data/app/assets/javascripts/materialize/sideNav.js +335 -0
- data/app/assets/javascripts/materialize/slider.js +263 -0
- data/app/assets/javascripts/materialize/tabs.js +129 -0
- data/app/assets/javascripts/materialize/toasts.js +121 -0
- data/app/assets/javascripts/materialize/tooltip.js +166 -0
- data/app/assets/javascripts/materialize/transitions.js +145 -0
- data/app/assets/javascripts/materialize/velocity.min.js +4 -0
- data/app/assets/javascripts/materialize/waves.js +338 -0
- data/app/assets/stylesheets/materialize.scss +38 -0
- data/app/assets/stylesheets/materialize/components/_buttons.scss +151 -0
- data/app/assets/stylesheets/materialize/components/_cards.scss +150 -0
- data/app/assets/stylesheets/materialize/components/_collapsible.scss +88 -0
- data/app/assets/stylesheets/materialize/components/_color.scss +412 -0
- data/app/assets/stylesheets/materialize/components/_dropdown.scss +38 -0
- data/app/assets/stylesheets/materialize/components/_form.scss +850 -0
- data/app/assets/stylesheets/materialize/components/_global.scss +682 -0
- data/app/assets/stylesheets/materialize/components/_grid.scss +118 -0
- data/app/assets/stylesheets/materialize/components/_icons-material-design.scss +783 -0
- data/app/assets/stylesheets/materialize/components/_materialbox.scss +41 -0
- data/app/assets/stylesheets/materialize/components/_mixins.scss +5 -0
- data/app/assets/stylesheets/materialize/components/_modal.scss +89 -0
- data/app/assets/stylesheets/materialize/components/_navbar.scss +143 -0
- data/app/assets/stylesheets/materialize/components/_normalize.scss +427 -0
- data/app/assets/stylesheets/materialize/components/_prefixer.scss +376 -0
- data/app/assets/stylesheets/materialize/components/_preloader.scss +332 -0
- data/app/assets/stylesheets/materialize/components/_roboto.scss +38 -0
- data/app/assets/stylesheets/materialize/components/_sideNav.scss +111 -0
- data/app/assets/stylesheets/materialize/components/_slider.scss +92 -0
- data/app/assets/stylesheets/materialize/components/_table_of_contents.scss +33 -0
- data/app/assets/stylesheets/materialize/components/_tabs.scss +42 -0
- data/app/assets/stylesheets/materialize/components/_toast.scss +63 -0
- data/app/assets/stylesheets/materialize/components/_tooltip.scss +34 -0
- data/app/assets/stylesheets/materialize/components/_typography.scss +56 -0
- data/app/assets/stylesheets/materialize/components/_variables.scss +143 -0
- data/app/assets/stylesheets/materialize/components/_waves.scss +167 -0
- data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +435 -0
- data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +201 -0
- data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +125 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/dae-material.gemspec +23 -0
- data/lib/dae/material.rb +7 -0
- data/lib/dae/material/version.rb +8 -0
- metadata +166 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extend jquery with a scrollspy plugin.
|
|
3
|
+
* This watches the window scroll and fires events when elements are scrolled into viewport.
|
|
4
|
+
*
|
|
5
|
+
* throttle() and getTime() taken from Underscore.js
|
|
6
|
+
* https://github.com/jashkenas/underscore
|
|
7
|
+
*
|
|
8
|
+
* @author Copyright 2013 John Smart
|
|
9
|
+
* @license https://raw.github.com/thesmart/jquery-scrollspy/master/LICENSE
|
|
10
|
+
* @see https://github.com/thesmart
|
|
11
|
+
* @version 0.1.2
|
|
12
|
+
*/
|
|
13
|
+
(function($) {
|
|
14
|
+
|
|
15
|
+
var jWindow = $(window);
|
|
16
|
+
var elements = [];
|
|
17
|
+
var elementsInView = [];
|
|
18
|
+
var isSpying = false;
|
|
19
|
+
var ticks = 0;
|
|
20
|
+
var unique_id = 1;
|
|
21
|
+
var offset = {
|
|
22
|
+
top : 0,
|
|
23
|
+
right : 0,
|
|
24
|
+
bottom : 0,
|
|
25
|
+
left : 0,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Find elements that are within the boundary
|
|
30
|
+
* @param {number} top
|
|
31
|
+
* @param {number} right
|
|
32
|
+
* @param {number} bottom
|
|
33
|
+
* @param {number} left
|
|
34
|
+
* @return {jQuery} A collection of elements
|
|
35
|
+
*/
|
|
36
|
+
function findElements(top, right, bottom, left) {
|
|
37
|
+
var hits = $();
|
|
38
|
+
$.each(elements, function(i, element) {
|
|
39
|
+
if (element.height() > 0) {
|
|
40
|
+
var elTop = element.offset().top,
|
|
41
|
+
elLeft = element.offset().left,
|
|
42
|
+
elRight = elLeft + element.width(),
|
|
43
|
+
elBottom = elTop + element.height();
|
|
44
|
+
|
|
45
|
+
var isIntersect = !(elLeft > right ||
|
|
46
|
+
elRight < left ||
|
|
47
|
+
elTop > bottom ||
|
|
48
|
+
elBottom < top);
|
|
49
|
+
|
|
50
|
+
if (isIntersect) {
|
|
51
|
+
hits.push(element);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return hits;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Called when the user scrolls the window
|
|
62
|
+
*/
|
|
63
|
+
function onScroll() {
|
|
64
|
+
// unique tick id
|
|
65
|
+
++ticks;
|
|
66
|
+
|
|
67
|
+
// viewport rectangle
|
|
68
|
+
var top = jWindow.scrollTop(),
|
|
69
|
+
left = jWindow.scrollLeft(),
|
|
70
|
+
right = left + jWindow.width(),
|
|
71
|
+
bottom = top + jWindow.height();
|
|
72
|
+
|
|
73
|
+
// determine which elements are in view
|
|
74
|
+
// + 60 accounts for fixed nav
|
|
75
|
+
var intersections = findElements(top+offset.top + 200, right+offset.right, bottom+offset.bottom, left+offset.left);
|
|
76
|
+
$.each(intersections, function(i, element) {
|
|
77
|
+
|
|
78
|
+
var lastTick = element.data('scrollSpy:ticks');
|
|
79
|
+
if (typeof lastTick != 'number') {
|
|
80
|
+
// entered into view
|
|
81
|
+
element.triggerHandler('scrollSpy:enter');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// update tick id
|
|
85
|
+
element.data('scrollSpy:ticks', ticks);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// determine which elements are no longer in view
|
|
89
|
+
$.each(elementsInView, function(i, element) {
|
|
90
|
+
var lastTick = element.data('scrollSpy:ticks');
|
|
91
|
+
if (typeof lastTick == 'number' && lastTick !== ticks) {
|
|
92
|
+
// exited from view
|
|
93
|
+
element.triggerHandler('scrollSpy:exit');
|
|
94
|
+
element.data('scrollSpy:ticks', null);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// remember elements in view for next tick
|
|
99
|
+
elementsInView = intersections;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Called when window is resized
|
|
104
|
+
*/
|
|
105
|
+
function onWinSize() {
|
|
106
|
+
jWindow.trigger('scrollSpy:winSize');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Get time in ms
|
|
111
|
+
* @license https://raw.github.com/jashkenas/underscore/master/LICENSE
|
|
112
|
+
* @type {function}
|
|
113
|
+
* @return {number}
|
|
114
|
+
*/
|
|
115
|
+
var getTime = (Date.now || function () {
|
|
116
|
+
return new Date().getTime();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Returns a function, that, when invoked, will only be triggered at most once
|
|
121
|
+
* during a given window of time. Normally, the throttled function will run
|
|
122
|
+
* as much as it can, without ever going more than once per `wait` duration;
|
|
123
|
+
* but if you'd like to disable the execution on the leading edge, pass
|
|
124
|
+
* `{leading: false}`. To disable execution on the trailing edge, ditto.
|
|
125
|
+
* @license https://raw.github.com/jashkenas/underscore/master/LICENSE
|
|
126
|
+
* @param {function} func
|
|
127
|
+
* @param {number} wait
|
|
128
|
+
* @param {Object=} options
|
|
129
|
+
* @returns {Function}
|
|
130
|
+
*/
|
|
131
|
+
function throttle(func, wait, options) {
|
|
132
|
+
var context, args, result;
|
|
133
|
+
var timeout = null;
|
|
134
|
+
var previous = 0;
|
|
135
|
+
options || (options = {});
|
|
136
|
+
var later = function () {
|
|
137
|
+
previous = options.leading === false ? 0 : getTime();
|
|
138
|
+
timeout = null;
|
|
139
|
+
result = func.apply(context, args);
|
|
140
|
+
context = args = null;
|
|
141
|
+
};
|
|
142
|
+
return function () {
|
|
143
|
+
var now = getTime();
|
|
144
|
+
if (!previous && options.leading === false) previous = now;
|
|
145
|
+
var remaining = wait - (now - previous);
|
|
146
|
+
context = this;
|
|
147
|
+
args = arguments;
|
|
148
|
+
if (remaining <= 0) {
|
|
149
|
+
clearTimeout(timeout);
|
|
150
|
+
timeout = null;
|
|
151
|
+
previous = now;
|
|
152
|
+
result = func.apply(context, args);
|
|
153
|
+
context = args = null;
|
|
154
|
+
} else if (!timeout && options.trailing !== false) {
|
|
155
|
+
timeout = setTimeout(later, remaining);
|
|
156
|
+
}
|
|
157
|
+
return result;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Enables ScrollSpy using a selector
|
|
163
|
+
* @param {jQuery|string} selector The elements collection, or a selector
|
|
164
|
+
* @param {Object=} options Optional.
|
|
165
|
+
throttle : number -> scrollspy throttling. Default: 100 ms
|
|
166
|
+
offsetTop : number -> offset from top. Default: 0
|
|
167
|
+
offsetRight : number -> offset from right. Default: 0
|
|
168
|
+
offsetBottom : number -> offset from bottom. Default: 0
|
|
169
|
+
offsetLeft : number -> offset from left. Default: 0
|
|
170
|
+
* @returns {jQuery}
|
|
171
|
+
*/
|
|
172
|
+
$.scrollSpy = function(selector, options) {
|
|
173
|
+
var visible = [];
|
|
174
|
+
selector = $(selector);
|
|
175
|
+
selector.each(function(i, element) {
|
|
176
|
+
elements.push($(element));
|
|
177
|
+
$(element).data("scrollSpy:id", i);
|
|
178
|
+
// Smooth scroll to section
|
|
179
|
+
$('a[href=#' + $(element).attr('id') + ']').click(function(e) {
|
|
180
|
+
e.preventDefault();
|
|
181
|
+
var offset = $(this.hash).offset().top + 1;
|
|
182
|
+
|
|
183
|
+
// offset - 200 allows elements near bottom of page to scroll
|
|
184
|
+
|
|
185
|
+
$('html, body').animate({ scrollTop: offset - 200 }, {duration: 400, queue: false, easing: 'easeOutCubic'});
|
|
186
|
+
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
options = options || {
|
|
190
|
+
throttle: 100
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
offset.top = options.offsetTop || 0;
|
|
194
|
+
offset.right = options.offsetRight || 0;
|
|
195
|
+
offset.bottom = options.offsetBottom || 0;
|
|
196
|
+
offset.left = options.offsetLeft || 0;
|
|
197
|
+
|
|
198
|
+
var throttledScroll = throttle(onScroll, options.throttle || 100);
|
|
199
|
+
var readyScroll = function(){
|
|
200
|
+
$(document).ready(throttledScroll);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
if (!isSpying) {
|
|
204
|
+
jWindow.on('scroll', readyScroll);
|
|
205
|
+
jWindow.on('resize', readyScroll);
|
|
206
|
+
isSpying = true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// perform a scan once, after current execution context, and after dom is ready
|
|
210
|
+
setTimeout(readyScroll, 0);
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
selector.on('scrollSpy:enter', function() {
|
|
214
|
+
visible = $.grep(visible, function(value) {
|
|
215
|
+
return value.height() != 0;
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
var $this = $(this);
|
|
219
|
+
|
|
220
|
+
if (visible[0]) {
|
|
221
|
+
$('a[href=#' + visible[0].attr('id') + ']').removeClass('active');
|
|
222
|
+
if ($this.data('scrollSpy:id') < visible[0].data('scrollSpy:id')) {
|
|
223
|
+
visible.unshift($(this));
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
visible.push($(this));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
visible.push($(this));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
$('a[href=#' + visible[0].attr('id') + ']').addClass('active');
|
|
235
|
+
});
|
|
236
|
+
selector.on('scrollSpy:exit', function() {
|
|
237
|
+
visible = $.grep(visible, function(value) {
|
|
238
|
+
return value.height() != 0;
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
if (visible[0]) {
|
|
242
|
+
$('a[href=#' + visible[0].attr('id') + ']').removeClass('active');
|
|
243
|
+
var $this = $(this);
|
|
244
|
+
visible = $.grep(visible, function(value) {
|
|
245
|
+
return value.attr('id') != $this.attr('id');
|
|
246
|
+
});
|
|
247
|
+
if (visible[0]) { // Check if empty
|
|
248
|
+
$('a[href=#' + visible[0].attr('id') + ']').addClass('active');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
return selector;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Listen for window resize events
|
|
258
|
+
* @param {Object=} options Optional. Set { throttle: number } to change throttling. Default: 100 ms
|
|
259
|
+
* @returns {jQuery} $(window)
|
|
260
|
+
*/
|
|
261
|
+
$.winSizeSpy = function(options) {
|
|
262
|
+
$.winSizeSpy = function() { return jWindow; }; // lock from multiple calls
|
|
263
|
+
options = options || {
|
|
264
|
+
throttle: 100
|
|
265
|
+
};
|
|
266
|
+
return jWindow.on('resize', throttle(onWinSize, options.throttle || 100));
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Enables ScrollSpy on a collection of elements
|
|
271
|
+
* e.g. $('.scrollSpy').scrollSpy()
|
|
272
|
+
* @param {Object=} options Optional.
|
|
273
|
+
throttle : number -> scrollspy throttling. Default: 100 ms
|
|
274
|
+
offsetTop : number -> offset from top. Default: 0
|
|
275
|
+
offsetRight : number -> offset from right. Default: 0
|
|
276
|
+
offsetBottom : number -> offset from bottom. Default: 0
|
|
277
|
+
offsetLeft : number -> offset from left. Default: 0
|
|
278
|
+
* @returns {jQuery}
|
|
279
|
+
*/
|
|
280
|
+
$.fn.scrollSpy = function(options) {
|
|
281
|
+
return $.scrollSpy($(this), options);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
})(jQuery);
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
(function ($) {
|
|
2
|
+
// left: 37, up: 38, right: 39, down: 40,
|
|
3
|
+
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
|
|
4
|
+
// var keys = [32, 33, 34, 35, 36, 37, 38, 39, 40];
|
|
5
|
+
|
|
6
|
+
// function preventDefault(e) {
|
|
7
|
+
// e = e || window.event;
|
|
8
|
+
// if (e.preventDefault)
|
|
9
|
+
// e.preventDefault();
|
|
10
|
+
// e.returnValue = false;
|
|
11
|
+
// }
|
|
12
|
+
|
|
13
|
+
// function keydown(e) {
|
|
14
|
+
// for (var i = keys.length; i--;) {
|
|
15
|
+
// if (e.keyCode === keys[i]) {
|
|
16
|
+
// preventDefault(e);
|
|
17
|
+
// return;
|
|
18
|
+
// }
|
|
19
|
+
// }
|
|
20
|
+
// }
|
|
21
|
+
|
|
22
|
+
// function wheel(e) {
|
|
23
|
+
// preventDefault(e);
|
|
24
|
+
// }
|
|
25
|
+
|
|
26
|
+
// function disable_scroll() {
|
|
27
|
+
// if (window.addEventListener) {
|
|
28
|
+
// window.addEventListener('DOMMouseScroll', wheel, false);
|
|
29
|
+
// }
|
|
30
|
+
// window.onmousewheel = document.onmousewheel = wheel;
|
|
31
|
+
// document.onkeydown = keydown;
|
|
32
|
+
// $('body').css({'overflow-y' : 'hidden'});
|
|
33
|
+
// }
|
|
34
|
+
|
|
35
|
+
// function enable_scroll() {
|
|
36
|
+
// if (window.removeEventListener) {
|
|
37
|
+
// window.removeEventListener('DOMMouseScroll', wheel, false);
|
|
38
|
+
// }
|
|
39
|
+
// window.onmousewheel = document.onmousewheel = document.onkeydown = null;
|
|
40
|
+
// $('body').css({'overflow-y' : ''});
|
|
41
|
+
|
|
42
|
+
// }
|
|
43
|
+
|
|
44
|
+
var methods = {
|
|
45
|
+
init : function(options) {
|
|
46
|
+
var defaults = {
|
|
47
|
+
menuWidth: 240,
|
|
48
|
+
edge: 'left',
|
|
49
|
+
closeOnClick: false
|
|
50
|
+
}
|
|
51
|
+
options = $.extend(defaults, options);
|
|
52
|
+
|
|
53
|
+
$(this).each(function(){
|
|
54
|
+
var $this = $(this);
|
|
55
|
+
var menu_id = $("#"+ $this.attr('data-activates'));
|
|
56
|
+
|
|
57
|
+
// Set to width
|
|
58
|
+
if (options.menuWidth != 240) {
|
|
59
|
+
menu_id.css('width', options.menuWidth);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Add Touch Area
|
|
63
|
+
$('body').append($('<div class="drag-target"></div>'));
|
|
64
|
+
|
|
65
|
+
if (options.edge == 'left') {
|
|
66
|
+
menu_id.css('left', -1 * (options.menuWidth + 10));
|
|
67
|
+
$('.drag-target').css({'left': 0}); // Add Touch Area
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
menu_id.addClass('right-aligned') // Change text-alignment to right
|
|
71
|
+
.css('right', -1 * (options.menuWidth + 10))
|
|
72
|
+
.css('left', '');
|
|
73
|
+
$('.drag-target').css({'right': 0}); // Add Touch Area
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// If fixed sidenav, bring menu out
|
|
77
|
+
if (menu_id.hasClass('fixed')) {
|
|
78
|
+
if ($(window).width() > 992) {
|
|
79
|
+
menu_id.css('left', 0);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Window resize to reset on large screens fixed
|
|
84
|
+
if (menu_id.hasClass('fixed')) {
|
|
85
|
+
$(window).resize( function() {
|
|
86
|
+
if (window.innerWidth > 992) {
|
|
87
|
+
// Close menu if window is resized bigger than 992 and user has fixed sidenav
|
|
88
|
+
if ($('#sidenav-overlay').css('opacity') != 0 && menuOut) {
|
|
89
|
+
removeMenu(true);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
menu_id.removeAttr('style');
|
|
93
|
+
menu_id.css('width', options.menuWidth);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else if (menuOut === false){
|
|
97
|
+
if (options.edge === 'left')
|
|
98
|
+
menu_id.css('left', -1 * (options.menuWidth + 10));
|
|
99
|
+
else
|
|
100
|
+
menu_id.css('right', -1 * (options.menuWidth + 10));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// if closeOnClick, then add close event for all a tags in side sideNav
|
|
107
|
+
if (options.closeOnClick == true) {
|
|
108
|
+
menu_id.on("click.itemclick", "a:not(.collapsible-header)", function(){
|
|
109
|
+
removeMenu();
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function removeMenu(restoreNav) {
|
|
114
|
+
panning = false;
|
|
115
|
+
menuOut = false;
|
|
116
|
+
$('#sidenav-overlay').velocity({opacity: 0}, {duration: 200, queue: false, easing: 'easeOutQuad',
|
|
117
|
+
complete: function() {
|
|
118
|
+
$(this).remove();
|
|
119
|
+
} });
|
|
120
|
+
if (options.edge === 'left') {
|
|
121
|
+
// Reset phantom div
|
|
122
|
+
$('.drag-target').css({width: '', right: '', left: '0'});
|
|
123
|
+
menu_id.velocity(
|
|
124
|
+
{left: -1 * (options.menuWidth + 10)},
|
|
125
|
+
{ duration: 200,
|
|
126
|
+
queue: false,
|
|
127
|
+
easing: 'easeOutCubic',
|
|
128
|
+
complete: function() {
|
|
129
|
+
if (restoreNav == true) {
|
|
130
|
+
// Restore Fixed sidenav
|
|
131
|
+
menu_id.removeAttr('style');
|
|
132
|
+
menu_id.css('width', options.menuWidth);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
// Reset phantom div
|
|
140
|
+
$('.drag-target').css({width: '', right: '0', left: ''});
|
|
141
|
+
menu_id.velocity(
|
|
142
|
+
{right: -1 * (options.menuWidth + 10)},
|
|
143
|
+
{ duration: 200,
|
|
144
|
+
queue: false,
|
|
145
|
+
easing: 'easeOutCubic',
|
|
146
|
+
complete: function() {
|
|
147
|
+
if (restoreNav == true) {
|
|
148
|
+
// Restore Fixed sidenav
|
|
149
|
+
menu_id.removeAttr('style');
|
|
150
|
+
menu_id.css('width', options.menuWidth);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
// Touch Event
|
|
160
|
+
var panning = false;
|
|
161
|
+
var menuOut = false;
|
|
162
|
+
|
|
163
|
+
$('.drag-target').on('click', function(){
|
|
164
|
+
removeMenu();
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
$('.drag-target').hammer({
|
|
168
|
+
prevent_default: false
|
|
169
|
+
}).bind('pan', function(e) {
|
|
170
|
+
|
|
171
|
+
if (e.gesture.pointerType == "touch") {
|
|
172
|
+
|
|
173
|
+
var direction = e.gesture.direction;
|
|
174
|
+
var x = e.gesture.center.x;
|
|
175
|
+
var y = e.gesture.center.y;
|
|
176
|
+
var velocityX = e.gesture.velocityX;
|
|
177
|
+
|
|
178
|
+
// If overlay does not exist, create one and if it is clicked, close menu
|
|
179
|
+
if ($('#sidenav-overlay').length === 0) {
|
|
180
|
+
var overlay = $('<div id="sidenav-overlay"></div>');
|
|
181
|
+
overlay.css('opacity', 0).click( function(){
|
|
182
|
+
removeMenu();
|
|
183
|
+
});
|
|
184
|
+
$('body').append(overlay);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Keep within boundaries
|
|
188
|
+
if (options.edge === 'left') {
|
|
189
|
+
if (x > options.menuWidth) { x = options.menuWidth; }
|
|
190
|
+
else if (x < 0) { x = 0; }
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (options.edge === 'left') {
|
|
194
|
+
// Left Direction
|
|
195
|
+
if (x < (options.menuWidth / 2)) { menuOut = false; }
|
|
196
|
+
// Right Direction
|
|
197
|
+
else if (x >= (options.menuWidth / 2)) { menuOut = true; }
|
|
198
|
+
|
|
199
|
+
menu_id.css('left', (x - options.menuWidth));
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
// Left Direction
|
|
203
|
+
if (x < ($(window).width() - options.menuWidth / 2)) {
|
|
204
|
+
menuOut = true;
|
|
205
|
+
}
|
|
206
|
+
// Right Direction
|
|
207
|
+
else if (x >= ($(window).width() - options.menuWidth / 2)) {
|
|
208
|
+
menuOut = false;
|
|
209
|
+
}
|
|
210
|
+
var rightPos = -1 *(x - options.menuWidth / 2);
|
|
211
|
+
if (rightPos > 0) {
|
|
212
|
+
rightPos = 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
menu_id.css('right', rightPos);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
// Percentage overlay
|
|
222
|
+
if (options.edge === 'left') {
|
|
223
|
+
var overlayPerc = x / options.menuWidth;
|
|
224
|
+
$('#sidenav-overlay').velocity({opacity: overlayPerc }, {duration: 50, queue: false, easing: 'easeOutQuad'});
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
var overlayPerc = Math.abs((x - $(window).width()) / options.menuWidth);
|
|
228
|
+
$('#sidenav-overlay').velocity({opacity: overlayPerc }, {duration: 50, queue: false, easing: 'easeOutQuad'});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
}).bind('panend', function(e) {
|
|
233
|
+
if (e.gesture.pointerType == "touch") {
|
|
234
|
+
var velocityX = e.gesture.velocityX;
|
|
235
|
+
panning = false;
|
|
236
|
+
if (options.edge === 'left') {
|
|
237
|
+
// If velocityX <= 0.3 then the user is flinging the menu closed so ignore menuOut
|
|
238
|
+
if ((menuOut && velocityX <= 0.3) || velocityX < -0.5) {
|
|
239
|
+
menu_id.velocity({left: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
|
|
240
|
+
$('#sidenav-overlay').velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
|
|
241
|
+
$('.drag-target').css({width: '50%', right: 0, left: ''});
|
|
242
|
+
}
|
|
243
|
+
else if (!menuOut || velocityX > 0.3) {
|
|
244
|
+
menu_id.velocity({left: -1 * (options.menuWidth + 10)}, {duration: 200, queue: false, easing: 'easeOutQuad'});
|
|
245
|
+
$('#sidenav-overlay').velocity({opacity: 0 }, {duration: 200, queue: false, easing: 'easeOutQuad',
|
|
246
|
+
complete: function () {
|
|
247
|
+
$(this).remove();
|
|
248
|
+
}});
|
|
249
|
+
$('.drag-target').css({width: '10px', right: '', left: 0});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
if ((menuOut && velocityX >= -0.3) || velocityX > 0.5) {
|
|
254
|
+
menu_id.velocity({right: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
|
|
255
|
+
$('#sidenav-overlay').velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
|
|
256
|
+
$('.drag-target').css({width: '50%', right: '', left: 0});
|
|
257
|
+
}
|
|
258
|
+
else if (!menuOut || velocityX < -0.3) {
|
|
259
|
+
menu_id.velocity({right: -1 * (options.menuWidth + 10)}, {duration: 200, queue: false, easing: 'easeOutQuad'});
|
|
260
|
+
$('#sidenav-overlay').velocity({opacity: 0 }, {duration: 200, queue: false, easing: 'easeOutQuad',
|
|
261
|
+
complete: function () {
|
|
262
|
+
$(this).remove();
|
|
263
|
+
}});
|
|
264
|
+
$('.drag-target').css({width: '10px', right: 0, left: ''});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
$this.click(function() {
|
|
272
|
+
if (menuOut == true) {
|
|
273
|
+
menuOut = false;
|
|
274
|
+
panning = false;
|
|
275
|
+
removeMenu();
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
|
|
279
|
+
if (options.edge === 'left') {
|
|
280
|
+
$('.drag-target').css({width: '50%', right: 0, left: ''});
|
|
281
|
+
menu_id.velocity({left: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
$('.drag-target').css({width: '50%', right: '', left: 0});
|
|
285
|
+
menu_id.velocity({right: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
|
|
286
|
+
menu_id.css('left','');
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
var overlay = $('<div id="sidenav-overlay"></div>');
|
|
290
|
+
overlay.css('opacity', 0)
|
|
291
|
+
.click(function(){
|
|
292
|
+
menuOut = false;
|
|
293
|
+
panning = false;
|
|
294
|
+
removeMenu();
|
|
295
|
+
overlay.velocity({opacity: 0}, {duration: 300, queue: false, easing: 'easeOutQuad',
|
|
296
|
+
complete: function() {
|
|
297
|
+
$(this).remove();
|
|
298
|
+
} });
|
|
299
|
+
|
|
300
|
+
});
|
|
301
|
+
$('body').append(overlay);
|
|
302
|
+
overlay.velocity({opacity: 1}, {duration: 300, queue: false, easing: 'easeOutQuad',
|
|
303
|
+
complete: function () {
|
|
304
|
+
menuOut = true;
|
|
305
|
+
panning = false;
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return false;
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
},
|
|
316
|
+
show : function() {
|
|
317
|
+
this.trigger('click');
|
|
318
|
+
},
|
|
319
|
+
hide : function() {
|
|
320
|
+
$('#sidenav-overlay').trigger('click');
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
$.fn.sideNav = function(methodOrOptions) {
|
|
326
|
+
if ( methods[methodOrOptions] ) {
|
|
327
|
+
return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
|
328
|
+
} else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
|
|
329
|
+
// Default to "init"
|
|
330
|
+
return methods.init.apply( this, arguments );
|
|
331
|
+
} else {
|
|
332
|
+
$.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.tooltip' );
|
|
333
|
+
}
|
|
334
|
+
}; // PLugin end
|
|
335
|
+
}( jQuery ));
|