materialize-sass 0.97.8 → 1.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +5 -5
  2. data/.gitattributes +1 -0
  3. data/.gitignore +1 -0
  4. data/README.md +34 -32
  5. data/Rakefile +38 -21
  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/{app/assets → assets}/javascripts/materialize-sprockets.js +12 -13
  38. data/assets/javascripts/materialize.js +12374 -0
  39. data/assets/stylesheets/materialize/components/_badges.scss +55 -0
  40. data/{app/assets → assets}/stylesheets/materialize/components/_buttons.scss +99 -58
  41. data/{app/assets → assets}/stylesheets/materialize/components/_cards.scss +14 -6
  42. data/{app/assets → assets}/stylesheets/materialize/components/_carousel.scss +12 -7
  43. data/{app/assets → assets}/stylesheets/materialize/components/_chips.scss +13 -6
  44. data/{app/assets → assets}/stylesheets/materialize/components/_collapsible.scss +16 -15
  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} +2 -44
  47. data/assets/stylesheets/materialize/components/_datepicker.scss +191 -0
  48. data/{app/assets → assets}/stylesheets/materialize/components/_dropdown.scss +35 -15
  49. data/{app/assets → assets}/stylesheets/materialize/components/_global.scss +96 -125
  50. data/{app/assets → assets}/stylesheets/materialize/components/_grid.scss +45 -36
  51. data/{app/assets → assets}/stylesheets/materialize/components/_icons-material-design.scss +0 -0
  52. data/{app/assets → assets}/stylesheets/materialize/components/_materialbox.scss +13 -12
  53. data/{app/assets → assets}/stylesheets/materialize/components/_modal.scss +7 -3
  54. data/{app/assets → assets}/stylesheets/materialize/components/_navbar.scss +29 -11
  55. data/assets/stylesheets/materialize/components/_normalize.scss +447 -0
  56. data/{app/assets → assets}/stylesheets/materialize/components/_preloader.scss +2 -2
  57. data/assets/stylesheets/materialize/components/_pulse.scss +34 -0
  58. data/{app/assets/stylesheets/materialize/components/_sideNav.scss → assets/stylesheets/materialize/components/_sidenav.scss} +47 -47
  59. data/{app/assets → assets}/stylesheets/materialize/components/_slider.scss +0 -0
  60. data/{app/assets → assets}/stylesheets/materialize/components/_table_of_contents.scss +5 -5
  61. data/{app/assets → assets}/stylesheets/materialize/components/_tabs.scss +10 -10
  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 +7 -14
  65. data/{app/assets → assets}/stylesheets/materialize/components/_tooltip.scss +3 -3
  66. data/assets/stylesheets/materialize/components/_transitions.scss +13 -0
  67. data/{app/assets → assets}/stylesheets/materialize/components/_typography.scss +8 -9
  68. data/{app/assets → assets}/stylesheets/materialize/components/_variables.scss +65 -29
  69. data/assets/stylesheets/materialize/components/_waves.scss +114 -0
  70. data/{app/assets → assets}/stylesheets/materialize/components/forms/_checkboxes.scss +26 -46
  71. data/{app/assets → assets}/stylesheets/materialize/components/forms/_file-input.scss +6 -0
  72. data/{app/assets → assets}/stylesheets/materialize/components/forms/_forms.scss +0 -0
  73. data/{app/assets → assets}/stylesheets/materialize/components/forms/_input-fields.scss +131 -63
  74. data/assets/stylesheets/materialize/components/forms/_radio-buttons.scss +115 -0
  75. data/{app/assets → assets}/stylesheets/materialize/components/forms/_range.scss +35 -33
  76. data/{app/assets → assets}/stylesheets/materialize/components/forms/_select.scss +88 -19
  77. data/{app/assets → assets}/stylesheets/materialize/components/forms/_switches.scss +32 -21
  78. data/assets/stylesheets/materialize/extras/nouislider.css +406 -0
  79. data/{app/assets → assets}/stylesheets/materialize.scss +10 -9
  80. data/lib/materialize-sass/engine.rb +9 -7
  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 -119
  86. data/app/assets/fonts/roboto/Roboto-Bold.eot +0 -0
  87. data/app/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
  88. data/app/assets/fonts/roboto/Roboto-Bold.woff +0 -0
  89. data/app/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
  90. data/app/assets/fonts/roboto/Roboto-Light.eot +0 -0
  91. data/app/assets/fonts/roboto/Roboto-Light.ttf +0 -0
  92. data/app/assets/fonts/roboto/Roboto-Light.woff +0 -0
  93. data/app/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
  94. data/app/assets/fonts/roboto/Roboto-Medium.eot +0 -0
  95. data/app/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
  96. data/app/assets/fonts/roboto/Roboto-Medium.woff +0 -0
  97. data/app/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
  98. data/app/assets/fonts/roboto/Roboto-Regular.eot +0 -0
  99. data/app/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
  100. data/app/assets/fonts/roboto/Roboto-Regular.woff +0 -0
  101. data/app/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
  102. data/app/assets/fonts/roboto/Roboto-Thin.eot +0 -0
  103. data/app/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
  104. data/app/assets/fonts/roboto/Roboto-Thin.woff +0 -0
  105. data/app/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
  106. data/app/assets/javascripts/materialize/animation.js +0 -9
  107. data/app/assets/javascripts/materialize/buttons.js +0 -267
  108. data/app/assets/javascripts/materialize/cards.js +0 -26
  109. data/app/assets/javascripts/materialize/carousel.js +0 -454
  110. data/app/assets/javascripts/materialize/character_counter.js +0 -72
  111. data/app/assets/javascripts/materialize/chips.js +0 -289
  112. data/app/assets/javascripts/materialize/collapsible.js +0 -160
  113. data/app/assets/javascripts/materialize/date_picker/picker.date.js +0 -1430
  114. data/app/assets/javascripts/materialize/date_picker/picker.js +0 -1123
  115. data/app/assets/javascripts/materialize/dropdown.js +0 -265
  116. data/app/assets/javascripts/materialize/extras/nouislider.js +0 -1666
  117. data/app/assets/javascripts/materialize/extras/nouislider.min.js +0 -1
  118. data/app/assets/javascripts/materialize/forms.js +0 -682
  119. data/app/assets/javascripts/materialize/global.js +0 -98
  120. data/app/assets/javascripts/materialize/hammer.min.js +0 -1
  121. data/app/assets/javascripts/materialize/init.js +0 -174
  122. data/app/assets/javascripts/materialize/initial.js +0 -11
  123. data/app/assets/javascripts/materialize/jquery.easing.1.3.js +0 -205
  124. data/app/assets/javascripts/materialize/jquery.hammer.js +0 -33
  125. data/app/assets/javascripts/materialize/jquery.timeago.min.js +0 -1
  126. data/app/assets/javascripts/materialize/materialbox.js +0 -269
  127. data/app/assets/javascripts/materialize/modal.js +0 -184
  128. data/app/assets/javascripts/materialize/parallax.js +0 -58
  129. data/app/assets/javascripts/materialize/prism.js +0 -8
  130. data/app/assets/javascripts/materialize/pushpin.js +0 -71
  131. data/app/assets/javascripts/materialize/scrollFire.js +0 -48
  132. data/app/assets/javascripts/materialize/scrollspy.js +0 -284
  133. data/app/assets/javascripts/materialize/sideNav.js +0 -370
  134. data/app/assets/javascripts/materialize/slider.js +0 -321
  135. data/app/assets/javascripts/materialize/tabs.js +0 -164
  136. data/app/assets/javascripts/materialize/toasts.js +0 -137
  137. data/app/assets/javascripts/materialize/tooltip.js +0 -236
  138. data/app/assets/javascripts/materialize/transitions.js +0 -169
  139. data/app/assets/javascripts/materialize/velocity.min.js +0 -5
  140. data/app/assets/javascripts/materialize.js +0 -5
  141. data/app/assets/stylesheets/materialize/components/_mixins.scss +0 -5
  142. data/app/assets/stylesheets/materialize/components/_normalize.scss +0 -424
  143. data/app/assets/stylesheets/materialize/components/_prefixer.scss +0 -384
  144. data/app/assets/stylesheets/materialize/components/_roboto.scss +0 -49
  145. data/app/assets/stylesheets/materialize/components/_waves.scss +0 -177
  146. data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +0 -435
  147. data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +0 -201
  148. data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +0 -125
  149. data/app/assets/stylesheets/materialize/components/forms/_radio-buttons.scss +0 -117
  150. data/app/assets/stylesheets/materialize/extras/nouislider.css +0 -259
