materialize-sass 0.100.2.1 → 1.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +18 -42
- data/Rakefile +17 -17
- data/{app/assets → assets}/javascripts/materialize-sprockets.js +8 -12
- data/assets/javascripts/materialize.js +11877 -0
- data/assets/javascripts/materialize/autocomplete.js +420 -0
- data/assets/javascripts/materialize/buttons.js +388 -0
- data/assets/javascripts/materialize/cards.js +28 -0
- data/assets/javascripts/materialize/carousel.js +791 -0
- data/assets/javascripts/materialize/cash.js +992 -0
- data/assets/javascripts/materialize/characterCounter.js +180 -0
- data/assets/javascripts/materialize/chips.js +555 -0
- data/assets/javascripts/materialize/collapsible.js +275 -0
- data/assets/javascripts/materialize/datepicker.js +898 -0
- data/assets/javascripts/materialize/dropdown.js +530 -0
- data/{app/assets → assets}/javascripts/materialize/extras/nouislider.js +1 -1
- data/{app/assets → assets}/javascripts/materialize/extras/nouislider.min.js +1 -1
- data/assets/javascripts/materialize/forms.js +223 -0
- data/assets/javascripts/materialize/global.js +353 -0
- data/assets/javascripts/materialize/materialbox.js +432 -0
- data/{app/assets → assets}/javascripts/materialize/modal.js +82 -113
- data/assets/javascripts/materialize/parallax.js +135 -0
- data/assets/javascripts/materialize/pushpin.js +158 -0
- data/assets/javascripts/materialize/range.js +305 -0
- data/assets/javascripts/materialize/scrollspy.js +322 -0
- data/assets/javascripts/materialize/select.js +426 -0
- data/assets/javascripts/materialize/sidenav.js +584 -0
- data/assets/javascripts/materialize/slider.js +383 -0
- data/assets/javascripts/materialize/tabs.js +460 -0
- data/assets/javascripts/materialize/tapTarget.js +347 -0
- data/assets/javascripts/materialize/timepicker.js +616 -0
- data/{app/assets → assets}/javascripts/materialize/toasts.js +42 -46
- data/assets/javascripts/materialize/tooltip.js +325 -0
- data/assets/javascripts/materialize/velocity.min.js +782 -0
- data/{app/assets → assets}/javascripts/materialize/waves.js +0 -0
- data/{app/assets → assets}/stylesheets/materialize.scss +5 -6
- data/{app/assets → assets}/stylesheets/materialize/components/_badges.scss +1 -1
- data/{app/assets → assets}/stylesheets/materialize/components/_buttons.scss +34 -2
- data/{app/assets → assets}/stylesheets/materialize/components/_cards.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_carousel.scss +1 -1
- data/{app/assets → assets}/stylesheets/materialize/components/_chips.scss +6 -5
- data/{app/assets → assets}/stylesheets/materialize/components/_collapsible.scss +3 -3
- data/{app/assets → assets}/stylesheets/materialize/components/_color.scss +0 -0
- data/assets/stylesheets/materialize/components/_datepicker.scss +180 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_dropdown.scss +16 -15
- data/{app/assets → assets}/stylesheets/materialize/components/_global.scss +49 -14
- data/{app/assets → assets}/stylesheets/materialize/components/_grid.scss +1 -1
- data/{app/assets → assets}/stylesheets/materialize/components/_icons-material-design.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_materialbox.scss +0 -0
- data/assets/stylesheets/materialize/components/_mixins.scss +5 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_modal.scss +1 -1
- data/{app/assets → assets}/stylesheets/materialize/components/_navbar.scss +0 -0
- data/assets/stylesheets/materialize/components/_normalize.scss +447 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_preloader.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_pulse.scss +0 -0
- data/{app/assets/stylesheets/materialize/components/_sideNav.scss → assets/stylesheets/materialize/components/_sidenav.scss} +23 -21
- data/{app/assets → assets}/stylesheets/materialize/components/_slider.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_table_of_contents.scss +3 -3
- data/{app/assets → assets}/stylesheets/materialize/components/_tabs.scss +2 -2
- data/{app/assets → assets}/stylesheets/materialize/components/_tapTarget.scss +0 -0
- data/assets/stylesheets/materialize/components/_timepicker.scss +182 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_toast.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_tooltip.scss +1 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_transitions.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_typography.scss +8 -8
- data/{app/assets → assets}/stylesheets/materialize/components/_variables.scss +42 -44
- data/{app/assets → assets}/stylesheets/materialize/components/_waves.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_checkboxes.scss +24 -24
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_file-input.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_forms.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_input-fields.scss +49 -35
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_radio-buttons.scss +29 -29
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_range.scss +32 -31
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_select.scss +20 -11
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_switches.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/extras/nouislider.css +1 -1
- data/lib/materialize-sass.rb +13 -23
- data/lib/materialize-sass/engine.rb +6 -9
- data/lib/materialize-sass/version.rb +1 -1
- data/materialize-sass.gemspec +2 -1
- metadata +97 -97
- 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.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Light.woff2 +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.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Regular.woff2 +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.js +0 -10021
- data/app/assets/javascripts/materialize/animation.js +0 -7
- data/app/assets/javascripts/materialize/buttons.js +0 -253
- data/app/assets/javascripts/materialize/cards.js +0 -28
- data/app/assets/javascripts/materialize/carousel.js +0 -543
- data/app/assets/javascripts/materialize/character_counter.js +0 -64
- data/app/assets/javascripts/materialize/chips.js +0 -315
- data/app/assets/javascripts/materialize/collapsible.js +0 -178
- data/app/assets/javascripts/materialize/date_picker/picker.date.js +0 -1399
- data/app/assets/javascripts/materialize/date_picker/picker.js +0 -1196
- data/app/assets/javascripts/materialize/date_picker/picker.time.js +0 -646
- data/app/assets/javascripts/materialize/dropdown.js +0 -257
- data/app/assets/javascripts/materialize/forms.js +0 -806
- data/app/assets/javascripts/materialize/global.js +0 -170
- data/app/assets/javascripts/materialize/hammer.min.js +0 -424
- data/app/assets/javascripts/materialize/initial.js +0 -10
- data/app/assets/javascripts/materialize/jquery.easing.1.4.js +0 -144
- data/app/assets/javascripts/materialize/jquery.hammer.js +0 -33
- data/app/assets/javascripts/materialize/materialbox.js +0 -263
- data/app/assets/javascripts/materialize/parallax.js +0 -54
- data/app/assets/javascripts/materialize/pushpin.js +0 -68
- data/app/assets/javascripts/materialize/scrollFire.js +0 -49
- data/app/assets/javascripts/materialize/scrollspy.js +0 -230
- data/app/assets/javascripts/materialize/sideNav.js +0 -395
- data/app/assets/javascripts/materialize/slider.js +0 -295
- data/app/assets/javascripts/materialize/tabs.js +0 -244
- data/app/assets/javascripts/materialize/tapTarget.js +0 -184
- data/app/assets/javascripts/materialize/tooltip.js +0 -227
- data/app/assets/javascripts/materialize/transitions.js +0 -163
- data/app/assets/javascripts/materialize/velocity.min.js +0 -626
- data/app/assets/stylesheets/materialize/components/_normalize.scss +0 -424
- data/app/assets/stylesheets/materialize/components/_roboto.scss +0 -39
- data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +0 -469
- data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +0 -216
- data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +0 -267
@@ -1,295 +0,0 @@
|
|
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) {
|
24
|
-
$active = $slides.eq($active_index);
|
25
|
-
}
|
26
|
-
|
27
|
-
// Transitions the caption depending on alignment
|
28
|
-
function captionTransition(caption, duration) {
|
29
|
-
if (caption.hasClass("center-align")) {
|
30
|
-
caption.velocity({ opacity: 0, translateY: -100 }, { duration: duration, queue: false });
|
31
|
-
} else if (caption.hasClass("right-align")) {
|
32
|
-
caption.velocity({ opacity: 0, translateX: 100 }, { duration: duration, queue: false });
|
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;else if (index < 0) index = $slides.length - 1;
|
42
|
-
|
43
|
-
$active_index = $slider.find('.active').index();
|
44
|
-
|
45
|
-
// Only do if index changes
|
46
|
-
if ($active_index != index) {
|
47
|
-
$active = $slides.eq($active_index);
|
48
|
-
$caption = $active.find('.caption');
|
49
|
-
|
50
|
-
$active.removeClass('active');
|
51
|
-
$active.velocity({ opacity: 0 }, { duration: options.transition, queue: false, easing: 'easeOutQuad',
|
52
|
-
complete: function () {
|
53
|
-
$slides.not('.active').velocity({ opacity: 0, translateX: 0, translateY: 0 }, { duration: 0, queue: false });
|
54
|
-
} });
|
55
|
-
captionTransition($caption, options.transition);
|
56
|
-
|
57
|
-
// Update indicators
|
58
|
-
if (options.indicators) {
|
59
|
-
$indicators.eq($active_index).removeClass('active');
|
60
|
-
}
|
61
|
-
|
62
|
-
$slides.eq(index).velocity({ opacity: 1 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' });
|
63
|
-
$slides.eq(index).find('.caption').velocity({ opacity: 1, translateX: 0, translateY: 0 }, { duration: options.transition, delay: options.transition, queue: false, easing: 'easeOutQuad' });
|
64
|
-
$slides.eq(index).addClass('active');
|
65
|
-
|
66
|
-
// Update indicators
|
67
|
-
if (options.indicators) {
|
68
|
-
$indicators.eq(index).addClass('active');
|
69
|
-
}
|
70
|
-
}
|
71
|
-
}
|
72
|
-
|
73
|
-
// Set height of slider
|
74
|
-
// If fullscreen, do nothing
|
75
|
-
if (!$this.hasClass('fullscreen')) {
|
76
|
-
if (options.indicators) {
|
77
|
-
// Add height if indicators are present
|
78
|
-
$this.height(options.height + 40);
|
79
|
-
} else {
|
80
|
-
$this.height(options.height);
|
81
|
-
}
|
82
|
-
$slider.height(options.height);
|
83
|
-
}
|
84
|
-
|
85
|
-
// Set initial positions of captions
|
86
|
-
$slides.find('.caption').each(function () {
|
87
|
-
captionTransition($(this), 0);
|
88
|
-
});
|
89
|
-
|
90
|
-
// Move img src into background-image
|
91
|
-
$slides.find('img').each(function () {
|
92
|
-
var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
|
93
|
-
if ($(this).attr('src') !== placeholderBase64) {
|
94
|
-
$(this).css('background-image', 'url("' + $(this).attr('src') + '")');
|
95
|
-
$(this).attr('src', placeholderBase64);
|
96
|
-
}
|
97
|
-
});
|
98
|
-
|
99
|
-
// dynamically add indicators
|
100
|
-
if (options.indicators) {
|
101
|
-
$indicators = $('<ul class="indicators"></ul>');
|
102
|
-
$slides.each(function (index) {
|
103
|
-
var $indicator = $('<li class="indicator-item"></li>');
|
104
|
-
|
105
|
-
// Handle clicks on indicators
|
106
|
-
$indicator.click(function () {
|
107
|
-
var $parent = $slider.parent();
|
108
|
-
var curr_index = $parent.find($(this)).index();
|
109
|
-
moveToSlide(curr_index);
|
110
|
-
|
111
|
-
// reset interval
|
112
|
-
clearInterval($interval);
|
113
|
-
$interval = setInterval(function () {
|
114
|
-
$active_index = $slider.find('.active').index();
|
115
|
-
if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
|
116
|
-
else $active_index += 1;
|
117
|
-
|
118
|
-
moveToSlide($active_index);
|
119
|
-
}, options.transition + options.interval);
|
120
|
-
});
|
121
|
-
$indicators.append($indicator);
|
122
|
-
});
|
123
|
-
$this.append($indicators);
|
124
|
-
$indicators = $this.find('ul.indicators').find('li.indicator-item');
|
125
|
-
}
|
126
|
-
|
127
|
-
if ($active) {
|
128
|
-
$active.show();
|
129
|
-
} else {
|
130
|
-
$slides.first().addClass('active').velocity({ opacity: 1 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' });
|
131
|
-
|
132
|
-
$active_index = 0;
|
133
|
-
$active = $slides.eq($active_index);
|
134
|
-
|
135
|
-
// Update indicators
|
136
|
-
if (options.indicators) {
|
137
|
-
$indicators.eq($active_index).addClass('active');
|
138
|
-
}
|
139
|
-
}
|
140
|
-
|
141
|
-
// Adjust height to current slide
|
142
|
-
$active.find('img').each(function () {
|
143
|
-
$active.find('.caption').velocity({ opacity: 1, translateX: 0, translateY: 0 }, { duration: options.transition, queue: false, easing: 'easeOutQuad' });
|
144
|
-
});
|
145
|
-
|
146
|
-
// auto scroll
|
147
|
-
$interval = setInterval(function () {
|
148
|
-
$active_index = $slider.find('.active').index();
|
149
|
-
moveToSlide($active_index + 1);
|
150
|
-
}, options.transition + options.interval);
|
151
|
-
|
152
|
-
// HammerJS, Swipe navigation
|
153
|
-
|
154
|
-
// Touch Event
|
155
|
-
var panning = false;
|
156
|
-
var swipeLeft = false;
|
157
|
-
var swipeRight = false;
|
158
|
-
|
159
|
-
$this.hammer({
|
160
|
-
prevent_default: false
|
161
|
-
}).on('pan', function (e) {
|
162
|
-
if (e.gesture.pointerType === "touch") {
|
163
|
-
|
164
|
-
// reset interval
|
165
|
-
clearInterval($interval);
|
166
|
-
|
167
|
-
var direction = e.gesture.direction;
|
168
|
-
var x = e.gesture.deltaX;
|
169
|
-
var velocityX = e.gesture.velocityX;
|
170
|
-
var velocityY = e.gesture.velocityY;
|
171
|
-
|
172
|
-
$curr_slide = $slider.find('.active');
|
173
|
-
if (Math.abs(velocityX) > Math.abs(velocityY)) {
|
174
|
-
$curr_slide.velocity({ translateX: x
|
175
|
-
}, { duration: 50, queue: false, easing: 'easeOutQuad' });
|
176
|
-
}
|
177
|
-
|
178
|
-
// Swipe Left
|
179
|
-
if (direction === 4 && (x > $this.innerWidth() / 2 || velocityX < -0.65)) {
|
180
|
-
swipeRight = true;
|
181
|
-
}
|
182
|
-
// Swipe Right
|
183
|
-
else if (direction === 2 && (x < -1 * $this.innerWidth() / 2 || velocityX > 0.65)) {
|
184
|
-
swipeLeft = true;
|
185
|
-
}
|
186
|
-
|
187
|
-
// Make Slide Behind active slide visible
|
188
|
-
var next_slide;
|
189
|
-
if (swipeLeft) {
|
190
|
-
next_slide = $curr_slide.next();
|
191
|
-
if (next_slide.length === 0) {
|
192
|
-
next_slide = $slides.first();
|
193
|
-
}
|
194
|
-
next_slide.velocity({ opacity: 1
|
195
|
-
}, { duration: 300, queue: false, easing: 'easeOutQuad' });
|
196
|
-
}
|
197
|
-
if (swipeRight) {
|
198
|
-
next_slide = $curr_slide.prev();
|
199
|
-
if (next_slide.length === 0) {
|
200
|
-
next_slide = $slides.last();
|
201
|
-
}
|
202
|
-
next_slide.velocity({ opacity: 1
|
203
|
-
}, { duration: 300, queue: false, easing: 'easeOutQuad' });
|
204
|
-
}
|
205
|
-
}
|
206
|
-
}).on('panend', function (e) {
|
207
|
-
if (e.gesture.pointerType === "touch") {
|
208
|
-
|
209
|
-
$curr_slide = $slider.find('.active');
|
210
|
-
panning = false;
|
211
|
-
curr_index = $slider.find('.active').index();
|
212
|
-
|
213
|
-
if (!swipeRight && !swipeLeft || $slides.length <= 1) {
|
214
|
-
// Return to original spot
|
215
|
-
$curr_slide.velocity({ translateX: 0
|
216
|
-
}, { duration: 300, queue: false, easing: 'easeOutQuad' });
|
217
|
-
} else if (swipeLeft) {
|
218
|
-
moveToSlide(curr_index + 1);
|
219
|
-
$curr_slide.velocity({ translateX: -1 * $this.innerWidth() }, { duration: 300, queue: false, easing: 'easeOutQuad',
|
220
|
-
complete: function () {
|
221
|
-
$curr_slide.velocity({ opacity: 0, translateX: 0 }, { duration: 0, queue: false });
|
222
|
-
} });
|
223
|
-
} else if (swipeRight) {
|
224
|
-
moveToSlide(curr_index - 1);
|
225
|
-
$curr_slide.velocity({ translateX: $this.innerWidth() }, { duration: 300, queue: false, easing: 'easeOutQuad',
|
226
|
-
complete: function () {
|
227
|
-
$curr_slide.velocity({ opacity: 0, translateX: 0 }, { duration: 0, queue: false });
|
228
|
-
} });
|
229
|
-
}
|
230
|
-
swipeLeft = false;
|
231
|
-
swipeRight = false;
|
232
|
-
|
233
|
-
// Restart interval
|
234
|
-
clearInterval($interval);
|
235
|
-
$interval = setInterval(function () {
|
236
|
-
$active_index = $slider.find('.active').index();
|
237
|
-
if ($slides.length == $active_index + 1) $active_index = 0; // loop to start
|
238
|
-
else $active_index += 1;
|
239
|
-
|
240
|
-
moveToSlide($active_index);
|
241
|
-
}, options.transition + options.interval);
|
242
|
-
}
|
243
|
-
});
|
244
|
-
|
245
|
-
$this.on('sliderPause', function () {
|
246
|
-
clearInterval($interval);
|
247
|
-
});
|
248
|
-
|
249
|
-
$this.on('sliderStart', function () {
|
250
|
-
clearInterval($interval);
|
251
|
-
$interval = setInterval(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
|
-
}, options.transition + options.interval);
|
258
|
-
});
|
259
|
-
|
260
|
-
$this.on('sliderNext', function () {
|
261
|
-
$active_index = $slider.find('.active').index();
|
262
|
-
moveToSlide($active_index + 1);
|
263
|
-
});
|
264
|
-
|
265
|
-
$this.on('sliderPrev', function () {
|
266
|
-
$active_index = $slider.find('.active').index();
|
267
|
-
moveToSlide($active_index - 1);
|
268
|
-
});
|
269
|
-
});
|
270
|
-
},
|
271
|
-
pause: function () {
|
272
|
-
$(this).trigger('sliderPause');
|
273
|
-
},
|
274
|
-
start: function () {
|
275
|
-
$(this).trigger('sliderStart');
|
276
|
-
},
|
277
|
-
next: function () {
|
278
|
-
$(this).trigger('sliderNext');
|
279
|
-
},
|
280
|
-
prev: function () {
|
281
|
-
$(this).trigger('sliderPrev');
|
282
|
-
}
|
283
|
-
};
|
284
|
-
|
285
|
-
$.fn.slider = function (methodOrOptions) {
|
286
|
-
if (methods[methodOrOptions]) {
|
287
|
-
return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
|
288
|
-
} else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
|
289
|
-
// Default to "init"
|
290
|
-
return methods.init.apply(this, arguments);
|
291
|
-
} else {
|
292
|
-
$.error('Method ' + methodOrOptions + ' does not exist on jQuery.tooltip');
|
293
|
-
}
|
294
|
-
}; // Plugin end
|
295
|
-
})(jQuery);
|
@@ -1,244 +0,0 @@
|
|
1
|
-
(function ($) {
|
2
|
-
|
3
|
-
var methods = {
|
4
|
-
init: function (options) {
|
5
|
-
var defaults = {
|
6
|
-
onShow: null,
|
7
|
-
swipeable: false,
|
8
|
-
responsiveThreshold: Infinity // breakpoint for swipeable
|
9
|
-
};
|
10
|
-
options = $.extend(defaults, options);
|
11
|
-
var namespace = Materialize.objectSelectorString($(this));
|
12
|
-
|
13
|
-
return this.each(function (i) {
|
14
|
-
|
15
|
-
var uniqueNamespace = namespace + i;
|
16
|
-
|
17
|
-
// For each set of tabs, we want to keep track of
|
18
|
-
// which tab is active and its associated content
|
19
|
-
var $this = $(this),
|
20
|
-
window_width = $(window).width();
|
21
|
-
|
22
|
-
var $active,
|
23
|
-
$content,
|
24
|
-
$links = $this.find('li.tab a'),
|
25
|
-
$tabs_width = $this.width(),
|
26
|
-
$tabs_content = $(),
|
27
|
-
$tabs_wrapper,
|
28
|
-
$tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length,
|
29
|
-
$indicator,
|
30
|
-
index = 0,
|
31
|
-
prev_index = 0,
|
32
|
-
clicked = false,
|
33
|
-
clickedTimeout,
|
34
|
-
transition = 300;
|
35
|
-
|
36
|
-
// Finds right attribute for indicator based on active tab.
|
37
|
-
// el: jQuery Object
|
38
|
-
var calcRightPos = function (el) {
|
39
|
-
return Math.ceil($tabs_width - el.position().left - el[0].getBoundingClientRect().width - $this.scrollLeft());
|
40
|
-
};
|
41
|
-
|
42
|
-
// Finds left attribute for indicator based on active tab.
|
43
|
-
// el: jQuery Object
|
44
|
-
var calcLeftPos = function (el) {
|
45
|
-
return Math.floor(el.position().left + $this.scrollLeft());
|
46
|
-
};
|
47
|
-
|
48
|
-
// Animates Indicator to active tab.
|
49
|
-
// prev_index: Number
|
50
|
-
var animateIndicator = function (prev_index) {
|
51
|
-
if (index - prev_index >= 0) {
|
52
|
-
$indicator.velocity({ "right": calcRightPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad' });
|
53
|
-
$indicator.velocity({ "left": calcLeftPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad', delay: 90 });
|
54
|
-
} else {
|
55
|
-
$indicator.velocity({ "left": calcLeftPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad' });
|
56
|
-
$indicator.velocity({ "right": calcRightPos($active) }, { duration: transition, queue: false, easing: 'easeOutQuad', delay: 90 });
|
57
|
-
}
|
58
|
-
};
|
59
|
-
|
60
|
-
// Change swipeable according to responsive threshold
|
61
|
-
if (options.swipeable) {
|
62
|
-
if (window_width > options.responsiveThreshold) {
|
63
|
-
options.swipeable = false;
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
|
-
// If the location.hash matches one of the links, use that as the active tab.
|
68
|
-
$active = $($links.filter('[href="' + location.hash + '"]'));
|
69
|
-
|
70
|
-
// If no match is found, use the first link or any with class 'active' as the initial active tab.
|
71
|
-
if ($active.length === 0) {
|
72
|
-
$active = $(this).find('li.tab a.active').first();
|
73
|
-
}
|
74
|
-
if ($active.length === 0) {
|
75
|
-
$active = $(this).find('li.tab a').first();
|
76
|
-
}
|
77
|
-
|
78
|
-
$active.addClass('active');
|
79
|
-
index = $links.index($active);
|
80
|
-
if (index < 0) {
|
81
|
-
index = 0;
|
82
|
-
}
|
83
|
-
|
84
|
-
if ($active[0] !== undefined) {
|
85
|
-
$content = $($active[0].hash);
|
86
|
-
$content.addClass('active');
|
87
|
-
}
|
88
|
-
|
89
|
-
// append indicator then set indicator width to tab width
|
90
|
-
if (!$this.find('.indicator').length) {
|
91
|
-
$this.append('<li class="indicator"></li>');
|
92
|
-
}
|
93
|
-
$indicator = $this.find('.indicator');
|
94
|
-
|
95
|
-
// we make sure that the indicator is at the end of the tabs
|
96
|
-
$this.append($indicator);
|
97
|
-
|
98
|
-
if ($this.is(":visible")) {
|
99
|
-
// $indicator.css({"right": $tabs_width - ((index + 1) * $tab_width)});
|
100
|
-
// $indicator.css({"left": index * $tab_width});
|
101
|
-
setTimeout(function () {
|
102
|
-
$indicator.css({ "right": calcRightPos($active) });
|
103
|
-
$indicator.css({ "left": calcLeftPos($active) });
|
104
|
-
}, 0);
|
105
|
-
}
|
106
|
-
$(window).off('resize.tabs-' + uniqueNamespace).on('resize.tabs-' + uniqueNamespace, function () {
|
107
|
-
$tabs_width = $this.width();
|
108
|
-
$tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length;
|
109
|
-
if (index < 0) {
|
110
|
-
index = 0;
|
111
|
-
}
|
112
|
-
if ($tab_width !== 0 && $tabs_width !== 0) {
|
113
|
-
$indicator.css({ "right": calcRightPos($active) });
|
114
|
-
$indicator.css({ "left": calcLeftPos($active) });
|
115
|
-
}
|
116
|
-
});
|
117
|
-
|
118
|
-
// Initialize Tabs Content.
|
119
|
-
if (options.swipeable) {
|
120
|
-
// TODO: Duplicate calls with swipeable? handle multiple div wrapping.
|
121
|
-
$links.each(function () {
|
122
|
-
var $curr_content = $(Materialize.escapeHash(this.hash));
|
123
|
-
$curr_content.addClass('carousel-item');
|
124
|
-
$tabs_content = $tabs_content.add($curr_content);
|
125
|
-
});
|
126
|
-
$tabs_wrapper = $tabs_content.wrapAll('<div class="tabs-content carousel"></div>');
|
127
|
-
$tabs_content.css('display', '');
|
128
|
-
$('.tabs-content.carousel').carousel({
|
129
|
-
fullWidth: true,
|
130
|
-
noWrap: true,
|
131
|
-
onCycleTo: function (item) {
|
132
|
-
if (!clicked) {
|
133
|
-
var prev_index = index;
|
134
|
-
index = $tabs_wrapper.index(item);
|
135
|
-
$active.removeClass('active');
|
136
|
-
$active = $links.eq(index);
|
137
|
-
$active.addClass('active');
|
138
|
-
animateIndicator(prev_index);
|
139
|
-
if (typeof options.onShow === "function") {
|
140
|
-
options.onShow.call($this[0], $content);
|
141
|
-
}
|
142
|
-
}
|
143
|
-
}
|
144
|
-
});
|
145
|
-
} else {
|
146
|
-
// Hide the remaining content
|
147
|
-
$links.not($active).each(function () {
|
148
|
-
$(Materialize.escapeHash(this.hash)).hide();
|
149
|
-
});
|
150
|
-
}
|
151
|
-
|
152
|
-
// Bind the click event handler
|
153
|
-
$this.off('click.tabs').on('click.tabs', 'a', function (e) {
|
154
|
-
if ($(this).parent().hasClass('disabled')) {
|
155
|
-
e.preventDefault();
|
156
|
-
return;
|
157
|
-
}
|
158
|
-
|
159
|
-
// Act as regular link if target attribute is specified.
|
160
|
-
if (!!$(this).attr("target")) {
|
161
|
-
return;
|
162
|
-
}
|
163
|
-
|
164
|
-
clicked = true;
|
165
|
-
$tabs_width = $this.width();
|
166
|
-
$tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length;
|
167
|
-
|
168
|
-
// Make the old tab inactive.
|
169
|
-
$active.removeClass('active');
|
170
|
-
var $oldContent = $content;
|
171
|
-
|
172
|
-
// Update the variables with the new link and content
|
173
|
-
$active = $(this);
|
174
|
-
$content = $(Materialize.escapeHash(this.hash));
|
175
|
-
$links = $this.find('li.tab a');
|
176
|
-
var activeRect = $active.position();
|
177
|
-
|
178
|
-
// Make the tab active.
|
179
|
-
$active.addClass('active');
|
180
|
-
prev_index = index;
|
181
|
-
index = $links.index($(this));
|
182
|
-
if (index < 0) {
|
183
|
-
index = 0;
|
184
|
-
}
|
185
|
-
// Change url to current tab
|
186
|
-
// window.location.hash = $active.attr('href');
|
187
|
-
|
188
|
-
// Swap content
|
189
|
-
if (options.swipeable) {
|
190
|
-
if ($tabs_content.length) {
|
191
|
-
$tabs_content.carousel('set', index, function () {
|
192
|
-
if (typeof options.onShow === "function") {
|
193
|
-
options.onShow.call($this[0], $content);
|
194
|
-
}
|
195
|
-
});
|
196
|
-
}
|
197
|
-
} else {
|
198
|
-
if ($content !== undefined) {
|
199
|
-
$content.show();
|
200
|
-
$content.addClass('active');
|
201
|
-
if (typeof options.onShow === "function") {
|
202
|
-
options.onShow.call(this, $content);
|
203
|
-
}
|
204
|
-
}
|
205
|
-
|
206
|
-
if ($oldContent !== undefined && !$oldContent.is($content)) {
|
207
|
-
$oldContent.hide();
|
208
|
-
$oldContent.removeClass('active');
|
209
|
-
}
|
210
|
-
}
|
211
|
-
|
212
|
-
// Reset clicked state
|
213
|
-
clickedTimeout = setTimeout(function () {
|
214
|
-
clicked = false;
|
215
|
-
}, transition);
|
216
|
-
|
217
|
-
// Update indicator
|
218
|
-
animateIndicator(prev_index);
|
219
|
-
|
220
|
-
// Prevent the anchor's default click action
|
221
|
-
e.preventDefault();
|
222
|
-
});
|
223
|
-
});
|
224
|
-
},
|
225
|
-
select_tab: function (id) {
|
226
|
-
this.find('a[href="#' + id + '"]').trigger('click');
|
227
|
-
}
|
228
|
-
};
|
229
|
-
|
230
|
-
$.fn.tabs = function (methodOrOptions) {
|
231
|
-
if (methods[methodOrOptions]) {
|
232
|
-
return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
|
233
|
-
} else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
|
234
|
-
// Default to "init"
|
235
|
-
return methods.init.apply(this, arguments);
|
236
|
-
} else {
|
237
|
-
$.error('Method ' + methodOrOptions + ' does not exist on jQuery.tabs');
|
238
|
-
}
|
239
|
-
};
|
240
|
-
|
241
|
-
$(document).on('ready turbolinks:load', function () {
|
242
|
-
$('ul.tabs').tabs();
|
243
|
-
});
|
244
|
-
})(jQuery);
|