mtl 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/Gemfile +9 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +104 -0
  6. data/Rakefile +6 -0
  7. data/app/assets/javascripts/mtl/clickables.coffee +25 -0
  8. data/app/assets/javascripts/mtl/collapsible.coffee +43 -0
  9. data/app/assets/javascripts/mtl/configuration.coffee.erb +1 -0
  10. data/app/assets/javascripts/mtl/document_modal.coffee +130 -0
  11. data/app/assets/javascripts/mtl/dropdown.coffee +24 -0
  12. data/app/assets/javascripts/mtl/hooks.coffee +14 -0
  13. data/app/assets/javascripts/mtl/icon.coffee.erb +17 -0
  14. data/app/assets/javascripts/mtl/modal.coffee +32 -0
  15. data/app/assets/javascripts/mtl/select.coffee +44 -0
  16. data/app/assets/javascripts/mtl/templates.coffee +4 -0
  17. data/app/assets/javascripts/mtl/toc.coffee +31 -0
  18. data/app/assets/javascripts/mtl.js +42 -0
  19. data/app/assets/stylesheets/mtl/all.scss +69 -0
  20. data/app/assets/stylesheets/mtl/extend/_avatars.scss +37 -0
  21. data/app/assets/stylesheets/mtl/extend/_buttons.scss +31 -0
  22. data/app/assets/stylesheets/mtl/extend/_cards.scss +21 -0
  23. data/app/assets/stylesheets/mtl/extend/_chips.scss +3 -0
  24. data/app/assets/stylesheets/mtl/extend/_collection-files.scss +108 -0
  25. data/app/assets/stylesheets/mtl/extend/_document-modals.scss +95 -0
  26. data/app/assets/stylesheets/mtl/extend/_dropdown.scss +12 -0
  27. data/app/assets/stylesheets/mtl/extend/_forms.scss +66 -0
  28. data/app/assets/stylesheets/mtl/extend/_global.scss +77 -0
  29. data/app/assets/stylesheets/mtl/extend/_grid.scss +25 -0
  30. data/app/assets/stylesheets/mtl/extend/_material-icons.scss +37 -0
  31. data/app/assets/stylesheets/mtl/extend/_mixins.scss +10 -0
  32. data/app/assets/stylesheets/mtl/extend/_roboto-rails.scss +49 -0
  33. data/app/assets/stylesheets/mtl/extend/_side-nav.scss +22 -0
  34. data/app/assets/stylesheets/mtl/extend/_toc.scss +12 -0
  35. data/app/assets/stylesheets/mtl/extend/_typography.scss +32 -0
  36. data/app/assets/stylesheets/mtl/extend/forms/_input-fields.scss +50 -0
  37. data/app/assets/stylesheets/mtl/layouts/_default.scss +220 -0
  38. data/app/assets/stylesheets/mtl/layouts/_single.scss +25 -0
  39. data/app/views/mtl/header.html.erb +25 -0
  40. data/bin/coffeelint.rb +16 -0
  41. data/lib/generators/mtl/install_generator.rb +20 -0
  42. data/lib/generators/mtl/templates/_color.scss +410 -0
  43. data/lib/generators/mtl/templates/_variables.scss +330 -0
  44. data/lib/generators/mtl/templates/mtl.scss +8 -0
  45. data/lib/generators/mtl/templates/simple_form.rb +211 -0
  46. data/lib/mtl/rails/card_file_presenter.rb +70 -0
  47. data/lib/mtl/rails/view_helpers.rb +412 -0
  48. data/lib/mtl/simple_form/suffix.rb +52 -0
  49. data/lib/mtl/version.rb +6 -0
  50. data/lib/mtl.rb +38 -0
  51. data/mtl.gemspec +35 -0
  52. data/package.json +11 -0
  53. data/spec/mtl/rails/card_file_presenter_spec.rb +126 -0
  54. data/spec/mtl/rails/view_helpers_spec.rb +193 -0
  55. data/spec/mtl/simple_form/suffix_spec.rb +39 -0
  56. data/spec/mtl_spec.rb +34 -0
  57. data/spec/spec_helper.rb +18 -0
  58. data/spec/support/dom.rb +15 -0
  59. data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.eot +0 -0
  60. data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.ijmap +1 -0
  61. data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.svg +2373 -0
  62. data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.ttf +0 -0
  63. data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.woff +0 -0
  64. data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.woff2 +0 -0
  65. data/vendor/assets/fonts/roboto/Roboto-Bold.eot +0 -0
  66. data/vendor/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
  67. data/vendor/assets/fonts/roboto/Roboto-Bold.woff +0 -0
  68. data/vendor/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
  69. data/vendor/assets/fonts/roboto/Roboto-Light.eot +0 -0
  70. data/vendor/assets/fonts/roboto/Roboto-Light.ttf +0 -0
  71. data/vendor/assets/fonts/roboto/Roboto-Light.woff +0 -0
  72. data/vendor/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
  73. data/vendor/assets/fonts/roboto/Roboto-Medium.eot +0 -0
  74. data/vendor/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
  75. data/vendor/assets/fonts/roboto/Roboto-Medium.woff +0 -0
  76. data/vendor/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
  77. data/vendor/assets/fonts/roboto/Roboto-Regular.eot +0 -0
  78. data/vendor/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
  79. data/vendor/assets/fonts/roboto/Roboto-Regular.woff +0 -0
  80. data/vendor/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
  81. data/vendor/assets/fonts/roboto/Roboto-Thin.eot +0 -0
  82. data/vendor/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
  83. data/vendor/assets/fonts/roboto/Roboto-Thin.woff +0 -0
  84. data/vendor/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
  85. data/vendor/assets/javascripts/lodash.js +16607 -0
  86. data/vendor/assets/javascripts/materialize/animation.js +9 -0
  87. data/vendor/assets/javascripts/materialize/buttons.js +91 -0
  88. data/vendor/assets/javascripts/materialize/cards.js +26 -0
  89. data/vendor/assets/javascripts/materialize/carousel.js +454 -0
  90. data/vendor/assets/javascripts/materialize/character_counter.js +72 -0
  91. data/vendor/assets/javascripts/materialize/chips.js +267 -0
  92. data/vendor/assets/javascripts/materialize/collapsible.js +160 -0
  93. data/vendor/assets/javascripts/materialize/date_picker/picker.date.js +1430 -0
  94. data/vendor/assets/javascripts/materialize/date_picker/picker.js +1123 -0
  95. data/vendor/assets/javascripts/materialize/dropdown.js +265 -0
  96. data/vendor/assets/javascripts/materialize/forms.js +681 -0
  97. data/vendor/assets/javascripts/materialize/global.js +45 -0
  98. data/vendor/assets/javascripts/materialize/hammer.min.js +1 -0
  99. data/vendor/assets/javascripts/materialize/init.js +173 -0
  100. data/vendor/assets/javascripts/materialize/initial.js +11 -0
  101. data/vendor/assets/javascripts/materialize/jquery.easing.1.3.js +205 -0
  102. data/vendor/assets/javascripts/materialize/jquery.hammer.js +33 -0
  103. data/vendor/assets/javascripts/materialize/jquery.timeago.min.js +1 -0
  104. data/vendor/assets/javascripts/materialize/leanModal.js +192 -0
  105. data/vendor/assets/javascripts/materialize/materialbox.js +269 -0
  106. data/vendor/assets/javascripts/materialize/parallax.js +58 -0
  107. data/vendor/assets/javascripts/materialize/prism.js +8 -0
  108. data/vendor/assets/javascripts/materialize/pushpin.js +71 -0
  109. data/vendor/assets/javascripts/materialize/scrollFire.js +48 -0
  110. data/vendor/assets/javascripts/materialize/scrollspy.js +283 -0
  111. data/vendor/assets/javascripts/materialize/sideNav.js +352 -0
  112. data/vendor/assets/javascripts/materialize/slider.js +321 -0
  113. data/vendor/assets/javascripts/materialize/tabs.js +148 -0
  114. data/vendor/assets/javascripts/materialize/toasts.js +136 -0
  115. data/vendor/assets/javascripts/materialize/tooltip.js +230 -0
  116. data/vendor/assets/javascripts/materialize/transitions.js +169 -0
  117. data/vendor/assets/javascripts/materialize/velocity.min.js +5 -0
  118. data/vendor/assets/javascripts/materialize/waves.js +338 -0
  119. data/vendor/assets/javascripts/pdfobject.js +254 -0
  120. data/vendor/assets/stylesheets/materialize/_buttons.scss +211 -0
  121. data/vendor/assets/stylesheets/materialize/_cards.scss +185 -0
  122. data/vendor/assets/stylesheets/materialize/_carousel.scss +85 -0
  123. data/vendor/assets/stylesheets/materialize/_chips.scss +74 -0
  124. data/vendor/assets/stylesheets/materialize/_collapsible.scss +90 -0
  125. data/vendor/assets/stylesheets/materialize/_color.scss +412 -0
  126. data/vendor/assets/stylesheets/materialize/_dropdown.scss +57 -0
  127. data/vendor/assets/stylesheets/materialize/_global.scss +781 -0
  128. data/vendor/assets/stylesheets/materialize/_grid.scss +147 -0
  129. data/vendor/assets/stylesheets/materialize/_icons-material-design.scss +5 -0
  130. data/vendor/assets/stylesheets/materialize/_materialbox.scss +42 -0
  131. data/vendor/assets/stylesheets/materialize/_mixins.scss +5 -0
  132. data/vendor/assets/stylesheets/materialize/_modal.scss +90 -0
  133. data/vendor/assets/stylesheets/materialize/_navbar.scss +182 -0
  134. data/vendor/assets/stylesheets/materialize/_normalize.scss +424 -0
  135. data/vendor/assets/stylesheets/materialize/_prefixer.scss +384 -0
  136. data/vendor/assets/stylesheets/materialize/_preloader.scss +334 -0
  137. data/vendor/assets/stylesheets/materialize/_roboto.scss +49 -0
  138. data/vendor/assets/stylesheets/materialize/_sideNav.scss +219 -0
  139. data/vendor/assets/stylesheets/materialize/_slider.scss +92 -0
  140. data/vendor/assets/stylesheets/materialize/_table_of_contents.scss +33 -0
  141. data/vendor/assets/stylesheets/materialize/_tabs.scss +56 -0
  142. data/vendor/assets/stylesheets/materialize/_toast.scss +65 -0
  143. data/vendor/assets/stylesheets/materialize/_tooltip.scss +32 -0
  144. data/vendor/assets/stylesheets/materialize/_typography.scss +61 -0
  145. data/vendor/assets/stylesheets/materialize/_variables.scss +313 -0
  146. data/vendor/assets/stylesheets/materialize/_waves.scss +177 -0
  147. data/vendor/assets/stylesheets/materialize/date_picker/_default.date.scss +435 -0
  148. data/vendor/assets/stylesheets/materialize/date_picker/_default.scss +201 -0
  149. data/vendor/assets/stylesheets/materialize/date_picker/_default.time.scss +125 -0
  150. data/vendor/assets/stylesheets/materialize/forms/_checkboxes.scss +220 -0
  151. data/vendor/assets/stylesheets/materialize/forms/_file-input.scss +38 -0
  152. data/vendor/assets/stylesheets/materialize/forms/_forms.scss +22 -0
  153. data/vendor/assets/stylesheets/materialize/forms/_input-fields.scss +273 -0
  154. data/vendor/assets/stylesheets/materialize/forms/_radio-buttons.scss +119 -0
  155. data/vendor/assets/stylesheets/materialize/forms/_range.scss +159 -0
  156. data/vendor/assets/stylesheets/materialize/forms/_select.scss +116 -0
  157. data/vendor/assets/stylesheets/materialize/forms/_switches.scss +78 -0
  158. metadata +309 -0