@@ -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(scrollOffset) {
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
- var intersections = findElements(top+offset.top + scrollOffset || 200, right+offset.right, bottom+offset.bottom, left+offset.left);
75
- $.each(intersections, function(i, element) {
76
-
77
- var lastTick = element.data('scrollSpy:ticks');
78
- if (typeof lastTick != 'number') {
79
- // entered into view
80
- element.triggerHandler('scrollSpy:enter');
81
- }
82
-
83
- // update tick id
84
- element.data('scrollSpy:ticks', ticks);
85
- });
86
-
87
- // determine which elements are no longer in view
88
- $.each(elementsInView, function(i, element) {
89
- var lastTick = element.data('scrollSpy:ticks');
90
- if (typeof lastTick == 'number' && lastTick !== ticks) {
91
- // exited from view
92
- element.triggerHandler('scrollSpy:exit');
93
- element.data('scrollSpy:ticks', null);
94
- }
95
- });
96
-
97
- // remember elements in view for next tick
98
- elementsInView = intersections;
99
- }
100
-
101
- /**
102
- * Called when window is resized
103
- */
104
- function onWinSize() {
105
- jWindow.trigger('scrollSpy:winSize');
106
- }
107
-
108
- /**
109
- * Get time in ms
110
- * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
111
- * @type {function}
112
- * @return {number}
113
- */
114
- var getTime = (Date.now || function () {
115
- return new Date().getTime();
116
- });
117
-
118
- /**
119
- * Returns a function, that, when invoked, will only be triggered at most once
120
- * during a given window of time. Normally, the throttled function will run
121
- * as much as it can, without ever going more than once per `wait` duration;
122
- * but if you'd like to disable the execution on the leading edge, pass
123
- * `{leading: false}`. To disable execution on the trailing edge, ditto.
124
- * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
125
- * @param {function} func
126
- * @param {number} wait
127
- * @param {Object=} options
128
- * @returns {Function}
129
- */
130
- function throttle(func, wait, options) {
131
- var context, args, result;
132
- var timeout = null;
133
- var previous = 0;
134
- options || (options = {});
135
- var later = function () {
136
- previous = options.leading === false ? 0 : getTime();
137
- timeout = null;
138
- result = func.apply(context, args);
139
- context = args = null;
140
- };
141
- return function () {
142
- var now = getTime();
143
- if (!previous && options.leading === false) previous = now;
144
- var remaining = wait - (now - previous);
145
- context = this;
146
- args = arguments;
147
- if (remaining <= 0) {
148
- clearTimeout(timeout);
149
- timeout = null;
150
- previous = now;
151
- result = func.apply(context, args);
152
- context = args = null;
153
- } else if (!timeout && options.trailing !== false) {
154
- timeout = setTimeout(later, remaining);
155
- }
156
- return result;
157
- };
158
- };
159
-
160
- /**
161
- * Enables ScrollSpy using a selector
162
- * @param {jQuery|string} selector The elements collection, or a selector
163
- * @param {Object=} options Optional.
164
- throttle : number -> scrollspy throttling. Default: 100 ms
165
- offsetTop : number -> offset from top. Default: 0
166
- offsetRight : number -> offset from right. Default: 0
167
- offsetBottom : number -> offset from bottom. Default: 0
168
- offsetLeft : number -> offset from left. Default: 0
169
- * @returns {jQuery}
170
- */
171
- $.scrollSpy = function(selector, options) {
172
- var defaults = {
173
- throttle: 100,
174
- scrollOffset: 200 // offset - 200 allows elements near bottom of page to scroll
175
- };
176
- options = $.extend(defaults, options);
177
-
178
- var visible = [];
179
- selector = $(selector);
180
- selector.each(function(i, element) {
181
- elements.push($(element));
182
- $(element).data("scrollSpy:id", i);
183
- // Smooth scroll to section
184
- $('a[href="#' + $(element).attr('id') + '"]').click(function(e) {
185
- e.preventDefault();
186
- var offset = $(Materialize.escapeHash(this.hash)).offset().top + 1;
187
- $('html, body').animate({ scrollTop: offset - options.scrollOffset }, {duration: 400, queue: false, easing: 'easeOutCubic'});
188
- });
189
- });
190
-
191
- offset.top = options.offsetTop || 0;
192
- offset.right = options.offsetRight || 0;
193
- offset.bottom = options.offsetBottom || 0;
194
- offset.left = options.offsetLeft || 0;
195
-
196
- var throttledScroll = throttle(function() {
197
- onScroll(options.scrollOffset);
198
- }, options.throttle || 100);
199
- var readyScroll = function(){
200
- $(document).on('turbolinks:load', 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,370 +0,0 @@
1
- (function ($) {
2
-
3
- var methods = {
4
- init : function(options) {
5
- var defaults = {
6
- menuWidth: 300,
7
- edge: 'left',
8
- closeOnClick: false,
9
- draggable: true
10
- };
11
- options = $.extend(defaults, options);
12
-
13
- $(this).each(function(){
14
- var $this = $(this);
15
- var menu_id = $("#"+ $this.attr('data-activates'));
16
-
17
- // Set to width
18
- if (options.menuWidth != 300) {
19
- menu_id.css('width', options.menuWidth);
20
- }
21
-
22
- // Add Touch Area
23
- var $dragTarget;
24
- if (options.draggable) {
25
- $dragTarget = $('<div class="drag-target"></div>').attr('data-sidenav', $this.attr('data-activates'));
26
- $('body').append($dragTarget);
27
- } else {
28
- $dragTarget = $();
29
- }
30
-
31
- if (options.edge == 'left') {
32
- menu_id.css('transform', 'translateX(-100%)');
33
- $dragTarget.css({'left': 0}); // Add Touch Area
34
- }
35
- else {
36
- menu_id.addClass('right-aligned') // Change text-alignment to right
37
- .css('transform', 'translateX(100%)');
38
- $dragTarget.css({'right': 0}); // Add Touch Area
39
- }
40
-
41
- // If fixed sidenav, bring menu out
42
- if (menu_id.hasClass('fixed')) {
43
- if (window.innerWidth > 992) {
44
- menu_id.css('transform', 'translateX(0)');
45
- }
46
- }
47
-
48
- // Window resize to reset on large screens fixed
49
- if (menu_id.hasClass('fixed')) {
50
- $(window).resize( function() {
51
- if (window.innerWidth > 992) {
52
- // Close menu if window is resized bigger than 992 and user has fixed sidenav
53
- if ($('#sidenav-overlay').length !== 0 && menuOut) {
54
- removeMenu(true);
55
- }
56
- else {
57
- // menu_id.removeAttr('style');
58
- menu_id.css('transform', 'translateX(0%)');
59
- // menu_id.css('width', options.menuWidth);
60
- }
61
- }
62
- else if (menuOut === false){
63
- if (options.edge === 'left') {
64
- menu_id.css('transform', 'translateX(-100%)');
65
- } else {
66
- menu_id.css('transform', 'translateX(100%)');
67
- }
68
-
69
- }
70
-
71
- });
72
- }
73
-
74
- // if closeOnClick, then add close event for all a tags in side sideNav
75
- if (options.closeOnClick === true) {
76
- menu_id.on("click.itemclick", "a:not(.collapsible-header)", function(){
77
- removeMenu();
78
- });
79
- }
80
-
81
- var removeMenu = function(restoreNav) {
82
- panning = false;
83
- menuOut = false;
84
- // Reenable scrolling
85
- $('body').css({
86
- overflow: '',
87
- width: ''
88
- });
89
-
90
- $('#sidenav-overlay').velocity({opacity: 0}, {duration: 200,
91
- queue: false, easing: 'easeOutQuad',
92
- complete: function() {
93
- $(this).remove();
94
- } });
95
- if (options.edge === 'left') {
96
- // Reset phantom div
97
- $dragTarget.css({width: '', right: '', left: '0'});
98
- menu_id.velocity(
99
- {'translateX': '-100%'},
100
- { duration: 200,
101
- queue: false,
102
- easing: 'easeOutCubic',
103
- complete: function() {
104
- if (restoreNav === true) {
105
- // Restore Fixed sidenav
106
- menu_id.removeAttr('style');
107
- menu_id.css('width', options.menuWidth);
108
- }
109
- }
110
-
111
- });
112
- }
113
- else {
114
- // Reset phantom div
115
- $dragTarget.css({width: '', right: '0', left: ''});
116
- menu_id.velocity(
117
- {'translateX': '100%'},
118
- { duration: 200,
119
- queue: false,
120
- easing: 'easeOutCubic',
121
- complete: function() {
122
- if (restoreNav === true) {
123
- // Restore Fixed sidenav
124
- menu_id.removeAttr('style');
125
- menu_id.css('width', options.menuWidth);
126
- }
127
- }
128
- });
129
- }
130
- };
131
-
132
-
133
-
134
- // Touch Event
135
- var panning = false;
136
- var menuOut = false;
137
-
138
- if (options.draggable) {
139
- $dragTarget.on('click', function(){
140
- if (menuOut) {
141
- removeMenu();
142
- }
143
- });
144
-
145
- $dragTarget.hammer({
146
- prevent_default: false
147
- }).bind('pan', function(e) {
148
-
149
- if (e.gesture.pointerType == "touch") {
150
-
151
- var direction = e.gesture.direction;
152
- var x = e.gesture.center.x;
153
- var y = e.gesture.center.y;
154
- var velocityX = e.gesture.velocityX;
155
-
156
- // Disable Scrolling
157
- var $body = $('body');
158
- var $overlay = $('#sidenav-overlay');
159
- var oldWidth = $body.innerWidth();
160
- $body.css('overflow', 'hidden');
161
- $body.width(oldWidth);
162
-
163
- // If overlay does not exist, create one and if it is clicked, close menu
164
- if ($overlay.length === 0) {
165
- $overlay = $('<div id="sidenav-overlay"></div>');
166
- $overlay.css('opacity', 0).click( function(){
167
- removeMenu();
168
- });
169
- $('body').append($overlay);
170
- }
171
-
172
- // Keep within boundaries
173
- if (options.edge === 'left') {
174
- if (x > options.menuWidth) { x = options.menuWidth; }
175
- else if (x < 0) { x = 0; }
176
- }
177
-
178
- if (options.edge === 'left') {
179
- // Left Direction
180
- if (x < (options.menuWidth / 2)) { menuOut = false; }
181
- // Right Direction
182
- else if (x >= (options.menuWidth / 2)) { menuOut = true; }
183
- menu_id.css('transform', 'translateX(' + (x - options.menuWidth) + 'px)');
184
- }
185
- else {
186
- // Left Direction
187
- if (x < (window.innerWidth - options.menuWidth / 2)) {
188
- menuOut = true;
189
- }
190
- // Right Direction
191
- else if (x >= (window.innerWidth - options.menuWidth / 2)) {
192
- menuOut = false;
193
- }
194
- var rightPos = (x - options.menuWidth / 2);
195
- if (rightPos < 0) {
196
- rightPos = 0;
197
- }
198
-
199
- menu_id.css('transform', 'translateX(' + rightPos + 'px)');
200
- }
201
-
202
-
203
- // Percentage overlay
204
- var overlayPerc;
205
- if (options.edge === 'left') {
206
- overlayPerc = x / options.menuWidth;
207
- $overlay.velocity({opacity: overlayPerc }, {duration: 10, queue: false, easing: 'easeOutQuad'});
208
- }
209
- else {
210
- overlayPerc = Math.abs((x - window.innerWidth) / options.menuWidth);
211
- $overlay.velocity({opacity: overlayPerc }, {duration: 10, queue: false, easing: 'easeOutQuad'});
212
- }
213
- }
214
-
215
- }).bind('panend', function(e) {
216
-
217
- if (e.gesture.pointerType == "touch") {
218
- var $overlay = $('<div id="sidenav-overlay"></div>');
219
- var velocityX = e.gesture.velocityX;
220
- var x = e.gesture.center.x;
221
- var leftPos = x - options.menuWidth;
222
- var rightPos = x - options.menuWidth / 2;
223
- if (leftPos > 0 ) {
224
- leftPos = 0;
225
- }
226
- if (rightPos < 0) {
227
- rightPos = 0;
228
- }
229
- panning = false;
230
-
231
- if (options.edge === 'left') {
232
- // If velocityX <= 0.3 then the user is flinging the menu closed so ignore menuOut
233
- if ((menuOut && velocityX <= 0.3) || velocityX < -0.5) {
234
- // Return menu to open
235
- if (leftPos !== 0) {
236
- menu_id.velocity({'translateX': [0, leftPos]}, {duration: 300, queue: false, easing: 'easeOutQuad'});
237
- }
238
-
239
- $overlay.velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
240
- $dragTarget.css({width: '50%', right: 0, left: ''});
241
- menuOut = true;
242
- }
243
- else if (!menuOut || velocityX > 0.3) {
244
- // Enable Scrolling
245
- $('body').css({
246
- overflow: '',
247
- width: ''
248
- });
249
- // Slide menu closed
250
- menu_id.velocity({'translateX': [-1 * options.menuWidth - 10, leftPos]}, {duration: 200, queue: false, easing: 'easeOutQuad'});
251
- $overlay.velocity({opacity: 0 }, {duration: 200, queue: false, easing: 'easeOutQuad',
252
- complete: function () {
253
- $(this).remove();
254
- }});
255
- $dragTarget.css({width: '10px', right: '', left: 0});
256
- }
257
- }
258
- else {
259
- if ((menuOut && velocityX >= -0.3) || velocityX > 0.5) {
260
- // Return menu to open
261
- if (rightPos !== 0) {
262
- menu_id.velocity({'translateX': [0, rightPos]}, {duration: 300, queue: false, easing: 'easeOutQuad'});
263
- }
264
-
265
- $overlay.velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
266
- $dragTarget.css({width: '50%', right: '', left: 0});
267
- menuOut = true;
268
- }
269
- else if (!menuOut || velocityX < -0.3) {
270
- // Enable Scrolling
271
- $('body').css({
272
- overflow: '',
273
- width: ''
274
- });
275
-
276
- // Slide menu closed
277
- menu_id.velocity({'translateX': [options.menuWidth + 10, rightPos]}, {duration: 200, queue: false, easing: 'easeOutQuad'});
278
- $overlay.velocity({opacity: 0 }, {duration: 200, queue: false, easing: 'easeOutQuad',
279
- complete: function () {
280
- $(this).remove();
281
- }});
282
- $dragTarget.css({width: '10px', right: 0, left: ''});
283
- }
284
- }
285
-
286
- }
287
- });
288
- }
289
-
290
- $this.click(function() {
291
- if (menuOut === true) {
292
- menuOut = false;
293
- panning = false;
294
- removeMenu();
295
- }
296
- else {
297
-
298
- // Disable Scrolling
299
- var $body = $('body');
300
- var $overlay = $('<div id="sidenav-overlay"></div>');
301
- var oldWidth = $body.innerWidth();
302
- $body.css('overflow', 'hidden');
303
- $body.width(oldWidth);
304
-
305
- // Push current drag target on top of DOM tree
306
- $('body').append($dragTarget);
307
-
308
- if (options.edge === 'left') {
309
- $dragTarget.css({width: '50%', right: 0, left: ''});
310
- menu_id.velocity({'translateX': [0, -1 * options.menuWidth]}, {duration: 300, queue: false, easing: 'easeOutQuad'});
311
- }
312
- else {
313
- $dragTarget.css({width: '50%', right: '', left: 0});
314
- menu_id.velocity({'translateX': [0, options.menuWidth]}, {duration: 300, queue: false, easing: 'easeOutQuad'});
315
- }
316
-
317
- $overlay.css('opacity', 0)
318
- .click(function(){
319
- menuOut = false;
320
- panning = false;
321
- removeMenu();
322
- $overlay.velocity({opacity: 0}, {duration: 300, queue: false, easing: 'easeOutQuad',
323
- complete: function() {
324
- $(this).remove();
325
- } });
326
-
327
- });
328
- $('body').append($overlay);
329
- $overlay.velocity({opacity: 1}, {duration: 300, queue: false, easing: 'easeOutQuad',
330
- complete: function () {
331
- menuOut = true;
332
- panning = false;
333
- }
334
- });
335
- }
336
-
337
- return false;
338
- });
339
- });
340
-
341
-
342
- },
343
- destroy: function () {
344
- var $overlay = $('#sidenav-overlay');
345
- var $dragTarget = $('.drag-target[data-sidenav="' + $(this).attr('data-activates') + '"]');
346
- $overlay.trigger('click');
347
- $dragTarget.remove();
348
- $(this).off('click');
349
- $overlay.remove();
350
- },
351
- show : function() {
352
- this.trigger('click');
353
- },
354
- hide : function() {
355
- $('#sidenav-overlay').trigger('click');
356
- }
357
- };
358
-
359
-
360
- $.fn.sideNav = function(methodOrOptions) {
361
- if ( methods[methodOrOptions] ) {
362
- return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
363
- } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
364
- // Default to "init"
365
- return methods.init.apply( this, arguments );
366
- } else {
367
- $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.sideNav' );
368
- }
369
- }; // Plugin end
370
- }( jQuery ));