materialize-sass 0.97.0 → 1.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +5 -5
  2. data/.gitattributes +1 -0
  3. data/.gitignore +3 -0
  4. data/README.md +48 -10
  5. data/Rakefile +129 -1
  6. data/assets/javascripts/materialize/anime.min.js +417 -0
  7. data/assets/javascripts/materialize/autocomplete.js +504 -0
  8. data/assets/javascripts/materialize/buttons.js +409 -0
  9. data/assets/javascripts/materialize/cards.js +34 -0
  10. data/assets/javascripts/materialize/carousel.js +797 -0
  11. data/assets/javascripts/materialize/cash.js +990 -0
  12. data/assets/javascripts/materialize/characterCounter.js +180 -0
  13. data/assets/javascripts/materialize/chips.js +564 -0
  14. data/assets/javascripts/materialize/collapsible.js +337 -0
  15. data/assets/javascripts/materialize/component.js +57 -0
  16. data/assets/javascripts/materialize/datepicker.js +935 -0
  17. data/assets/javascripts/materialize/dropdown.js +659 -0
  18. data/assets/javascripts/materialize/extras/nouislider.js +2147 -0
  19. data/assets/javascripts/materialize/extras/nouislider.min.js +1 -0
  20. data/assets/javascripts/materialize/forms.js +244 -0
  21. data/assets/javascripts/materialize/global.js +408 -0
  22. data/assets/javascripts/materialize/materialbox.js +513 -0
  23. data/assets/javascripts/materialize/modal.js +449 -0
  24. data/assets/javascripts/materialize/parallax.js +173 -0
  25. data/assets/javascripts/materialize/pushpin.js +179 -0
  26. data/assets/javascripts/materialize/range.js +310 -0
  27. data/assets/javascripts/materialize/scrollspy.js +328 -0
  28. data/assets/javascripts/materialize/select.js +497 -0
  29. data/assets/javascripts/materialize/sidenav.js +655 -0
  30. data/assets/javascripts/materialize/slider.js +424 -0
  31. data/assets/javascripts/materialize/tabs.js +476 -0
  32. data/assets/javascripts/materialize/tapTarget.js +364 -0
  33. data/assets/javascripts/materialize/timepicker.js +647 -0
  34. data/assets/javascripts/materialize/toasts.js +355 -0
  35. data/assets/javascripts/materialize/tooltip.js +351 -0
  36. data/{app/assets → assets}/javascripts/materialize/waves.js +42 -47
  37. data/assets/javascripts/materialize-sprockets.js +29 -0
  38. data/assets/javascripts/materialize.js +12374 -0
  39. data/assets/stylesheets/materialize/components/_badges.scss +55 -0
  40. data/assets/stylesheets/materialize/components/_buttons.scss +322 -0
  41. data/{app/assets → assets}/stylesheets/materialize/components/_cards.scss +72 -29
  42. data/assets/stylesheets/materialize/components/_carousel.scss +90 -0
  43. data/assets/stylesheets/materialize/components/_chips.scss +90 -0
  44. data/{app/assets → assets}/stylesheets/materialize/components/_collapsible.scss +23 -17
  45. data/assets/stylesheets/materialize/components/_color-classes.scss +32 -0
  46. data/{app/assets/stylesheets/materialize/components/_color.scss → assets/stylesheets/materialize/components/_color-variables.scss} +22 -64
  47. data/assets/stylesheets/materialize/components/_datepicker.scss +191 -0
  48. data/assets/stylesheets/materialize/components/_dropdown.scss +85 -0
  49. data/{app/assets → assets}/stylesheets/materialize/components/_global.scss +197 -144
  50. data/{app/assets → assets}/stylesheets/materialize/components/_grid.scss +57 -18
  51. data/assets/stylesheets/materialize/components/_icons-material-design.scss +5 -0
  52. data/{app/assets → assets}/stylesheets/materialize/components/_materialbox.scss +15 -13
  53. data/{app/assets → assets}/stylesheets/materialize/components/_modal.scss +18 -14
  54. data/{app/assets → assets}/stylesheets/materialize/components/_navbar.scss +89 -25
  55. data/assets/stylesheets/materialize/components/_normalize.scss +447 -0
  56. data/{app/assets → assets}/stylesheets/materialize/components/_preloader.scss +5 -3
  57. data/assets/stylesheets/materialize/components/_pulse.scss +34 -0
  58. data/assets/stylesheets/materialize/components/_sidenav.scss +208 -0
  59. data/{app/assets → assets}/stylesheets/materialize/components/_slider.scss +2 -2
  60. data/{app/assets → assets}/stylesheets/materialize/components/_table_of_contents.scss +5 -5
  61. data/assets/stylesheets/materialize/components/_tabs.scss +99 -0
  62. data/assets/stylesheets/materialize/components/_tapTarget.scss +103 -0
  63. data/assets/stylesheets/materialize/components/_timepicker.scss +183 -0
  64. data/{app/assets → assets}/stylesheets/materialize/components/_toast.scss +17 -22
  65. data/assets/stylesheets/materialize/components/_tooltip.scss +32 -0
  66. data/assets/stylesheets/materialize/components/_transitions.scss +13 -0
  67. data/{app/assets → assets}/stylesheets/materialize/components/_typography.scss +11 -9
  68. data/assets/stylesheets/materialize/components/_variables.scss +349 -0
  69. data/assets/stylesheets/materialize/components/_waves.scss +114 -0
  70. data/assets/stylesheets/materialize/components/forms/_checkboxes.scss +200 -0
  71. data/assets/stylesheets/materialize/components/forms/_file-input.scss +44 -0
  72. data/assets/stylesheets/materialize/components/forms/_forms.scss +22 -0
  73. data/assets/stylesheets/materialize/components/forms/_input-fields.scss +354 -0
  74. data/assets/stylesheets/materialize/components/forms/_radio-buttons.scss +115 -0
  75. data/assets/stylesheets/materialize/components/forms/_range.scss +161 -0
  76. data/assets/stylesheets/materialize/components/forms/_select.scss +190 -0
  77. data/assets/stylesheets/materialize/components/forms/_switches.scss +89 -0
  78. data/assets/stylesheets/materialize/extras/nouislider.css +406 -0
  79. data/{app/assets → assets}/stylesheets/materialize.scss +13 -10
  80. data/lib/materialize-sass/engine.rb +11 -6
  81. data/lib/materialize-sass/helpers.rb +38 -0
  82. data/lib/materialize-sass/version.rb +1 -1
  83. data/lib/materialize-sass.rb +13 -28
  84. data/materialize-sass.gemspec +5 -5
  85. metadata +97 -105
  86. data/app/assets/fonts/material-design-icons/LICENSE.txt +0 -428
  87. data/app/assets/fonts/material-design-icons/Material-Design-Icons.eot +0 -0
  88. data/app/assets/fonts/material-design-icons/Material-Design-Icons.svg +0 -769
  89. data/app/assets/fonts/material-design-icons/Material-Design-Icons.ttf +0 -0
  90. data/app/assets/fonts/material-design-icons/Material-Design-Icons.woff +0 -0
  91. data/app/assets/fonts/material-design-icons/Material-Design-Icons.woff2 +0 -0
  92. data/app/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
  93. data/app/assets/fonts/roboto/Roboto-Bold.woff +0 -0
  94. data/app/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
  95. data/app/assets/fonts/roboto/Roboto-Light.ttf +0 -0
  96. data/app/assets/fonts/roboto/Roboto-Light.woff +0 -0
  97. data/app/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
  98. data/app/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
  99. data/app/assets/fonts/roboto/Roboto-Medium.woff +0 -0
  100. data/app/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
  101. data/app/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
  102. data/app/assets/fonts/roboto/Roboto-Regular.woff +0 -0
  103. data/app/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
  104. data/app/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
  105. data/app/assets/fonts/roboto/Roboto-Thin.woff +0 -0
  106. data/app/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
  107. data/app/assets/javascripts/materialize/animation.js +0 -9
  108. data/app/assets/javascripts/materialize/buttons.js +0 -61
  109. data/app/assets/javascripts/materialize/cards.js +0 -27
  110. data/app/assets/javascripts/materialize/character_counter.js +0 -59
  111. data/app/assets/javascripts/materialize/collapsible.js +0 -139
  112. data/app/assets/javascripts/materialize/date_picker/picker.date.js +0 -1430
  113. data/app/assets/javascripts/materialize/date_picker/picker.js +0 -1123
  114. data/app/assets/javascripts/materialize/dropdown.js +0 -178
  115. data/app/assets/javascripts/materialize/forms.js +0 -456
  116. data/app/assets/javascripts/materialize/global.js +0 -36
  117. data/app/assets/javascripts/materialize/hammer.min.js +0 -1
  118. data/app/assets/javascripts/materialize/init.js +0 -136
  119. data/app/assets/javascripts/materialize/jquery.easing.1.3.js +0 -205
  120. data/app/assets/javascripts/materialize/jquery.hammer.js +0 -33
  121. data/app/assets/javascripts/materialize/jquery.timeago.min.js +0 -1
  122. data/app/assets/javascripts/materialize/leanModal.js +0 -178
  123. data/app/assets/javascripts/materialize/materialbox.js +0 -249
  124. data/app/assets/javascripts/materialize/parallax.js +0 -58
  125. data/app/assets/javascripts/materialize/prism.js +0 -8
  126. data/app/assets/javascripts/materialize/pushpin.js +0 -62
  127. data/app/assets/javascripts/materialize/scrollFire.js +0 -44
  128. data/app/assets/javascripts/materialize/scrollspy.js +0 -284
  129. data/app/assets/javascripts/materialize/sideNav.js +0 -312
  130. data/app/assets/javascripts/materialize/slider.js +0 -301
  131. data/app/assets/javascripts/materialize/tabs.js +0 -136
  132. data/app/assets/javascripts/materialize/toasts.js +0 -125
  133. data/app/assets/javascripts/materialize/tooltip.js +0 -166
  134. data/app/assets/javascripts/materialize/transitions.js +0 -154
  135. data/app/assets/javascripts/materialize/velocity.min.js +0 -4
  136. data/app/assets/javascripts/materialize-sprockets.js +0 -27
  137. data/app/assets/javascripts/materialize.js +0 -6159
  138. data/app/assets/stylesheets/materialize/components/_buttons.scss +0 -157
  139. data/app/assets/stylesheets/materialize/components/_dropdown.scss +0 -40
  140. data/app/assets/stylesheets/materialize/components/_form.scss +0 -886
  141. data/app/assets/stylesheets/materialize/components/_icons-material-design.scss +0 -3257
  142. data/app/assets/stylesheets/materialize/components/_mixins.scss +0 -5
  143. data/app/assets/stylesheets/materialize/components/_normalize.scss +0 -427
  144. data/app/assets/stylesheets/materialize/components/_prefixer.scss +0 -376
  145. data/app/assets/stylesheets/materialize/components/_roboto.scss +0 -38
  146. data/app/assets/stylesheets/materialize/components/_sideNav.scss +0 -111
  147. data/app/assets/stylesheets/materialize/components/_tabs.scss +0 -47
  148. data/app/assets/stylesheets/materialize/components/_tooltip.scss +0 -34
  149. data/app/assets/stylesheets/materialize/components/_variables.scss +0 -152
  150. data/app/assets/stylesheets/materialize/components/_waves.scss +0 -167
  151. data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +0 -435
  152. data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +0 -201
  153. data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +0 -125