@@ -0,0 +1,321 @@
1
+ (function ($) {
2
+
3
+ var methods = {
4
+
5
+ init : function(options) {
6
+ var defaults = {
7
+ indicators: true,
8
+ height: 400,
9
+ transition: 500,
10
+ interval: 6000
11
+ };
12
+ options = $.extend(defaults, options);
13
+
14
+ return this.each(function() {
15
+
16
+ // For each slider, we want to keep track of
17
+ // which slide is active and its associated content
18
+ var $this = $(this);
19
+ var $slider = $this.find('ul.slides').first();
20
+ var $slides = $slider.find('> li');
21
+ var $active_index = $slider.find('.active').index();
22
+ var $active, $indicators, $interval;
23
+ if ($active_index != -1) { $active = $slides.eq($active_index); }
24
+
25
+ // Transitions the caption depending on alignment
26
+ function captionTransition(caption, duration) {
27
+ if (caption.hasClass("center-align")) {
28
+ caption.velocity({opacity: 0, translateY: -100}, {duration: duration, queue: false});
29
+ }
30
+ else if (caption.hasClass("right-align")) {
31
+ caption.velocity({opacity: 0, translateX: 100}, {duration: duration, queue: false});
32
+ }
33
+ else if (caption.hasClass("left-align")) {
34
+ caption.velocity({opacity: 0, translateX: -100}, {duration: duration, queue: false});
35
+ }
36
+ }
37
+
38
+ // This function will transition the slide to any index of the next slide
39
+ function moveToSlide(index) {
40
+ // Wrap around indices.
41
+ if (index >= $slides.length) index = 0;
42
+ else if (index < 0) index = $slides.length -1;
43
+
44
+ $active_index = $slider.find('.active').index();
45
+
46
+ // Only do if index changes
47
+ if ($active_index != index) {
48
+ $active = $slides.eq($active_index);
49
+ $caption = $active.find('.caption');
50
+
51
+ $active.removeClass('active');
52
+ $active.velocity({opacity: 0}, {duration: options.transition, queue: false, easing: 'easeOutQuad',
53
+ complete: function() {
54
+ $slides.not('.active').velocity({opacity: 0, translateX: 0, translateY: 0}, {duration: 0, queue: false});
55
+ } });
56
+ captionTransition($caption, options.transition);
57
+
58
+
59
+ // Update indicators
60
+ if (options.indicators) {
61
+ $indicators.eq($active_index).removeClass('active');
62
+ }
63
+
64
+ $slides.eq(index).velocity({opacity: 1}, {duration: options.transition, queue: false, easing: 'easeOutQuad'});
65
+ $slides.eq(index).find('.caption').velocity({opacity: 1, translateX: 0, translateY: 0}, {duration: options.transition, delay: options.transition, queue: false, easing: 'easeOutQuad'});
66
+ $slides.eq(index).addClass('active');
67
+
68
+
69
+ // Update indicators
70
+ if (options.indicators) {
71
+ $indicators.eq(index).addClass('active');
72
+ }
73
+ }
74
+ }
75
+
76
+ // Set height of slider
77
+ // If fullscreen, do nothing
78
+ if (!$this.hasClass('fullscreen')) {
79
+ if (options.indicators) {
80
+ // Add height if indicators are present
81
+ $this.height(options.height + 40);
82
+ }
83
+ else {
84
+ $this.height(options.height);
85
+ }
86
+ $slider.height(options.height);
87
+ }
88
+
89
+
90
+ // Set initial positions of captions
91
+ $slides.find('.caption').each(function () {
92
+ captionTransition($(this), 0);
93
+ });
94
+
95
+ // Move img src into background-image
96
+ $slides.find('img').each(function () {
97
+ var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
98
+ if ($(this).attr('src') !== placeholderBase64) {
99
+ $(this).css('background-image', 'url(' + $(this).attr('src') + ')' );
100
+ $(this).attr('src', placeholderBase64);
101
+ }
102
+ });
103
+
104
+ // dynamically add indicators
105
+ if (options.indicators) {
106
+ $indicators = $('<ul class="indicators"></ul>');
107
+ $slides.each(function( index ) {
108
+ var $indicator = $('<li class="indicator-item"></li>');
109
+
110
+ // Handle clicks on indicators
111
+ $indicator.click(function () {
112
+ var $parent = $slider.parent();
113
+ var curr_index = $parent.find($(this)).index();
114
+ moveToSlide(curr_index);
115
+
116
+ // reset interval
117
+ clearInterval($interval);
118
+ $interval = setInterval(
119
+ function(){
120
+ $active_index = $slider.find('.active').index();
121
+ if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
122
+ else $active_index += 1;
123
+
124
+ moveToSlide($active_index);
125
+
126
+ }, options.transition + options.interval
127
+ );
128
+ });
129
+ $indicators.append($indicator);
130
+ });
131
+ $this.append($indicators);
132
+ $indicators = $this.find('ul.indicators').find('li.indicator-item');
133
+ }
134
+
135
+ if ($active) {
136
+ $active.show();
137
+ }
138
+ else {
139
+ $slides.first().addClass('active').velocity({opacity: 1}, {duration: options.transition, queue: false, easing: 'easeOutQuad'});
140
+
141
+ $active_index = 0;
142
+ $active = $slides.eq($active_index);
143
+
144
+ // Update indicators
145
+ if (options.indicators) {
146
+ $indicators.eq($active_index).addClass('active');
147
+ }
148
+ }
149
+
150
+ // Adjust height to current slide
151
+ $active.find('img').each(function() {
152
+ $active.find('.caption').velocity({opacity: 1, translateX: 0, translateY: 0}, {duration: options.transition, queue: false, easing: 'easeOutQuad'});
153
+ });
154
+
155
+ // auto scroll
156
+ $interval = setInterval(
157
+ function(){
158
+ $active_index = $slider.find('.active').index();
159
+ moveToSlide($active_index + 1);
160
+
161
+ }, options.transition + options.interval
162
+ );
163
+
164
+
165
+ // HammerJS, Swipe navigation
166
+
167
+ // Touch Event
168
+ var panning = false;
169
+ var swipeLeft = false;
170
+ var swipeRight = false;
171
+
172
+ $this.hammer({
173
+ prevent_default: false
174
+ }).bind('pan', function(e) {
175
+ if (e.gesture.pointerType === "touch") {
176
+
177
+ // reset interval
178
+ clearInterval($interval);
179
+
180
+ var direction = e.gesture.direction;
181
+ var x = e.gesture.deltaX;
182
+ var velocityX = e.gesture.velocityX;
183
+
184
+ $curr_slide = $slider.find('.active');
185
+ $curr_slide.velocity({ translateX: x
186
+ }, {duration: 50, queue: false, easing: 'easeOutQuad'});
187
+
188
+ // Swipe Left
189
+ if (direction === 4 && (x > ($this.innerWidth() / 2) || velocityX < -0.65)) {
190
+ swipeRight = true;
191
+ }
192
+ // Swipe Right
193
+ else if (direction === 2 && (x < (-1 * $this.innerWidth() / 2) || velocityX > 0.65)) {
194
+ swipeLeft = true;
195
+ }
196
+
197
+ // Make Slide Behind active slide visible
198
+ var next_slide;
199
+ if (swipeLeft) {
200
+ next_slide = $curr_slide.next();
201
+ if (next_slide.length === 0) {
202
+ next_slide = $slides.first();
203
+ }
204
+ next_slide.velocity({ opacity: 1
205
+ }, {duration: 300, queue: false, easing: 'easeOutQuad'});
206
+ }
207
+ if (swipeRight) {
208
+ next_slide = $curr_slide.prev();
209
+ if (next_slide.length === 0) {
210
+ next_slide = $slides.last();
211
+ }
212
+ next_slide.velocity({ opacity: 1
213
+ }, {duration: 300, queue: false, easing: 'easeOutQuad'});
214
+ }
215
+
216
+
217
+ }
218
+
219
+ }).bind('panend', function(e) {
220
+ if (e.gesture.pointerType === "touch") {
221
+
222
+ $curr_slide = $slider.find('.active');
223
+ panning = false;
224
+ curr_index = $slider.find('.active').index();
225
+
226
+ if (!swipeRight && !swipeLeft || $slides.length <=1) {
227
+ // Return to original spot
228
+ $curr_slide.velocity({ translateX: 0
229
+ }, {duration: 300, queue: false, easing: 'easeOutQuad'});
230
+ }
231
+ else if (swipeLeft) {
232
+ moveToSlide(curr_index + 1);
233
+ $curr_slide.velocity({translateX: -1 * $this.innerWidth() }, {duration: 300, queue: false, easing: 'easeOutQuad',
234
+ complete: function() {
235
+ $curr_slide.velocity({opacity: 0, translateX: 0}, {duration: 0, queue: false});
236
+ } });
237
+ }
238
+ else if (swipeRight) {
239
+ moveToSlide(curr_index - 1);
240
+ $curr_slide.velocity({translateX: $this.innerWidth() }, {duration: 300, queue: false, easing: 'easeOutQuad',
241
+ complete: function() {
242
+ $curr_slide.velocity({opacity: 0, translateX: 0}, {duration: 0, queue: false});
243
+ } });
244
+ }
245
+ swipeLeft = false;
246
+ swipeRight = false;
247
+
248
+ // Restart interval
249
+ clearInterval($interval);
250
+ $interval = setInterval(
251
+ function(){
252
+ $active_index = $slider.find('.active').index();
253
+ if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
254
+ else $active_index += 1;
255
+
256
+ moveToSlide($active_index);
257
+
258
+ }, options.transition + options.interval
259
+ );
260
+ }
261
+ });
262
+
263
+ $this.on('sliderPause', function() {
264
+ clearInterval($interval);
265
+ });
266
+
267
+ $this.on('sliderStart', function() {
268
+ clearInterval($interval);
269
+ $interval = setInterval(
270
+ function(){
271
+ $active_index = $slider.find('.active').index();
272
+ if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
273
+ else $active_index += 1;
274
+
275
+ moveToSlide($active_index);
276
+
277
+ }, options.transition + options.interval
278
+ );
279
+ });
280
+
281
+ $this.on('sliderNext', function() {
282
+ $active_index = $slider.find('.active').index();
283
+ moveToSlide($active_index + 1);
284
+ });
285
+
286
+ $this.on('sliderPrev', function() {
287
+ $active_index = $slider.find('.active').index();
288
+ moveToSlide($active_index - 1);
289
+ });
290
+
291
+ });
292
+
293
+
294
+
295
+ },
296
+ pause : function() {
297
+ $(this).trigger('sliderPause');
298
+ },
299
+ start : function() {
300
+ $(this).trigger('sliderStart');
301
+ },
302
+ next : function() {
303
+ $(this).trigger('sliderNext');
304
+ },
305
+ prev : function() {
306
+ $(this).trigger('sliderPrev');
307
+ }
308
+ };
309
+
310
+
311
+ $.fn.slider = function(methodOrOptions) {
312
+ if ( methods[methodOrOptions] ) {
313
+ return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
314
+ } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
315
+ // Default to "init"
316
+ return methods.init.apply( this, arguments );
317
+ } else {
318
+ $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.tooltip' );
319
+ }
320
+ }; // Plugin end
321
+ }( jQuery ));
@@ -0,0 +1,148 @@
1
+ (function ($) {
2
+
3
+ var methods = {
4
+ init : function(options) {
5
+ var defaults = {
6
+ onShow: null
7
+ };
8
+ options = $.extend(defaults, options);
9
+
10
+ return this.each(function() {
11
+
12
+ // For each set of tabs, we want to keep track of
13
+ // which tab is active and its associated content
14
+ var $this = $(this),
15
+ window_width = $(window).width();
16
+
17
+ $this.width('100%');
18
+ var $active, $content, $links = $this.find('li.tab a'),
19
+ $tabs_width = $this.width(),
20
+ $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length,
21
+ $index = 0;
22
+
23
+ // If the location.hash matches one of the links, use that as the active tab.
24
+ $active = $($links.filter('[href="'+location.hash+'"]'));
25
+
26
+ // If no match is found, use the first link or any with class 'active' as the initial active tab.
27
+ if ($active.length === 0) {
28
+ $active = $(this).find('li.tab a.active').first();
29
+ }
30
+ if ($active.length === 0) {
31
+ $active = $(this).find('li.tab a').first();
32
+ }
33
+
34
+ $active.addClass('active');
35
+ $index = $links.index($active);
36
+ if ($index < 0) {
37
+ $index = 0;
38
+ }
39
+
40
+ if ($active[0] !== undefined) {
41
+ $content = $($active[0].hash);
42
+ }
43
+
44
+ // append indicator then set indicator width to tab width
45
+ $this.append('<div class="indicator"></div>');
46
+ var $indicator = $this.find('.indicator');
47
+ if ($this.is(":visible")) {
48
+ $indicator.css({"right": $tabs_width - (($index + 1) * $tab_width)});
49
+ $indicator.css({"left": $index * $tab_width});
50
+ }
51
+ $(window).resize(function () {
52
+ $tabs_width = $this.width();
53
+ $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length;
54
+ if ($index < 0) {
55
+ $index = 0;
56
+ }
57
+ if ($tab_width !== 0 && $tabs_width !== 0) {
58
+ $indicator.css({"right": $tabs_width - (($index + 1) * $tab_width)});
59
+ $indicator.css({"left": $index * $tab_width});
60
+ }
61
+ });
62
+
63
+ // Hide the remaining content
64
+ $links.not($active).each(function () {
65
+ $(this.hash).hide();
66
+ });
67
+
68
+
69
+ // Bind the click event handler
70
+ $this.on('click', 'a', function(e) {
71
+ if ($(this).parent().hasClass('disabled')) {
72
+ e.preventDefault();
73
+ return;
74
+ }
75
+
76
+ // Act as regular link if target attribute is specified.
77
+ if (!!$(this).attr("target")) {
78
+ return;
79
+ }
80
+
81
+ $tabs_width = $this.width();
82
+ $tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length;
83
+
84
+ // Make the old tab inactive.
85
+ $active.removeClass('active');
86
+ if ($content !== undefined) {
87
+ $content.hide();
88
+ }
89
+
90
+ // Update the variables with the new link and content
91
+ $active = $(this);
92
+ $content = $(this.hash);
93
+ $links = $this.find('li.tab a');
94
+
95
+ // Make the tab active.
96
+ $active.addClass('active');
97
+ var $prev_index = $index;
98
+ $index = $links.index($(this));
99
+ if ($index < 0) {
100
+ $index = 0;
101
+ }
102
+ // Change url to current tab
103
+ // window.location.hash = $active.attr('href');
104
+
105
+ if ($content !== undefined) {
106
+ $content.show();
107
+ if (typeof(options.onShow) === "function") {
108
+ options.onShow.call(this, $content);
109
+ }
110
+ }
111
+
112
+ // Update indicator
113
+ if (($index - $prev_index) >= 0) {
114
+ $indicator.velocity({"right": $tabs_width - (($index + 1) * $tab_width)}, { duration: 300, queue: false, easing: 'easeOutQuad'});
115
+ $indicator.velocity({"left": $index * $tab_width}, {duration: 300, queue: false, easing: 'easeOutQuad', delay: 90});
116
+
117
+ }
118
+ else {
119
+ $indicator.velocity({"left": $index * $tab_width}, { duration: 300, queue: false, easing: 'easeOutQuad'});
120
+ $indicator.velocity({"right": $tabs_width - (($index + 1) * $tab_width)}, {duration: 300, queue: false, easing: 'easeOutQuad', delay: 90});
121
+ }
122
+
123
+ // Prevent the anchor's default click action
124
+ e.preventDefault();
125
+ });
126
+ });
127
+
128
+ },
129
+ select_tab : function( id ) {
130
+ this.find('a[href="#' + id + '"]').trigger('click');
131
+ }
132
+ };
133
+
134
+ $.fn.tabs = function(methodOrOptions) {
135
+ if ( methods[methodOrOptions] ) {
136
+ return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
137
+ } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
138
+ // Default to "init"
139
+ return methods.init.apply( this, arguments );
140
+ } else {
141
+ $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.tooltip' );
142
+ }
143
+ };
144
+
145
+ $(document).ready(function(){
146
+ $('ul.tabs').tabs();
147
+ });
148
+ }( jQuery ));
@@ -0,0 +1,136 @@
1
+ Materialize.toast = function (message, displayLength, className, completeCallback) {
2
+ className = className || "";
3
+
4
+ var container = document.getElementById('toast-container');
5
+
6
+ // Create toast container if it does not exist
7
+ if (container === null) {
8
+ // create notification container
9
+ container = document.createElement('div');
10
+ container.id = 'toast-container';
11
+ document.body.appendChild(container);
12
+ }
13
+
14
+ // Select and append toast
15
+ var newToast = createToast(message);
16
+
17
+ // only append toast if message is not undefined
18
+ if(message){
19
+ container.appendChild(newToast);
20
+ }
21
+
22
+ newToast.style.top = '35px';
23
+ newToast.style.opacity = 0;
24
+
25
+ // Animate toast in
26
+ Vel(newToast, { "top" : "0px", opacity: 1 }, {duration: 300,
27
+ easing: 'easeOutCubic',
28
+ queue: false});
29
+
30
+ // Allows timer to be pause while being panned
31
+ var timeLeft = displayLength;
32
+ var counterInterval = setInterval (function(){
33
+
34
+
35
+ if (newToast.parentNode === null)
36
+ window.clearInterval(counterInterval);
37
+
38
+ // If toast is not being dragged, decrease its time remaining
39
+ if (!newToast.classList.contains('panning')) {
40
+ timeLeft -= 20;
41
+ }
42
+
43
+ if (timeLeft <= 0) {
44
+ // Animate toast out
45
+ Vel(newToast, {"opacity": 0, marginTop: '-40px'}, { duration: 375,
46
+ easing: 'easeOutExpo',
47
+ queue: false,
48
+ complete: function(){
49
+ // Call the optional callback
50
+ if(typeof(completeCallback) === "function")
51
+ completeCallback();
52
+ // Remove toast after it times out
53
+ this[0].parentNode.removeChild(this[0]);
54
+ }
55
+ });
56
+ window.clearInterval(counterInterval);
57
+ }
58
+ }, 20);
59
+
60
+
61
+
62
+ function createToast(html) {
63
+
64
+ // Create toast
65
+ var toast = document.createElement('div');
66
+ toast.classList.add('toast');
67
+ if (className) {
68
+ var classes = className.split(' ');
69
+
70
+ for (var i = 0, count = classes.length; i < count; i++) {
71
+ toast.classList.add(classes[i]);
72
+ }
73
+ }
74
+ // If type of parameter is HTML Element
75
+ if ( typeof HTMLElement === "object" ? html instanceof HTMLElement : html && typeof html === "object" && html !== null && html.nodeType === 1 && typeof html.nodeName==="string"
76
+ ) {
77
+ toast.appendChild(html);
78
+ }
79
+ else if (html instanceof jQuery) {
80
+ // Check if it is jQuery object
81
+ toast.appendChild(html[0]);
82
+ }
83
+ else {
84
+ // Insert as text;
85
+ toast.innerHTML = html;
86
+ }
87
+ // Bind hammer
88
+ var hammerHandler = new Hammer(toast, {prevent_default: false});
89
+ hammerHandler.on('pan', function(e) {
90
+ var deltaX = e.deltaX;
91
+ var activationDistance = 80;
92
+
93
+ // Change toast state
94
+ if (!toast.classList.contains('panning')){
95
+ toast.classList.add('panning');
96
+ }
97
+
98
+ var opacityPercent = 1-Math.abs(deltaX / activationDistance);
99
+ if (opacityPercent < 0)
100
+ opacityPercent = 0;
101
+
102
+ Vel(toast, {left: deltaX, opacity: opacityPercent }, {duration: 50, queue: false, easing: 'easeOutQuad'});
103
+
104
+ });
105
+
106
+ hammerHandler.on('panend', function(e) {
107
+ var deltaX = e.deltaX;
108
+ var activationDistance = 80;
109
+
110
+ // If toast dragged past activation point
111
+ if (Math.abs(deltaX) > activationDistance) {
112
+ Vel(toast, {marginTop: '-40px'}, { duration: 375,
113
+ easing: 'easeOutExpo',
114
+ queue: false,
115
+ complete: function(){
116
+ if(typeof(completeCallback) === "function") {
117
+ completeCallback();
118
+ }
119
+ toast.parentNode.removeChild(toast);
120
+ }
121
+ });
122
+
123
+ } else {
124
+ toast.classList.remove('panning');
125
+ // Put toast back into original position
126
+ Vel(toast, { left: 0, opacity: 1 }, { duration: 300,
127
+ easing: 'easeOutExpo',
128
+ queue: false
129
+ });
130
+
131
+ }
132
+ });
133
+
134
+ return toast;
135
+ }
136
+ };