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.
- checksums.yaml +5 -5
- data/.gitattributes +1 -0
- data/.gitignore +1 -0
- data/README.md +34 -32
- data/Rakefile +38 -21
- data/assets/javascripts/materialize/anime.min.js +417 -0
- data/assets/javascripts/materialize/autocomplete.js +504 -0
- data/assets/javascripts/materialize/buttons.js +409 -0
- data/assets/javascripts/materialize/cards.js +34 -0
- data/assets/javascripts/materialize/carousel.js +797 -0
- data/assets/javascripts/materialize/cash.js +990 -0
- data/assets/javascripts/materialize/characterCounter.js +180 -0
- data/assets/javascripts/materialize/chips.js +564 -0
- data/assets/javascripts/materialize/collapsible.js +337 -0
- data/assets/javascripts/materialize/component.js +57 -0
- data/assets/javascripts/materialize/datepicker.js +935 -0
- data/assets/javascripts/materialize/dropdown.js +659 -0
- data/assets/javascripts/materialize/extras/nouislider.js +2147 -0
- data/assets/javascripts/materialize/extras/nouislider.min.js +1 -0
- data/assets/javascripts/materialize/forms.js +244 -0
- data/assets/javascripts/materialize/global.js +408 -0
- data/assets/javascripts/materialize/materialbox.js +513 -0
- data/assets/javascripts/materialize/modal.js +449 -0
- data/assets/javascripts/materialize/parallax.js +173 -0
- data/assets/javascripts/materialize/pushpin.js +179 -0
- data/assets/javascripts/materialize/range.js +310 -0
- data/assets/javascripts/materialize/scrollspy.js +328 -0
- data/assets/javascripts/materialize/select.js +497 -0
- data/assets/javascripts/materialize/sidenav.js +655 -0
- data/assets/javascripts/materialize/slider.js +424 -0
- data/assets/javascripts/materialize/tabs.js +476 -0
- data/assets/javascripts/materialize/tapTarget.js +364 -0
- data/assets/javascripts/materialize/timepicker.js +647 -0
- data/assets/javascripts/materialize/toasts.js +355 -0
- data/assets/javascripts/materialize/tooltip.js +351 -0
- data/{app/assets → assets}/javascripts/materialize/waves.js +42 -47
- data/{app/assets → assets}/javascripts/materialize-sprockets.js +12 -13
- data/assets/javascripts/materialize.js +12374 -0
- data/assets/stylesheets/materialize/components/_badges.scss +55 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_buttons.scss +99 -58
- data/{app/assets → assets}/stylesheets/materialize/components/_cards.scss +14 -6
- data/{app/assets → assets}/stylesheets/materialize/components/_carousel.scss +12 -7
- data/{app/assets → assets}/stylesheets/materialize/components/_chips.scss +13 -6
- data/{app/assets → assets}/stylesheets/materialize/components/_collapsible.scss +16 -15
- data/assets/stylesheets/materialize/components/_color-classes.scss +32 -0
- data/{app/assets/stylesheets/materialize/components/_color.scss → assets/stylesheets/materialize/components/_color-variables.scss} +2 -44
- data/assets/stylesheets/materialize/components/_datepicker.scss +191 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_dropdown.scss +35 -15
- data/{app/assets → assets}/stylesheets/materialize/components/_global.scss +96 -125
- data/{app/assets → assets}/stylesheets/materialize/components/_grid.scss +45 -36
- data/{app/assets → assets}/stylesheets/materialize/components/_icons-material-design.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_materialbox.scss +13 -12
- data/{app/assets → assets}/stylesheets/materialize/components/_modal.scss +7 -3
- data/{app/assets → assets}/stylesheets/materialize/components/_navbar.scss +29 -11
- data/assets/stylesheets/materialize/components/_normalize.scss +447 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_preloader.scss +2 -2
- data/assets/stylesheets/materialize/components/_pulse.scss +34 -0
- data/{app/assets/stylesheets/materialize/components/_sideNav.scss → assets/stylesheets/materialize/components/_sidenav.scss} +47 -47
- data/{app/assets → assets}/stylesheets/materialize/components/_slider.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_table_of_contents.scss +5 -5
- data/{app/assets → assets}/stylesheets/materialize/components/_tabs.scss +10 -10
- data/assets/stylesheets/materialize/components/_tapTarget.scss +103 -0
- data/assets/stylesheets/materialize/components/_timepicker.scss +183 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_toast.scss +7 -14
- data/{app/assets → assets}/stylesheets/materialize/components/_tooltip.scss +3 -3
- data/assets/stylesheets/materialize/components/_transitions.scss +13 -0
- data/{app/assets → assets}/stylesheets/materialize/components/_typography.scss +8 -9
- data/{app/assets → assets}/stylesheets/materialize/components/_variables.scss +65 -29
- data/assets/stylesheets/materialize/components/_waves.scss +114 -0
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_checkboxes.scss +26 -46
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_file-input.scss +6 -0
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_forms.scss +0 -0
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_input-fields.scss +131 -63
- data/assets/stylesheets/materialize/components/forms/_radio-buttons.scss +115 -0
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_range.scss +35 -33
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_select.scss +88 -19
- data/{app/assets → assets}/stylesheets/materialize/components/forms/_switches.scss +32 -21
- data/assets/stylesheets/materialize/extras/nouislider.css +406 -0
- data/{app/assets → assets}/stylesheets/materialize.scss +10 -9
- data/lib/materialize-sass/engine.rb +9 -7
- data/lib/materialize-sass/helpers.rb +38 -0
- data/lib/materialize-sass/version.rb +1 -1
- data/lib/materialize-sass.rb +13 -28
- data/materialize-sass.gemspec +5 -5
- metadata +97 -119
- data/app/assets/fonts/roboto/Roboto-Bold.eot +0 -0
- data/app/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
- data/app/assets/fonts/roboto/Roboto-Bold.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Light.eot +0 -0
- data/app/assets/fonts/roboto/Roboto-Light.ttf +0 -0
- data/app/assets/fonts/roboto/Roboto-Light.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Medium.eot +0 -0
- data/app/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
- data/app/assets/fonts/roboto/Roboto-Medium.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Regular.eot +0 -0
- data/app/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
- data/app/assets/fonts/roboto/Roboto-Regular.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
- data/app/assets/fonts/roboto/Roboto-Thin.eot +0 -0
- data/app/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
- data/app/assets/fonts/roboto/Roboto-Thin.woff +0 -0
- data/app/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
- data/app/assets/javascripts/materialize/animation.js +0 -9
- data/app/assets/javascripts/materialize/buttons.js +0 -267
- data/app/assets/javascripts/materialize/cards.js +0 -26
- data/app/assets/javascripts/materialize/carousel.js +0 -454
- data/app/assets/javascripts/materialize/character_counter.js +0 -72
- data/app/assets/javascripts/materialize/chips.js +0 -289
- data/app/assets/javascripts/materialize/collapsible.js +0 -160
- data/app/assets/javascripts/materialize/date_picker/picker.date.js +0 -1430
- data/app/assets/javascripts/materialize/date_picker/picker.js +0 -1123
- data/app/assets/javascripts/materialize/dropdown.js +0 -265
- data/app/assets/javascripts/materialize/extras/nouislider.js +0 -1666
- data/app/assets/javascripts/materialize/extras/nouislider.min.js +0 -1
- data/app/assets/javascripts/materialize/forms.js +0 -682
- data/app/assets/javascripts/materialize/global.js +0 -98
- data/app/assets/javascripts/materialize/hammer.min.js +0 -1
- data/app/assets/javascripts/materialize/init.js +0 -174
- data/app/assets/javascripts/materialize/initial.js +0 -11
- data/app/assets/javascripts/materialize/jquery.easing.1.3.js +0 -205
- data/app/assets/javascripts/materialize/jquery.hammer.js +0 -33
- data/app/assets/javascripts/materialize/jquery.timeago.min.js +0 -1
- data/app/assets/javascripts/materialize/materialbox.js +0 -269
- data/app/assets/javascripts/materialize/modal.js +0 -184
- data/app/assets/javascripts/materialize/parallax.js +0 -58
- data/app/assets/javascripts/materialize/prism.js +0 -8
- data/app/assets/javascripts/materialize/pushpin.js +0 -71
- data/app/assets/javascripts/materialize/scrollFire.js +0 -48
- data/app/assets/javascripts/materialize/scrollspy.js +0 -284
- data/app/assets/javascripts/materialize/sideNav.js +0 -370
- data/app/assets/javascripts/materialize/slider.js +0 -321
- data/app/assets/javascripts/materialize/tabs.js +0 -164
- data/app/assets/javascripts/materialize/toasts.js +0 -137
- data/app/assets/javascripts/materialize/tooltip.js +0 -236
- data/app/assets/javascripts/materialize/transitions.js +0 -169
- data/app/assets/javascripts/materialize/velocity.min.js +0 -5
- data/app/assets/javascripts/materialize.js +0 -5
- data/app/assets/stylesheets/materialize/components/_mixins.scss +0 -5
- data/app/assets/stylesheets/materialize/components/_normalize.scss +0 -424
- data/app/assets/stylesheets/materialize/components/_prefixer.scss +0 -384
- data/app/assets/stylesheets/materialize/components/_roboto.scss +0 -49
- data/app/assets/stylesheets/materialize/components/_waves.scss +0 -177
- data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +0 -435
- data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +0 -201
- data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +0 -125
- data/app/assets/stylesheets/materialize/components/forms/_radio-buttons.scss +0 -117
- data/app/assets/stylesheets/materialize/extras/nouislider.css +0 -259
@@ -1,454 +0,0 @@
|
|
1
|
-
(function ($) {
|
2
|
-
|
3
|
-
var methods = {
|
4
|
-
|
5
|
-
init : function(options) {
|
6
|
-
var defaults = {
|
7
|
-
time_constant: 200, // ms
|
8
|
-
dist: -100, // zoom scale TODO: make this more intuitive as an option
|
9
|
-
shift: 0, // spacing for center image
|
10
|
-
padding: 0, // Padding between non center items
|
11
|
-
full_width: false, // Change to full width styles
|
12
|
-
indicators: false, // Toggle indicators
|
13
|
-
no_wrap: false // Don't wrap around and cycle through items.
|
14
|
-
};
|
15
|
-
options = $.extend(defaults, options);
|
16
|
-
|
17
|
-
return this.each(function() {
|
18
|
-
|
19
|
-
var images, offset, center, pressed, dim, count,
|
20
|
-
reference, referenceY, amplitude, target, velocity,
|
21
|
-
xform, frame, timestamp, ticker, dragged, vertical_dragged;
|
22
|
-
var $indicators = $('<ul class="indicators"></ul>');
|
23
|
-
|
24
|
-
|
25
|
-
// Initialize
|
26
|
-
var view = $(this);
|
27
|
-
var showIndicators = view.attr('data-indicators') || options.indicators;
|
28
|
-
|
29
|
-
// Don't double initialize.
|
30
|
-
if (view.hasClass('initialized')) {
|
31
|
-
// Redraw carousel.
|
32
|
-
$(this).trigger('carouselNext', [0.000001]);
|
33
|
-
return true;
|
34
|
-
}
|
35
|
-
|
36
|
-
|
37
|
-
// Options
|
38
|
-
if (options.full_width) {
|
39
|
-
options.dist = 0;
|
40
|
-
var firstImage = view.find('.carousel-item img').first();
|
41
|
-
if (firstImage.length) {
|
42
|
-
imageHeight = firstImage.on('load', function(){
|
43
|
-
view.css('height', $(this).height());
|
44
|
-
});
|
45
|
-
} else {
|
46
|
-
imageHeight = view.find('.carousel-item').first().height();
|
47
|
-
view.css('height', imageHeight);
|
48
|
-
}
|
49
|
-
|
50
|
-
// Offset fixed items when indicators.
|
51
|
-
if (showIndicators) {
|
52
|
-
view.find('.carousel-fixed-item').addClass('with-indicators');
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
|
57
|
-
view.addClass('initialized');
|
58
|
-
pressed = false;
|
59
|
-
offset = target = 0;
|
60
|
-
images = [];
|
61
|
-
item_width = view.find('.carousel-item').first().innerWidth();
|
62
|
-
dim = item_width * 2 + options.padding;
|
63
|
-
|
64
|
-
view.find('.carousel-item').each(function (i) {
|
65
|
-
images.push($(this)[0]);
|
66
|
-
if (showIndicators) {
|
67
|
-
var $indicator = $('<li class="indicator-item"></li>');
|
68
|
-
|
69
|
-
// Add active to first by default.
|
70
|
-
if (i === 0) {
|
71
|
-
$indicator.addClass('active');
|
72
|
-
}
|
73
|
-
|
74
|
-
// Handle clicks on indicators.
|
75
|
-
$indicator.click(function () {
|
76
|
-
var index = $(this).index();
|
77
|
-
cycleTo(index);
|
78
|
-
});
|
79
|
-
$indicators.append($indicator);
|
80
|
-
}
|
81
|
-
});
|
82
|
-
|
83
|
-
if (showIndicators) {
|
84
|
-
view.append($indicators);
|
85
|
-
}
|
86
|
-
count = images.length;
|
87
|
-
|
88
|
-
|
89
|
-
function setupEvents() {
|
90
|
-
if (typeof window.ontouchstart !== 'undefined') {
|
91
|
-
view[0].addEventListener('touchstart', tap);
|
92
|
-
view[0].addEventListener('touchmove', drag);
|
93
|
-
view[0].addEventListener('touchend', release);
|
94
|
-
}
|
95
|
-
view[0].addEventListener('mousedown', tap);
|
96
|
-
view[0].addEventListener('mousemove', drag);
|
97
|
-
view[0].addEventListener('mouseup', release);
|
98
|
-
view[0].addEventListener('mouseleave', release);
|
99
|
-
view[0].addEventListener('click', click);
|
100
|
-
}
|
101
|
-
|
102
|
-
function xpos(e) {
|
103
|
-
// touch event
|
104
|
-
if (e.targetTouches && (e.targetTouches.length >= 1)) {
|
105
|
-
return e.targetTouches[0].clientX;
|
106
|
-
}
|
107
|
-
|
108
|
-
// mouse event
|
109
|
-
return e.clientX;
|
110
|
-
}
|
111
|
-
|
112
|
-
function ypos(e) {
|
113
|
-
// touch event
|
114
|
-
if (e.targetTouches && (e.targetTouches.length >= 1)) {
|
115
|
-
return e.targetTouches[0].clientY;
|
116
|
-
}
|
117
|
-
|
118
|
-
// mouse event
|
119
|
-
return e.clientY;
|
120
|
-
}
|
121
|
-
|
122
|
-
function wrap(x) {
|
123
|
-
return (x >= count) ? (x % count) : (x < 0) ? wrap(count + (x % count)) : x;
|
124
|
-
}
|
125
|
-
|
126
|
-
function scroll(x) {
|
127
|
-
var i, half, delta, dir, tween, el, alignment, xTranslation;
|
128
|
-
|
129
|
-
offset = (typeof x === 'number') ? x : offset;
|
130
|
-
center = Math.floor((offset + dim / 2) / dim);
|
131
|
-
delta = offset - center * dim;
|
132
|
-
dir = (delta < 0) ? 1 : -1;
|
133
|
-
tween = -dir * delta * 2 / dim;
|
134
|
-
half = count >> 1;
|
135
|
-
|
136
|
-
if (!options.full_width) {
|
137
|
-
alignment = 'translateX(' + (view[0].clientWidth - item_width) / 2 + 'px) ';
|
138
|
-
alignment += 'translateY(' + (view[0].clientHeight - item_width) / 2 + 'px)';
|
139
|
-
} else {
|
140
|
-
alignment = 'translateX(0)';
|
141
|
-
}
|
142
|
-
|
143
|
-
// Set indicator active
|
144
|
-
if (showIndicators) {
|
145
|
-
var diff = (center % count);
|
146
|
-
var activeIndicator = $indicators.find('.indicator-item.active');
|
147
|
-
if (activeIndicator.index() !== diff) {
|
148
|
-
activeIndicator.removeClass('active');
|
149
|
-
$indicators.find('.indicator-item').eq(diff).addClass('active');
|
150
|
-
}
|
151
|
-
}
|
152
|
-
|
153
|
-
// center
|
154
|
-
// Don't show wrapped items.
|
155
|
-
if (!options.no_wrap || (center >= 0 && center < count)) {
|
156
|
-
el = images[wrap(center)];
|
157
|
-
el.style[xform] = alignment +
|
158
|
-
' translateX(' + (-delta / 2) + 'px)' +
|
159
|
-
' translateX(' + (dir * options.shift * tween * i) + 'px)' +
|
160
|
-
' translateZ(' + (options.dist * tween) + 'px)';
|
161
|
-
el.style.zIndex = 0;
|
162
|
-
if (options.full_width) { tweenedOpacity = 1; }
|
163
|
-
else { tweenedOpacity = 1 - 0.2 * tween; }
|
164
|
-
el.style.opacity = tweenedOpacity;
|
165
|
-
el.style.display = 'block';
|
166
|
-
}
|
167
|
-
|
168
|
-
for (i = 1; i <= half; ++i) {
|
169
|
-
// right side
|
170
|
-
if (options.full_width) {
|
171
|
-
zTranslation = options.dist;
|
172
|
-
tweenedOpacity = (i === half && delta < 0) ? 1 - tween : 1;
|
173
|
-
} else {
|
174
|
-
zTranslation = options.dist * (i * 2 + tween * dir);
|
175
|
-
tweenedOpacity = 1 - 0.2 * (i * 2 + tween * dir);
|
176
|
-
}
|
177
|
-
// Don't show wrapped items.
|
178
|
-
if (!options.no_wrap || center + i < count) {
|
179
|
-
el = images[wrap(center + i)];
|
180
|
-
el.style[xform] = alignment +
|
181
|
-
' translateX(' + (options.shift + (dim * i - delta) / 2) + 'px)' +
|
182
|
-
' translateZ(' + zTranslation + 'px)';
|
183
|
-
el.style.zIndex = -i;
|
184
|
-
el.style.opacity = tweenedOpacity;
|
185
|
-
el.style.display = 'block';
|
186
|
-
}
|
187
|
-
|
188
|
-
|
189
|
-
// left side
|
190
|
-
if (options.full_width) {
|
191
|
-
zTranslation = options.dist;
|
192
|
-
tweenedOpacity = (i === half && delta > 0) ? 1 - tween : 1;
|
193
|
-
} else {
|
194
|
-
zTranslation = options.dist * (i * 2 - tween * dir);
|
195
|
-
tweenedOpacity = 1 - 0.2 * (i * 2 - tween * dir);
|
196
|
-
}
|
197
|
-
// Don't show wrapped items.
|
198
|
-
if (!options.no_wrap || center - i >= 0) {
|
199
|
-
el = images[wrap(center - i)];
|
200
|
-
el.style[xform] = alignment +
|
201
|
-
' translateX(' + (-options.shift + (-dim * i - delta) / 2) + 'px)' +
|
202
|
-
' translateZ(' + zTranslation + 'px)';
|
203
|
-
el.style.zIndex = -i;
|
204
|
-
el.style.opacity = tweenedOpacity;
|
205
|
-
el.style.display = 'block';
|
206
|
-
}
|
207
|
-
}
|
208
|
-
|
209
|
-
// center
|
210
|
-
// Don't show wrapped items.
|
211
|
-
if (!options.no_wrap || (center >= 0 && center < count)) {
|
212
|
-
el = images[wrap(center)];
|
213
|
-
el.style[xform] = alignment +
|
214
|
-
' translateX(' + (-delta / 2) + 'px)' +
|
215
|
-
' translateX(' + (dir * options.shift * tween) + 'px)' +
|
216
|
-
' translateZ(' + (options.dist * tween) + 'px)';
|
217
|
-
el.style.zIndex = 0;
|
218
|
-
if (options.full_width) { tweenedOpacity = 1; }
|
219
|
-
else { tweenedOpacity = 1 - 0.2 * tween; }
|
220
|
-
el.style.opacity = tweenedOpacity;
|
221
|
-
el.style.display = 'block';
|
222
|
-
}
|
223
|
-
}
|
224
|
-
|
225
|
-
function track() {
|
226
|
-
var now, elapsed, delta, v;
|
227
|
-
|
228
|
-
now = Date.now();
|
229
|
-
elapsed = now - timestamp;
|
230
|
-
timestamp = now;
|
231
|
-
delta = offset - frame;
|
232
|
-
frame = offset;
|
233
|
-
|
234
|
-
v = 1000 * delta / (1 + elapsed);
|
235
|
-
velocity = 0.8 * v + 0.2 * velocity;
|
236
|
-
}
|
237
|
-
|
238
|
-
function autoScroll() {
|
239
|
-
var elapsed, delta;
|
240
|
-
|
241
|
-
if (amplitude) {
|
242
|
-
elapsed = Date.now() - timestamp;
|
243
|
-
delta = amplitude * Math.exp(-elapsed / options.time_constant);
|
244
|
-
if (delta > 2 || delta < -2) {
|
245
|
-
scroll(target - delta);
|
246
|
-
requestAnimationFrame(autoScroll);
|
247
|
-
} else {
|
248
|
-
scroll(target);
|
249
|
-
}
|
250
|
-
}
|
251
|
-
}
|
252
|
-
|
253
|
-
function click(e) {
|
254
|
-
// Disable clicks if carousel was dragged.
|
255
|
-
if (dragged) {
|
256
|
-
e.preventDefault();
|
257
|
-
e.stopPropagation();
|
258
|
-
return false;
|
259
|
-
|
260
|
-
} else if (!options.full_width) {
|
261
|
-
var clickedIndex = $(e.target).closest('.carousel-item').index();
|
262
|
-
var diff = (center % count) - clickedIndex;
|
263
|
-
|
264
|
-
// Disable clicks if carousel was shifted by click
|
265
|
-
if (diff !== 0) {
|
266
|
-
e.preventDefault();
|
267
|
-
e.stopPropagation();
|
268
|
-
}
|
269
|
-
cycleTo(clickedIndex);
|
270
|
-
}
|
271
|
-
}
|
272
|
-
|
273
|
-
function cycleTo(n) {
|
274
|
-
var diff = (center % count) - n;
|
275
|
-
|
276
|
-
// Account for wraparound.
|
277
|
-
if (!options.no_wrap) {
|
278
|
-
if (diff < 0) {
|
279
|
-
if (Math.abs(diff + count) < Math.abs(diff)) { diff += count; }
|
280
|
-
|
281
|
-
} else if (diff > 0) {
|
282
|
-
if (Math.abs(diff - count) < diff) { diff -= count; }
|
283
|
-
}
|
284
|
-
}
|
285
|
-
|
286
|
-
// Call prev or next accordingly.
|
287
|
-
if (diff < 0) {
|
288
|
-
view.trigger('carouselNext', [Math.abs(diff)]);
|
289
|
-
|
290
|
-
} else if (diff > 0) {
|
291
|
-
view.trigger('carouselPrev', [diff]);
|
292
|
-
}
|
293
|
-
}
|
294
|
-
|
295
|
-
function tap(e) {
|
296
|
-
pressed = true;
|
297
|
-
dragged = false;
|
298
|
-
vertical_dragged = false;
|
299
|
-
reference = xpos(e);
|
300
|
-
referenceY = ypos(e);
|
301
|
-
|
302
|
-
velocity = amplitude = 0;
|
303
|
-
frame = offset;
|
304
|
-
timestamp = Date.now();
|
305
|
-
clearInterval(ticker);
|
306
|
-
ticker = setInterval(track, 100);
|
307
|
-
|
308
|
-
}
|
309
|
-
|
310
|
-
function drag(e) {
|
311
|
-
var x, delta, deltaY;
|
312
|
-
if (pressed) {
|
313
|
-
x = xpos(e);
|
314
|
-
y = ypos(e);
|
315
|
-
delta = reference - x;
|
316
|
-
deltaY = Math.abs(referenceY - y);
|
317
|
-
if (deltaY < 30 && !vertical_dragged) {
|
318
|
-
// If vertical scrolling don't allow dragging.
|
319
|
-
if (delta > 2 || delta < -2) {
|
320
|
-
dragged = true;
|
321
|
-
reference = x;
|
322
|
-
scroll(offset + delta);
|
323
|
-
}
|
324
|
-
|
325
|
-
} else if (dragged) {
|
326
|
-
// If dragging don't allow vertical scroll.
|
327
|
-
e.preventDefault();
|
328
|
-
e.stopPropagation();
|
329
|
-
return false;
|
330
|
-
|
331
|
-
} else {
|
332
|
-
// Vertical scrolling.
|
333
|
-
vertical_dragged = true;
|
334
|
-
}
|
335
|
-
}
|
336
|
-
|
337
|
-
if (dragged) {
|
338
|
-
// If dragging don't allow vertical scroll.
|
339
|
-
e.preventDefault();
|
340
|
-
e.stopPropagation();
|
341
|
-
return false;
|
342
|
-
}
|
343
|
-
}
|
344
|
-
|
345
|
-
function release(e) {
|
346
|
-
if (pressed) {
|
347
|
-
pressed = false;
|
348
|
-
} else {
|
349
|
-
return;
|
350
|
-
}
|
351
|
-
|
352
|
-
clearInterval(ticker);
|
353
|
-
target = offset;
|
354
|
-
if (velocity > 10 || velocity < -10) {
|
355
|
-
amplitude = 0.9 * velocity;
|
356
|
-
target = offset + amplitude;
|
357
|
-
}
|
358
|
-
target = Math.round(target / dim) * dim;
|
359
|
-
|
360
|
-
// No wrap of items.
|
361
|
-
if (options.no_wrap) {
|
362
|
-
if (target >= dim * (count - 1)) {
|
363
|
-
target = dim * (count - 1);
|
364
|
-
} else if (target < 0) {
|
365
|
-
target = 0;
|
366
|
-
}
|
367
|
-
}
|
368
|
-
amplitude = target - offset;
|
369
|
-
timestamp = Date.now();
|
370
|
-
requestAnimationFrame(autoScroll);
|
371
|
-
|
372
|
-
if (dragged) {
|
373
|
-
e.preventDefault();
|
374
|
-
e.stopPropagation();
|
375
|
-
}
|
376
|
-
return false;
|
377
|
-
}
|
378
|
-
|
379
|
-
xform = 'transform';
|
380
|
-
['webkit', 'Moz', 'O', 'ms'].every(function (prefix) {
|
381
|
-
var e = prefix + 'Transform';
|
382
|
-
if (typeof document.body.style[e] !== 'undefined') {
|
383
|
-
xform = e;
|
384
|
-
return false;
|
385
|
-
}
|
386
|
-
return true;
|
387
|
-
});
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
window.onresize = scroll;
|
392
|
-
|
393
|
-
setupEvents();
|
394
|
-
scroll(offset);
|
395
|
-
|
396
|
-
$(this).on('carouselNext', function(e, n) {
|
397
|
-
if (n === undefined) {
|
398
|
-
n = 1;
|
399
|
-
}
|
400
|
-
target = offset + dim * n;
|
401
|
-
if (offset !== target) {
|
402
|
-
amplitude = target - offset;
|
403
|
-
timestamp = Date.now();
|
404
|
-
requestAnimationFrame(autoScroll);
|
405
|
-
}
|
406
|
-
});
|
407
|
-
|
408
|
-
$(this).on('carouselPrev', function(e, n) {
|
409
|
-
if (n === undefined) {
|
410
|
-
n = 1;
|
411
|
-
}
|
412
|
-
target = offset - dim * n;
|
413
|
-
if (offset !== target) {
|
414
|
-
amplitude = target - offset;
|
415
|
-
timestamp = Date.now();
|
416
|
-
requestAnimationFrame(autoScroll);
|
417
|
-
}
|
418
|
-
});
|
419
|
-
|
420
|
-
$(this).on('carouselSet', function(e, n) {
|
421
|
-
if (n === undefined) {
|
422
|
-
n = 0;
|
423
|
-
}
|
424
|
-
cycleTo(n);
|
425
|
-
});
|
426
|
-
|
427
|
-
});
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
},
|
432
|
-
next : function(n) {
|
433
|
-
$(this).trigger('carouselNext', [n]);
|
434
|
-
},
|
435
|
-
prev : function(n) {
|
436
|
-
$(this).trigger('carouselPrev', [n]);
|
437
|
-
},
|
438
|
-
set : function(n) {
|
439
|
-
$(this).trigger('carouselSet', [n]);
|
440
|
-
}
|
441
|
-
};
|
442
|
-
|
443
|
-
|
444
|
-
$.fn.carousel = function(methodOrOptions) {
|
445
|
-
if ( methods[methodOrOptions] ) {
|
446
|
-
return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
447
|
-
} else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
|
448
|
-
// Default to "init"
|
449
|
-
return methods.init.apply( this, arguments );
|
450
|
-
} else {
|
451
|
-
$.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.carousel' );
|
452
|
-
}
|
453
|
-
}; // Plugin end
|
454
|
-
}( jQuery ));
|
@@ -1,72 +0,0 @@
|
|
1
|
-
(function ($) {
|
2
|
-
|
3
|
-
$.fn.characterCounter = function(){
|
4
|
-
return this.each(function(){
|
5
|
-
var $input = $(this);
|
6
|
-
var $counterElement = $input.parent().find('span[class="character-counter"]');
|
7
|
-
|
8
|
-
// character counter has already been added appended to the parent container
|
9
|
-
if ($counterElement.length) {
|
10
|
-
return;
|
11
|
-
}
|
12
|
-
|
13
|
-
var itHasLengthAttribute = $input.attr('length') !== undefined;
|
14
|
-
|
15
|
-
if(itHasLengthAttribute){
|
16
|
-
$input.on('input', updateCounter);
|
17
|
-
$input.on('focus', updateCounter);
|
18
|
-
$input.on('blur', removeCounterElement);
|
19
|
-
|
20
|
-
addCounterElement($input);
|
21
|
-
}
|
22
|
-
|
23
|
-
});
|
24
|
-
};
|
25
|
-
|
26
|
-
function updateCounter(){
|
27
|
-
var maxLength = +$(this).attr('length'),
|
28
|
-
actualLength = +$(this).val().length,
|
29
|
-
isValidLength = actualLength <= maxLength;
|
30
|
-
|
31
|
-
$(this).parent().find('span[class="character-counter"]')
|
32
|
-
.html( actualLength + '/' + maxLength);
|
33
|
-
|
34
|
-
addInputStyle(isValidLength, $(this));
|
35
|
-
}
|
36
|
-
|
37
|
-
function addCounterElement($input) {
|
38
|
-
var $counterElement = $input.parent().find('span[class="character-counter"]');
|
39
|
-
|
40
|
-
if ($counterElement.length) {
|
41
|
-
return;
|
42
|
-
}
|
43
|
-
|
44
|
-
$counterElement = $('<span/>')
|
45
|
-
.addClass('character-counter')
|
46
|
-
.css('float','right')
|
47
|
-
.css('font-size','12px')
|
48
|
-
.css('height', 1);
|
49
|
-
|
50
|
-
$input.parent().append($counterElement);
|
51
|
-
}
|
52
|
-
|
53
|
-
function removeCounterElement(){
|
54
|
-
$(this).parent().find('span[class="character-counter"]').html('');
|
55
|
-
}
|
56
|
-
|
57
|
-
function addInputStyle(isValidLength, $input){
|
58
|
-
var inputHasInvalidClass = $input.hasClass('invalid');
|
59
|
-
if (isValidLength && inputHasInvalidClass) {
|
60
|
-
$input.removeClass('invalid');
|
61
|
-
}
|
62
|
-
else if(!isValidLength && !inputHasInvalidClass){
|
63
|
-
$input.removeClass('valid');
|
64
|
-
$input.addClass('invalid');
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
$(document).on('turbolinks:load', function(){
|
69
|
-
$('input, textarea').characterCounter();
|
70
|
-
});
|
71
|
-
|
72
|
-
}( jQuery ));
|