@@ -1,284 +0,0 @@
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);
@@ -1,312 +0,0 @@
1
- (function ($) {
2
-
3
- var methods = {
4
- init : function(options) {
5
- var defaults = {
6
- menuWidth: 240,
7
- edge: 'left',
8
- closeOnClick: false
9
- };
10
- options = $.extend(defaults, options);
11
-
12
- $(this).each(function(){
13
- var $this = $(this);
14
- var menu_id = $("#"+ $this.attr('data-activates'));
15
-
16
- // Set to width
17
- if (options.menuWidth != 240) {
18
- menu_id.css('width', options.menuWidth);
19
- }
20
-
21
- // Add Touch Area
22
- $('body').append($('<div class="drag-target"></div>'));
23
-
24
- if (options.edge == 'left') {
25
- menu_id.css('left', -1 * (options.menuWidth + 10));
26
- $('.drag-target').css({'left': 0}); // Add Touch Area
27
- }
28
- else {
29
- menu_id.addClass('right-aligned') // Change text-alignment to right
30
- .css('right', -1 * (options.menuWidth + 10))
31
- .css('left', '');
32
- $('.drag-target').css({'right': 0}); // Add Touch Area
33
- }
34
-
35
- // If fixed sidenav, bring menu out
36
- if (menu_id.hasClass('fixed')) {
37
- if (window.innerWidth > 992) {
38
- menu_id.css('left', 0);
39
- }
40
- }
41
-
42
- // Window resize to reset on large screens fixed
43
- if (menu_id.hasClass('fixed')) {
44
- $(window).resize( function() {
45
- if (window.innerWidth > 992) {
46
- // Close menu if window is resized bigger than 992 and user has fixed sidenav
47
- if ($('#sidenav-overlay').css('opacity') !== 0 && menuOut) {
48
- removeMenu(true);
49
- }
50
- else {
51
- menu_id.removeAttr('style');
52
- menu_id.css('width', options.menuWidth);
53
- }
54
- }
55
- else if (menuOut === false){
56
- if (options.edge === 'left')
57
- menu_id.css('left', -1 * (options.menuWidth + 10));
58
- else
59
- menu_id.css('right', -1 * (options.menuWidth + 10));
60
- }
61
-
62
- });
63
- }
64
-
65
- // if closeOnClick, then add close event for all a tags in side sideNav
66
- if (options.closeOnClick === true) {
67
- menu_id.on("click.itemclick", "a:not(.collapsible-header)", function(){
68
- removeMenu();
69
- });
70
- }
71
-
72
- function removeMenu(restoreNav) {
73
- panning = false;
74
- menuOut = false;
75
-
76
- // Reenable scrolling
77
- $('body').css('overflow', '');
78
-
79
- $('#sidenav-overlay').velocity({opacity: 0}, {duration: 200, queue: false, easing: 'easeOutQuad',
80
- complete: function() {
81
- $(this).remove();
82
- } });
83
- if (options.edge === 'left') {
84
- // Reset phantom div
85
- $('.drag-target').css({width: '', right: '', left: '0'});
86
- menu_id.velocity(
87
- {left: -1 * (options.menuWidth + 10)},
88
- { duration: 200,
89
- queue: false,
90
- easing: 'easeOutCubic',
91
- complete: function() {
92
- if (restoreNav === true) {
93
- // Restore Fixed sidenav
94
- menu_id.removeAttr('style');
95
- menu_id.css('width', options.menuWidth);
96
- }
97
- }
98
-
99
- });
100
- }
101
- else {
102
- // Reset phantom div
103
- $('.drag-target').css({width: '', right: '0', left: ''});
104
- menu_id.velocity(
105
- {right: -1 * (options.menuWidth + 10)},
106
- { duration: 200,
107
- queue: false,
108
- easing: 'easeOutCubic',
109
- complete: function() {
110
- if (restoreNav === true) {
111
- // Restore Fixed sidenav
112
- menu_id.removeAttr('style');
113
- menu_id.css('width', options.menuWidth);
114
- }
115
- }
116
- });
117
- }
118
- }
119
-
120
-
121
-
122
- // Touch Event
123
- var panning = false;
124
- var menuOut = false;
125
-
126
- $('.drag-target').on('click', function(){
127
- removeMenu();
128
- });
129
-
130
- $('.drag-target').hammer({
131
- prevent_default: false
132
- }).bind('pan', function(e) {
133
-
134
- if (e.gesture.pointerType == "touch") {
135
-
136
- var direction = e.gesture.direction;
137
- var x = e.gesture.center.x;
138
- var y = e.gesture.center.y;
139
- var velocityX = e.gesture.velocityX;
140
-
141
- // Disable Scrolling
142
- $('body').css('overflow', 'hidden');
143
-
144
- // If overlay does not exist, create one and if it is clicked, close menu
145
- if ($('#sidenav-overlay').length === 0) {
146
- var overlay = $('<div id="sidenav-overlay"></div>');
147
- overlay.css('opacity', 0).click( function(){
148
- removeMenu();
149
- });
150
- $('body').append(overlay);
151
- }
152
-
153
- // Keep within boundaries
154
- if (options.edge === 'left') {
155
- if (x > options.menuWidth) { x = options.menuWidth; }
156
- else if (x < 0) { x = 0; }
157
- }
158
-
159
- if (options.edge === 'left') {
160
- // Left Direction
161
- if (x < (options.menuWidth / 2)) { menuOut = false; }
162
- // Right Direction
163
- else if (x >= (options.menuWidth / 2)) { menuOut = true; }
164
-
165
- menu_id.css('left', (x - options.menuWidth));
166
- }
167
- else {
168
- // Left Direction
169
- if (x < (window.innerWidth - options.menuWidth / 2)) {
170
- menuOut = true;
171
- }
172
- // Right Direction
173
- else if (x >= (window.innerWidth - options.menuWidth / 2)) {
174
- menuOut = false;
175
- }
176
- var rightPos = -1 *(x - options.menuWidth / 2);
177
- if (rightPos > 0) {
178
- rightPos = 0;
179
- }
180
-
181
- menu_id.css('right', rightPos);
182
- }
183
-
184
-
185
-
186
-
187
- // Percentage overlay
188
- var overlayPerc;
189
- if (options.edge === 'left') {
190
- overlayPerc = x / options.menuWidth;
191
- $('#sidenav-overlay').velocity({opacity: overlayPerc }, {duration: 50, queue: false, easing: 'easeOutQuad'});
192
- }
193
- else {
194
- overlayPerc = Math.abs((x - window.innerWidth) / options.menuWidth);
195
- $('#sidenav-overlay').velocity({opacity: overlayPerc }, {duration: 50, queue: false, easing: 'easeOutQuad'});
196
- }
197
- }
198
-
199
- }).bind('panend', function(e) {
200
-
201
- if (e.gesture.pointerType == "touch") {
202
- var velocityX = e.gesture.velocityX;
203
- panning = false;
204
- if (options.edge === 'left') {
205
- // If velocityX <= 0.3 then the user is flinging the menu closed so ignore menuOut
206
- if ((menuOut && velocityX <= 0.3) || velocityX < -0.5) {
207
- menu_id.velocity({left: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
208
- $('#sidenav-overlay').velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
209
- $('.drag-target').css({width: '50%', right: 0, left: ''});
210
- }
211
- else if (!menuOut || velocityX > 0.3) {
212
- // Enable Scrolling
213
- $('body').css('overflow', '');
214
- // Slide menu closed
215
- menu_id.velocity({left: -1 * (options.menuWidth + 10)}, {duration: 200, queue: false, easing: 'easeOutQuad'});
216
- $('#sidenav-overlay').velocity({opacity: 0 }, {duration: 200, queue: false, easing: 'easeOutQuad',
217
- complete: function () {
218
- $(this).remove();
219
- }});
220
- $('.drag-target').css({width: '10px', right: '', left: 0});
221
- }
222
- }
223
- else {
224
- if ((menuOut && velocityX >= -0.3) || velocityX > 0.5) {
225
- menu_id.velocity({right: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
226
- $('#sidenav-overlay').velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
227
- $('.drag-target').css({width: '50%', right: '', left: 0});
228
- }
229
- else if (!menuOut || velocityX < -0.3) {
230
- // Enable Scrolling
231
- $('body').css('overflow', '');
232
- // Slide menu closed
233
- menu_id.velocity({right: -1 * (options.menuWidth + 10)}, {duration: 200, queue: false, easing: 'easeOutQuad'});
234
- $('#sidenav-overlay').velocity({opacity: 0 }, {duration: 200, queue: false, easing: 'easeOutQuad',
235
- complete: function () {
236
- $(this).remove();
237
- }});
238
- $('.drag-target').css({width: '10px', right: 0, left: ''});
239
- }
240
- }
241
-
242
- }
243
- });
244
-
245
- $this.click(function() {
246
- if (menuOut === true) {
247
- menuOut = false;
248
- panning = false;
249
- removeMenu();
250
- }
251
- else {
252
-
253
- // Disable Scrolling
254
- $('body').css('overflow', 'hidden');
255
-
256
- if (options.edge === 'left') {
257
- $('.drag-target').css({width: '50%', right: 0, left: ''});
258
- menu_id.velocity({left: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
259
- }
260
- else {
261
- $('.drag-target').css({width: '50%', right: '', left: 0});
262
- menu_id.velocity({right: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
263
- menu_id.css('left','');
264
- }
265
-
266
- var overlay = $('<div id="sidenav-overlay"></div>');
267
- overlay.css('opacity', 0)
268
- .click(function(){
269
- menuOut = false;
270
- panning = false;
271
- removeMenu();
272
- overlay.velocity({opacity: 0}, {duration: 300, queue: false, easing: 'easeOutQuad',
273
- complete: function() {
274
- $(this).remove();
275
- } });
276
-
277
- });
278
- $('body').append(overlay);
279
- overlay.velocity({opacity: 1}, {duration: 300, queue: false, easing: 'easeOutQuad',
280
- complete: function () {
281
- menuOut = true;
282
- panning = false;
283
- }
284
- });
285
- }
286
-
287
- return false;
288
- });
289
- });
290
-
291
-
292
- },
293
- show : function() {
294
- this.trigger('click');
295
- },
296
- hide : function() {
297
- $('#sidenav-overlay').trigger('click');
298
- }
299
- };
300
-
301
-
302
- $.fn.sideNav = function(methodOrOptions) {
303
- if ( methods[methodOrOptions] ) {
304
- return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
305
- } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
306
- // Default to "init"
307
- return methods.init.apply( this, arguments );
308
- } else {
309
- $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.sideNav' );
310
- }
311
- }; // Plugin end
312
- }( jQuery ));