volt-foundation 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/VERSION +1 -0
- data/app/foundation/assets/css/foundation.css +6196 -0
- data/app/foundation/assets/css/foundation.min.css +1 -0
- data/app/foundation/assets/css/normalize.css +425 -0
- data/app/foundation/assets/js/foundation/foundation.abide.js +313 -0
- data/app/foundation/assets/js/foundation/foundation.accordion.js +65 -0
- data/app/foundation/assets/js/foundation/foundation.alert.js +43 -0
- data/app/foundation/assets/js/foundation/foundation.clearing.js +558 -0
- data/app/foundation/assets/js/foundation/foundation.dropdown.js +326 -0
- data/app/foundation/assets/js/foundation/foundation.equalizer.js +74 -0
- data/app/foundation/assets/js/foundation/foundation.interchange.js +344 -0
- data/app/foundation/assets/js/foundation/foundation.joyride.js +917 -0
- data/app/foundation/assets/js/foundation/foundation.js +625 -0
- data/app/foundation/assets/js/foundation/foundation.magellan.js +189 -0
- data/app/foundation/assets/js/foundation/foundation.offcanvas.js +152 -0
- data/app/foundation/assets/js/foundation/foundation.orbit.js +472 -0
- data/app/foundation/assets/js/foundation/foundation.reveal.js +444 -0
- data/app/foundation/assets/js/foundation/foundation.slider.js +239 -0
- data/app/foundation/assets/js/foundation/foundation.tab.js +217 -0
- data/app/foundation/assets/js/foundation/foundation.tooltip.js +300 -0
- data/app/foundation/assets/js/foundation/foundation.topbar.js +445 -0
- data/app/foundation/assets/js/foundation.min.js +5723 -0
- data/app/foundation/assets/js/vendor/fastclick.js +9 -0
- data/app/foundation/assets/js/vendor/jquery.cookie.js +8 -0
- data/app/foundation/assets/js/vendor/jquery.js +26 -0
- data/app/foundation/assets/js/vendor/modernizr.js +8 -0
- data/app/foundation/assets/js/vendor/placeholder.js +2 -0
- data/lib/volt/foundation/version.rb +5 -0
- data/lib/volt/foundation.rb +7 -0
- data/volt-foundation.gemspec +24 -0
- metadata +107 -0
@@ -0,0 +1,444 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.reveal = {
|
5
|
+
name : 'reveal',
|
6
|
+
|
7
|
+
version : '5.4.6',
|
8
|
+
|
9
|
+
locked : false,
|
10
|
+
|
11
|
+
settings : {
|
12
|
+
animation: 'fadeAndPop',
|
13
|
+
animation_speed: 250,
|
14
|
+
close_on_background_click: true,
|
15
|
+
close_on_esc: true,
|
16
|
+
dismiss_modal_class: 'close-reveal-modal',
|
17
|
+
bg_class: 'reveal-modal-bg',
|
18
|
+
root_element: 'body',
|
19
|
+
open: function(){},
|
20
|
+
opened: function(){},
|
21
|
+
close: function(){},
|
22
|
+
closed: function(){},
|
23
|
+
bg : $('.reveal-modal-bg'),
|
24
|
+
css : {
|
25
|
+
open : {
|
26
|
+
'opacity': 0,
|
27
|
+
'visibility': 'visible',
|
28
|
+
'display' : 'block'
|
29
|
+
},
|
30
|
+
close : {
|
31
|
+
'opacity': 1,
|
32
|
+
'visibility': 'hidden',
|
33
|
+
'display': 'none'
|
34
|
+
}
|
35
|
+
}
|
36
|
+
},
|
37
|
+
|
38
|
+
init : function (scope, method, options) {
|
39
|
+
$.extend(true, this.settings, method, options);
|
40
|
+
this.bindings(method, options);
|
41
|
+
},
|
42
|
+
|
43
|
+
events : function (scope) {
|
44
|
+
var self = this,
|
45
|
+
S = self.S;
|
46
|
+
|
47
|
+
S(this.scope)
|
48
|
+
.off('.reveal')
|
49
|
+
.on('click.fndtn.reveal', '[' + this.add_namespace('data-reveal-id') + ']:not([disabled])', function (e) {
|
50
|
+
e.preventDefault();
|
51
|
+
|
52
|
+
if (!self.locked) {
|
53
|
+
var element = S(this),
|
54
|
+
ajax = element.data(self.data_attr('reveal-ajax'));
|
55
|
+
|
56
|
+
self.locked = true;
|
57
|
+
|
58
|
+
if (typeof ajax === 'undefined') {
|
59
|
+
self.open.call(self, element);
|
60
|
+
} else {
|
61
|
+
var url = ajax === true ? element.attr('href') : ajax;
|
62
|
+
|
63
|
+
self.open.call(self, element, {url: url});
|
64
|
+
}
|
65
|
+
}
|
66
|
+
});
|
67
|
+
|
68
|
+
S(document)
|
69
|
+
.on('click.fndtn.reveal', this.close_targets(), function (e) {
|
70
|
+
|
71
|
+
e.preventDefault();
|
72
|
+
|
73
|
+
if (!self.locked) {
|
74
|
+
var settings = S('[' + self.attr_name() + '].open').data(self.attr_name(true) + '-init'),
|
75
|
+
bg_clicked = S(e.target)[0] === S('.' + settings.bg_class)[0];
|
76
|
+
|
77
|
+
if (bg_clicked) {
|
78
|
+
if (settings.close_on_background_click) {
|
79
|
+
e.stopPropagation();
|
80
|
+
} else {
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
self.locked = true;
|
86
|
+
self.close.call(self, bg_clicked ? S('[' + self.attr_name() + '].open') : S(this).closest('[' + self.attr_name() + ']'));
|
87
|
+
}
|
88
|
+
});
|
89
|
+
|
90
|
+
if(S('[' + self.attr_name() + ']', this.scope).length > 0) {
|
91
|
+
S(this.scope)
|
92
|
+
// .off('.reveal')
|
93
|
+
.on('open.fndtn.reveal', this.settings.open)
|
94
|
+
.on('opened.fndtn.reveal', this.settings.opened)
|
95
|
+
.on('opened.fndtn.reveal', this.open_video)
|
96
|
+
.on('close.fndtn.reveal', this.settings.close)
|
97
|
+
.on('closed.fndtn.reveal', this.settings.closed)
|
98
|
+
.on('closed.fndtn.reveal', this.close_video);
|
99
|
+
} else {
|
100
|
+
S(this.scope)
|
101
|
+
// .off('.reveal')
|
102
|
+
.on('open.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.open)
|
103
|
+
.on('opened.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.opened)
|
104
|
+
.on('opened.fndtn.reveal', '[' + self.attr_name() + ']', this.open_video)
|
105
|
+
.on('close.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.close)
|
106
|
+
.on('closed.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.closed)
|
107
|
+
.on('closed.fndtn.reveal', '[' + self.attr_name() + ']', this.close_video);
|
108
|
+
}
|
109
|
+
|
110
|
+
return true;
|
111
|
+
},
|
112
|
+
|
113
|
+
// PATCH #3: turning on key up capture only when a reveal window is open
|
114
|
+
key_up_on : function (scope) {
|
115
|
+
var self = this;
|
116
|
+
|
117
|
+
// PATCH #1: fixing multiple keyup event trigger from single key press
|
118
|
+
self.S('body').off('keyup.fndtn.reveal').on('keyup.fndtn.reveal', function ( event ) {
|
119
|
+
var open_modal = self.S('[' + self.attr_name() + '].open'),
|
120
|
+
settings = open_modal.data(self.attr_name(true) + '-init') || self.settings ;
|
121
|
+
// PATCH #2: making sure that the close event can be called only while unlocked,
|
122
|
+
// so that multiple keyup.fndtn.reveal events don't prevent clean closing of the reveal window.
|
123
|
+
if ( settings && event.which === 27 && settings.close_on_esc && !self.locked) { // 27 is the keycode for the Escape key
|
124
|
+
self.close.call(self, open_modal);
|
125
|
+
}
|
126
|
+
});
|
127
|
+
|
128
|
+
return true;
|
129
|
+
},
|
130
|
+
|
131
|
+
// PATCH #3: turning on key up capture only when a reveal window is open
|
132
|
+
key_up_off : function (scope) {
|
133
|
+
this.S('body').off('keyup.fndtn.reveal');
|
134
|
+
return true;
|
135
|
+
},
|
136
|
+
|
137
|
+
|
138
|
+
open : function (target, ajax_settings) {
|
139
|
+
var self = this,
|
140
|
+
modal;
|
141
|
+
|
142
|
+
if (target) {
|
143
|
+
if (typeof target.selector !== 'undefined') {
|
144
|
+
// Find the named node; only use the first one found, since the rest of the code assumes there's only one node
|
145
|
+
modal = self.S('#' + target.data(self.data_attr('reveal-id'))).first();
|
146
|
+
} else {
|
147
|
+
modal = self.S(this.scope);
|
148
|
+
|
149
|
+
ajax_settings = target;
|
150
|
+
}
|
151
|
+
} else {
|
152
|
+
modal = self.S(this.scope);
|
153
|
+
}
|
154
|
+
|
155
|
+
var settings = modal.data(self.attr_name(true) + '-init');
|
156
|
+
settings = settings || this.settings;
|
157
|
+
|
158
|
+
|
159
|
+
if (modal.hasClass('open') && target.attr('data-reveal-id') == modal.attr('id')) {
|
160
|
+
return self.close(modal);
|
161
|
+
}
|
162
|
+
|
163
|
+
if (!modal.hasClass('open')) {
|
164
|
+
var open_modal = self.S('[' + self.attr_name() + '].open');
|
165
|
+
|
166
|
+
if (typeof modal.data('css-top') === 'undefined') {
|
167
|
+
modal.data('css-top', parseInt(modal.css('top'), 10))
|
168
|
+
.data('offset', this.cache_offset(modal));
|
169
|
+
}
|
170
|
+
|
171
|
+
this.key_up_on(modal); // PATCH #3: turning on key up capture only when a reveal window is open
|
172
|
+
modal.trigger('open').trigger('open.fndtn.reveal');
|
173
|
+
|
174
|
+
if (open_modal.length < 1) {
|
175
|
+
this.toggle_bg(modal, true);
|
176
|
+
}
|
177
|
+
|
178
|
+
if (typeof ajax_settings === 'string') {
|
179
|
+
ajax_settings = {
|
180
|
+
url: ajax_settings
|
181
|
+
};
|
182
|
+
}
|
183
|
+
|
184
|
+
if (typeof ajax_settings === 'undefined' || !ajax_settings.url) {
|
185
|
+
if (open_modal.length > 0) {
|
186
|
+
this.hide(open_modal, settings.css.close);
|
187
|
+
}
|
188
|
+
|
189
|
+
this.show(modal, settings.css.open);
|
190
|
+
} else {
|
191
|
+
var old_success = typeof ajax_settings.success !== 'undefined' ? ajax_settings.success : null;
|
192
|
+
|
193
|
+
$.extend(ajax_settings, {
|
194
|
+
success: function (data, textStatus, jqXHR) {
|
195
|
+
if ( $.isFunction(old_success) ) {
|
196
|
+
old_success(data, textStatus, jqXHR);
|
197
|
+
}
|
198
|
+
|
199
|
+
modal.html(data);
|
200
|
+
self.S(modal).foundation('section', 'reflow');
|
201
|
+
self.S(modal).children().foundation();
|
202
|
+
|
203
|
+
if (open_modal.length > 0) {
|
204
|
+
self.hide(open_modal, settings.css.close);
|
205
|
+
}
|
206
|
+
self.show(modal, settings.css.open);
|
207
|
+
}
|
208
|
+
});
|
209
|
+
|
210
|
+
$.ajax(ajax_settings);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
self.S(window).trigger('resize');
|
214
|
+
},
|
215
|
+
|
216
|
+
close : function (modal) {
|
217
|
+
var modal = modal && modal.length ? modal : this.S(this.scope),
|
218
|
+
open_modals = this.S('[' + this.attr_name() + '].open'),
|
219
|
+
settings = modal.data(this.attr_name(true) + '-init') || this.settings;
|
220
|
+
|
221
|
+
if (open_modals.length > 0) {
|
222
|
+
this.locked = true;
|
223
|
+
this.key_up_off(modal); // PATCH #3: turning on key up capture only when a reveal window is open
|
224
|
+
modal.trigger('close').trigger('close.fndtn.reveal');
|
225
|
+
this.toggle_bg(modal, false);
|
226
|
+
this.hide(open_modals, settings.css.close, settings);
|
227
|
+
}
|
228
|
+
},
|
229
|
+
|
230
|
+
close_targets : function () {
|
231
|
+
var base = '.' + this.settings.dismiss_modal_class;
|
232
|
+
|
233
|
+
if (this.settings.close_on_background_click) {
|
234
|
+
return base + ', .' + this.settings.bg_class;
|
235
|
+
}
|
236
|
+
|
237
|
+
return base;
|
238
|
+
},
|
239
|
+
|
240
|
+
toggle_bg : function (modal, state) {
|
241
|
+
if (this.S('.' + this.settings.bg_class).length === 0) {
|
242
|
+
this.settings.bg = $('<div />', {'class': this.settings.bg_class})
|
243
|
+
.appendTo('body').hide();
|
244
|
+
}
|
245
|
+
|
246
|
+
var visible = this.settings.bg.filter(':visible').length > 0;
|
247
|
+
if ( state != visible ) {
|
248
|
+
if ( state == undefined ? visible : !state ) {
|
249
|
+
this.hide(this.settings.bg);
|
250
|
+
} else {
|
251
|
+
this.show(this.settings.bg);
|
252
|
+
}
|
253
|
+
}
|
254
|
+
},
|
255
|
+
|
256
|
+
show : function (el, css) {
|
257
|
+
// is modal
|
258
|
+
if (css) {
|
259
|
+
var settings = el.data(this.attr_name(true) + '-init') || this.settings,
|
260
|
+
root_element = settings.root_element;
|
261
|
+
|
262
|
+
if (el.parent(root_element).length === 0) {
|
263
|
+
var placeholder = el.wrap('<div style="display: none;" />').parent();
|
264
|
+
|
265
|
+
el.on('closed.fndtn.reveal.wrapped', function() {
|
266
|
+
el.detach().appendTo(placeholder);
|
267
|
+
el.unwrap().unbind('closed.fndtn.reveal.wrapped');
|
268
|
+
});
|
269
|
+
|
270
|
+
el.detach().appendTo(root_element);
|
271
|
+
}
|
272
|
+
|
273
|
+
var animData = getAnimationData(settings.animation);
|
274
|
+
if (!animData.animate) {
|
275
|
+
this.locked = false;
|
276
|
+
}
|
277
|
+
if (animData.pop) {
|
278
|
+
css.top = $(window).scrollTop() - el.data('offset') + 'px';
|
279
|
+
var end_css = {
|
280
|
+
top: $(window).scrollTop() + el.data('css-top') + 'px',
|
281
|
+
opacity: 1
|
282
|
+
};
|
283
|
+
|
284
|
+
return setTimeout(function () {
|
285
|
+
return el
|
286
|
+
.css(css)
|
287
|
+
.animate(end_css, settings.animation_speed, 'linear', function () {
|
288
|
+
this.locked = false;
|
289
|
+
el.trigger('opened').trigger('opened.fndtn.reveal');
|
290
|
+
}.bind(this))
|
291
|
+
.addClass('open');
|
292
|
+
}.bind(this), settings.animation_speed / 2);
|
293
|
+
}
|
294
|
+
|
295
|
+
if (animData.fade) {
|
296
|
+
css.top = $(window).scrollTop() + el.data('css-top') + 'px';
|
297
|
+
var end_css = {opacity: 1};
|
298
|
+
|
299
|
+
return setTimeout(function () {
|
300
|
+
return el
|
301
|
+
.css(css)
|
302
|
+
.animate(end_css, settings.animation_speed, 'linear', function () {
|
303
|
+
this.locked = false;
|
304
|
+
el.trigger('opened').trigger('opened.fndtn.reveal');
|
305
|
+
}.bind(this))
|
306
|
+
.addClass('open');
|
307
|
+
}.bind(this), settings.animation_speed / 2);
|
308
|
+
}
|
309
|
+
|
310
|
+
return el.css(css).show().css({opacity: 1}).addClass('open').trigger('opened').trigger('opened.fndtn.reveal');
|
311
|
+
}
|
312
|
+
|
313
|
+
var settings = this.settings;
|
314
|
+
|
315
|
+
// should we animate the background?
|
316
|
+
if (getAnimationData(settings.animation).fade) {
|
317
|
+
return el.fadeIn(settings.animation_speed / 2);
|
318
|
+
}
|
319
|
+
|
320
|
+
this.locked = false;
|
321
|
+
|
322
|
+
return el.show();
|
323
|
+
},
|
324
|
+
|
325
|
+
hide : function (el, css) {
|
326
|
+
// is modal
|
327
|
+
if (css) {
|
328
|
+
var settings = el.data(this.attr_name(true) + '-init');
|
329
|
+
settings = settings || this.settings;
|
330
|
+
|
331
|
+
var animData = getAnimationData(settings.animation);
|
332
|
+
if (!animData.animate) {
|
333
|
+
this.locked = false;
|
334
|
+
}
|
335
|
+
if (animData.pop) {
|
336
|
+
var end_css = {
|
337
|
+
top: - $(window).scrollTop() - el.data('offset') + 'px',
|
338
|
+
opacity: 0
|
339
|
+
};
|
340
|
+
|
341
|
+
return setTimeout(function () {
|
342
|
+
return el
|
343
|
+
.animate(end_css, settings.animation_speed, 'linear', function () {
|
344
|
+
this.locked = false;
|
345
|
+
el.css(css).trigger('closed').trigger('closed.fndtn.reveal');
|
346
|
+
}.bind(this))
|
347
|
+
.removeClass('open');
|
348
|
+
}.bind(this), settings.animation_speed / 2);
|
349
|
+
}
|
350
|
+
|
351
|
+
if (animData.fade) {
|
352
|
+
var end_css = {opacity: 0};
|
353
|
+
|
354
|
+
return setTimeout(function () {
|
355
|
+
return el
|
356
|
+
.animate(end_css, settings.animation_speed, 'linear', function () {
|
357
|
+
this.locked = false;
|
358
|
+
el.css(css).trigger('closed').trigger('closed.fndtn.reveal');
|
359
|
+
}.bind(this))
|
360
|
+
.removeClass('open');
|
361
|
+
}.bind(this), settings.animation_speed / 2);
|
362
|
+
}
|
363
|
+
|
364
|
+
return el.hide().css(css).removeClass('open').trigger('closed').trigger('closed.fndtn.reveal');
|
365
|
+
}
|
366
|
+
|
367
|
+
var settings = this.settings;
|
368
|
+
|
369
|
+
// should we animate the background?
|
370
|
+
if (getAnimationData(settings.animation).fade) {
|
371
|
+
return el.fadeOut(settings.animation_speed / 2);
|
372
|
+
}
|
373
|
+
|
374
|
+
return el.hide();
|
375
|
+
},
|
376
|
+
|
377
|
+
close_video : function (e) {
|
378
|
+
var video = $('.flex-video', e.target),
|
379
|
+
iframe = $('iframe', video);
|
380
|
+
|
381
|
+
if (iframe.length > 0) {
|
382
|
+
iframe.attr('data-src', iframe[0].src);
|
383
|
+
iframe.attr('src', iframe.attr('src'));
|
384
|
+
video.hide();
|
385
|
+
}
|
386
|
+
},
|
387
|
+
|
388
|
+
open_video : function (e) {
|
389
|
+
var video = $('.flex-video', e.target),
|
390
|
+
iframe = video.find('iframe');
|
391
|
+
|
392
|
+
if (iframe.length > 0) {
|
393
|
+
var data_src = iframe.attr('data-src');
|
394
|
+
if (typeof data_src === 'string') {
|
395
|
+
iframe[0].src = iframe.attr('data-src');
|
396
|
+
} else {
|
397
|
+
var src = iframe[0].src;
|
398
|
+
iframe[0].src = undefined;
|
399
|
+
iframe[0].src = src;
|
400
|
+
}
|
401
|
+
video.show();
|
402
|
+
}
|
403
|
+
},
|
404
|
+
|
405
|
+
data_attr: function (str) {
|
406
|
+
if (this.namespace.length > 0) {
|
407
|
+
return this.namespace + '-' + str;
|
408
|
+
}
|
409
|
+
|
410
|
+
return str;
|
411
|
+
},
|
412
|
+
|
413
|
+
cache_offset : function (modal) {
|
414
|
+
var offset = modal.show().height() + parseInt(modal.css('top'), 10);
|
415
|
+
|
416
|
+
modal.hide();
|
417
|
+
|
418
|
+
return offset;
|
419
|
+
},
|
420
|
+
|
421
|
+
off : function () {
|
422
|
+
$(this.scope).off('.fndtn.reveal');
|
423
|
+
},
|
424
|
+
|
425
|
+
reflow : function () {}
|
426
|
+
};
|
427
|
+
|
428
|
+
/*
|
429
|
+
* getAnimationData('popAndFade') // {animate: true, pop: true, fade: true}
|
430
|
+
* getAnimationData('fade') // {animate: true, pop: false, fade: true}
|
431
|
+
* getAnimationData('pop') // {animate: true, pop: true, fade: false}
|
432
|
+
* getAnimationData('foo') // {animate: false, pop: false, fade: false}
|
433
|
+
* getAnimationData(null) // {animate: false, pop: false, fade: false}
|
434
|
+
*/
|
435
|
+
function getAnimationData(str) {
|
436
|
+
var fade = /fade/i.test(str);
|
437
|
+
var pop = /pop/i.test(str);
|
438
|
+
return {
|
439
|
+
animate: fade || pop,
|
440
|
+
pop: pop,
|
441
|
+
fade: fade
|
442
|
+
};
|
443
|
+
}
|
444
|
+
}(jQuery, window, window.document));
|
@@ -0,0 +1,239 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.slider = {
|
5
|
+
name : 'slider',
|
6
|
+
|
7
|
+
version : '5.4.6',
|
8
|
+
|
9
|
+
settings: {
|
10
|
+
start: 0,
|
11
|
+
end: 100,
|
12
|
+
step: 1,
|
13
|
+
initial: null,
|
14
|
+
display_selector: '',
|
15
|
+
vertical: false,
|
16
|
+
on_change: function(){}
|
17
|
+
},
|
18
|
+
|
19
|
+
cache : {},
|
20
|
+
|
21
|
+
init : function (scope, method, options) {
|
22
|
+
Foundation.inherit(this,'throttle');
|
23
|
+
this.bindings(method, options);
|
24
|
+
this.reflow();
|
25
|
+
},
|
26
|
+
|
27
|
+
events : function() {
|
28
|
+
var self = this;
|
29
|
+
|
30
|
+
$(this.scope)
|
31
|
+
.off('.slider')
|
32
|
+
.on('mousedown.fndtn.slider touchstart.fndtn.slider pointerdown.fndtn.slider',
|
33
|
+
'[' + self.attr_name() + ']:not(.disabled, [disabled]) .range-slider-handle', function(e) {
|
34
|
+
if (!self.cache.active) {
|
35
|
+
e.preventDefault();
|
36
|
+
self.set_active_slider($(e.target));
|
37
|
+
}
|
38
|
+
})
|
39
|
+
.on('mousemove.fndtn.slider touchmove.fndtn.slider pointermove.fndtn.slider', function(e) {
|
40
|
+
if (!!self.cache.active) {
|
41
|
+
e.preventDefault();
|
42
|
+
if ($.data(self.cache.active[0], 'settings').vertical) {
|
43
|
+
var scroll_offset = 0;
|
44
|
+
if (!e.pageY) {
|
45
|
+
scroll_offset = window.scrollY;
|
46
|
+
}
|
47
|
+
self.calculate_position(self.cache.active, (e.pageY ||
|
48
|
+
e.originalEvent.clientY ||
|
49
|
+
e.originalEvent.touches[0].clientY ||
|
50
|
+
e.currentPoint.y)
|
51
|
+
+ scroll_offset);
|
52
|
+
} else {
|
53
|
+
self.calculate_position(self.cache.active, e.pageX ||
|
54
|
+
e.originalEvent.clientX ||
|
55
|
+
e.originalEvent.touches[0].clientX ||
|
56
|
+
e.currentPoint.x);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
})
|
60
|
+
.on('mouseup.fndtn.slider touchend.fndtn.slider pointerup.fndtn.slider', function(e) {
|
61
|
+
self.remove_active_slider();
|
62
|
+
})
|
63
|
+
.on('change.fndtn.slider', function(e) {
|
64
|
+
self.settings.on_change();
|
65
|
+
});
|
66
|
+
|
67
|
+
self.S(window)
|
68
|
+
.on('resize.fndtn.slider', self.throttle(function(e) {
|
69
|
+
self.reflow();
|
70
|
+
}, 300));
|
71
|
+
},
|
72
|
+
|
73
|
+
set_active_slider : function($handle) {
|
74
|
+
this.cache.active = $handle;
|
75
|
+
},
|
76
|
+
|
77
|
+
remove_active_slider : function() {
|
78
|
+
this.cache.active = null;
|
79
|
+
},
|
80
|
+
|
81
|
+
calculate_position : function($handle, cursor_x) {
|
82
|
+
var self = this,
|
83
|
+
settings = $.data($handle[0], 'settings'),
|
84
|
+
handle_l = $.data($handle[0], 'handle_l'),
|
85
|
+
handle_o = $.data($handle[0], 'handle_o'),
|
86
|
+
bar_l = $.data($handle[0], 'bar_l'),
|
87
|
+
bar_o = $.data($handle[0], 'bar_o');
|
88
|
+
|
89
|
+
requestAnimationFrame(function(){
|
90
|
+
var pct;
|
91
|
+
|
92
|
+
if (Foundation.rtl && !settings.vertical) {
|
93
|
+
pct = self.limit_to(((bar_o+bar_l-cursor_x)/bar_l),0,1);
|
94
|
+
} else {
|
95
|
+
pct = self.limit_to(((cursor_x-bar_o)/bar_l),0,1);
|
96
|
+
}
|
97
|
+
|
98
|
+
pct = settings.vertical ? 1-pct : pct;
|
99
|
+
|
100
|
+
var norm = self.normalized_value(pct, settings.start, settings.end, settings.step);
|
101
|
+
|
102
|
+
self.set_ui($handle, norm);
|
103
|
+
});
|
104
|
+
},
|
105
|
+
|
106
|
+
set_ui : function($handle, value) {
|
107
|
+
var settings = $.data($handle[0], 'settings'),
|
108
|
+
handle_l = $.data($handle[0], 'handle_l'),
|
109
|
+
bar_l = $.data($handle[0], 'bar_l'),
|
110
|
+
norm_pct = this.normalized_percentage(value, settings.start, settings.end),
|
111
|
+
handle_offset = norm_pct*(bar_l-handle_l)-1,
|
112
|
+
progress_bar_length = norm_pct*100;
|
113
|
+
|
114
|
+
if (Foundation.rtl && !settings.vertical) {
|
115
|
+
handle_offset = -handle_offset;
|
116
|
+
}
|
117
|
+
|
118
|
+
handle_offset = settings.vertical ? -handle_offset + bar_l - handle_l + 1 : handle_offset;
|
119
|
+
this.set_translate($handle, handle_offset, settings.vertical);
|
120
|
+
|
121
|
+
if (settings.vertical) {
|
122
|
+
$handle.siblings('.range-slider-active-segment').css('height', progress_bar_length + '%');
|
123
|
+
} else {
|
124
|
+
$handle.siblings('.range-slider-active-segment').css('width', progress_bar_length + '%');
|
125
|
+
}
|
126
|
+
|
127
|
+
$handle.parent().attr(this.attr_name(), value).trigger('change').trigger('change.fndtn.slider');
|
128
|
+
|
129
|
+
$handle.parent().children('input[type=hidden]').val(value);
|
130
|
+
|
131
|
+
if (!$handle[0].hasAttribute('aria-valuemin')) {
|
132
|
+
$handle.attr({
|
133
|
+
'aria-valuemin': settings.start,
|
134
|
+
'aria-valuemax': settings.end,
|
135
|
+
});
|
136
|
+
}
|
137
|
+
$handle.attr('aria-valuenow', value);
|
138
|
+
|
139
|
+
if (settings.display_selector != '') {
|
140
|
+
$(settings.display_selector).each(function(){
|
141
|
+
if (this.hasOwnProperty('value')) {
|
142
|
+
$(this).val(value);
|
143
|
+
} else {
|
144
|
+
$(this).text(value);
|
145
|
+
}
|
146
|
+
});
|
147
|
+
}
|
148
|
+
|
149
|
+
},
|
150
|
+
|
151
|
+
normalized_percentage : function(val, start, end) {
|
152
|
+
return Math.min(1, (val - start)/(end - start));
|
153
|
+
},
|
154
|
+
|
155
|
+
normalized_value : function(val, start, end, step) {
|
156
|
+
var range = end - start,
|
157
|
+
point = val*range,
|
158
|
+
mod = (point-(point%step)) / step,
|
159
|
+
rem = point % step,
|
160
|
+
round = ( rem >= step*0.5 ? step : 0);
|
161
|
+
return (mod*step + round) + start;
|
162
|
+
},
|
163
|
+
|
164
|
+
set_translate : function(ele, offset, vertical) {
|
165
|
+
if (vertical) {
|
166
|
+
$(ele)
|
167
|
+
.css('-webkit-transform', 'translateY('+offset+'px)')
|
168
|
+
.css('-moz-transform', 'translateY('+offset+'px)')
|
169
|
+
.css('-ms-transform', 'translateY('+offset+'px)')
|
170
|
+
.css('-o-transform', 'translateY('+offset+'px)')
|
171
|
+
.css('transform', 'translateY('+offset+'px)');
|
172
|
+
} else {
|
173
|
+
$(ele)
|
174
|
+
.css('-webkit-transform', 'translateX('+offset+'px)')
|
175
|
+
.css('-moz-transform', 'translateX('+offset+'px)')
|
176
|
+
.css('-ms-transform', 'translateX('+offset+'px)')
|
177
|
+
.css('-o-transform', 'translateX('+offset+'px)')
|
178
|
+
.css('transform', 'translateX('+offset+'px)');
|
179
|
+
}
|
180
|
+
},
|
181
|
+
|
182
|
+
limit_to : function(val, min, max) {
|
183
|
+
return Math.min(Math.max(val, min), max);
|
184
|
+
},
|
185
|
+
|
186
|
+
initialize_settings : function(handle) {
|
187
|
+
var settings = $.extend({}, this.settings, this.data_options($(handle).parent()));
|
188
|
+
|
189
|
+
if (settings.vertical) {
|
190
|
+
$.data(handle, 'bar_o', $(handle).parent().offset().top);
|
191
|
+
$.data(handle, 'bar_l', $(handle).parent().outerHeight());
|
192
|
+
$.data(handle, 'handle_o', $(handle).offset().top);
|
193
|
+
$.data(handle, 'handle_l', $(handle).outerHeight());
|
194
|
+
} else {
|
195
|
+
$.data(handle, 'bar_o', $(handle).parent().offset().left);
|
196
|
+
$.data(handle, 'bar_l', $(handle).parent().outerWidth());
|
197
|
+
$.data(handle, 'handle_o', $(handle).offset().left);
|
198
|
+
$.data(handle, 'handle_l', $(handle).outerWidth());
|
199
|
+
}
|
200
|
+
|
201
|
+
$.data(handle, 'bar', $(handle).parent());
|
202
|
+
$.data(handle, 'settings', settings);
|
203
|
+
},
|
204
|
+
|
205
|
+
set_initial_position : function($ele) {
|
206
|
+
var settings = $.data($ele.children('.range-slider-handle')[0], 'settings'),
|
207
|
+
initial = (!!settings.initial ? settings.initial : Math.floor((settings.end-settings.start)*0.5/settings.step)*settings.step+settings.start),
|
208
|
+
$handle = $ele.children('.range-slider-handle');
|
209
|
+
this.set_ui($handle, initial);
|
210
|
+
},
|
211
|
+
|
212
|
+
set_value : function(value) {
|
213
|
+
var self = this;
|
214
|
+
$('[' + self.attr_name() + ']', this.scope).each(function(){
|
215
|
+
$(this).attr(self.attr_name(), value);
|
216
|
+
});
|
217
|
+
if (!!$(this.scope).attr(self.attr_name())) {
|
218
|
+
$(this.scope).attr(self.attr_name(), value);
|
219
|
+
}
|
220
|
+
self.reflow();
|
221
|
+
},
|
222
|
+
|
223
|
+
reflow : function() {
|
224
|
+
var self = this;
|
225
|
+
self.S('[' + this.attr_name() + ']').each(function() {
|
226
|
+
var handle = $(this).children('.range-slider-handle')[0],
|
227
|
+
val = $(this).attr(self.attr_name());
|
228
|
+
self.initialize_settings(handle);
|
229
|
+
|
230
|
+
if (val) {
|
231
|
+
self.set_ui($(handle), parseFloat(val));
|
232
|
+
} else {
|
233
|
+
self.set_initial_position($(this));
|
234
|
+
}
|
235
|
+
});
|
236
|
+
}
|
237
|
+
};
|
238
|
+
|
239
|
+
}(jQuery, window, window.document));
|