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