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,531 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.clearing = {
|
5
|
+
name : 'clearing',
|
6
|
+
|
7
|
+
version: '5.2.2',
|
8
|
+
|
9
|
+
settings : {
|
10
|
+
templates : {
|
11
|
+
viewing : '<a href="#" class="clearing-close">×</a>' +
|
12
|
+
'<div class="visible-img" style="display: none"><div class="clearing-touch-label"></div><img src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D" alt="" />' +
|
13
|
+
'<p class="clearing-caption"></p><a href="#" class="clearing-main-prev"><span></span></a>' +
|
14
|
+
'<a href="#" class="clearing-main-next"><span></span></a></div>'
|
15
|
+
},
|
16
|
+
|
17
|
+
// comma delimited list of selectors that, on click, will close clearing,
|
18
|
+
// add 'div.clearing-blackout, div.visible-img' to close on background click
|
19
|
+
close_selectors : '.clearing-close',
|
20
|
+
|
21
|
+
touch_label : '',
|
22
|
+
|
23
|
+
// event initializers and locks
|
24
|
+
init : false,
|
25
|
+
locked : false
|
26
|
+
},
|
27
|
+
|
28
|
+
init : function (scope, method, options) {
|
29
|
+
var self = this;
|
30
|
+
Foundation.inherit(this, 'throttle image_loaded');
|
31
|
+
|
32
|
+
this.bindings(method, options);
|
33
|
+
|
34
|
+
if (self.S(this.scope).is('[' + this.attr_name() + ']')) {
|
35
|
+
this.assemble(self.S('li', this.scope));
|
36
|
+
} else {
|
37
|
+
self.S('[' + this.attr_name() + ']', this.scope).each(function () {
|
38
|
+
self.assemble(self.S('li', this));
|
39
|
+
});
|
40
|
+
}
|
41
|
+
},
|
42
|
+
|
43
|
+
events : function (scope) {
|
44
|
+
var self = this,
|
45
|
+
S = self.S;
|
46
|
+
|
47
|
+
if ($('.scroll-container').length > 0) {
|
48
|
+
this.scope = $('.scroll-container');
|
49
|
+
}
|
50
|
+
|
51
|
+
S(this.scope)
|
52
|
+
.off('.clearing')
|
53
|
+
.on('click.fndtn.clearing', 'ul[' + this.attr_name() + '] li',
|
54
|
+
function (e, current, target) {
|
55
|
+
var current = current || S(this),
|
56
|
+
target = target || current,
|
57
|
+
next = current.next('li'),
|
58
|
+
settings = current.closest('[' + self.attr_name() + ']').data(self.attr_name(true) + '-init'),
|
59
|
+
image = S(e.target);
|
60
|
+
|
61
|
+
e.preventDefault();
|
62
|
+
|
63
|
+
if (!settings) {
|
64
|
+
self.init();
|
65
|
+
settings = current.closest('[' + self.attr_name() + ']').data(self.attr_name(true) + '-init');
|
66
|
+
}
|
67
|
+
|
68
|
+
// if clearing is open and the current image is
|
69
|
+
// clicked, go to the next image in sequence
|
70
|
+
if (target.hasClass('visible') &&
|
71
|
+
current[0] === target[0] &&
|
72
|
+
next.length > 0 && self.is_open(current)) {
|
73
|
+
target = next;
|
74
|
+
image = S('img', target);
|
75
|
+
}
|
76
|
+
|
77
|
+
// set current and target to the clicked li if not otherwise defined.
|
78
|
+
self.open(image, current, target);
|
79
|
+
self.update_paddles(target);
|
80
|
+
})
|
81
|
+
|
82
|
+
.on('click.fndtn.clearing', '.clearing-main-next',
|
83
|
+
function (e) { self.nav(e, 'next') })
|
84
|
+
.on('click.fndtn.clearing', '.clearing-main-prev',
|
85
|
+
function (e) { self.nav(e, 'prev') })
|
86
|
+
.on('click.fndtn.clearing', this.settings.close_selectors,
|
87
|
+
function (e) { Foundation.libs.clearing.close(e, this) });
|
88
|
+
|
89
|
+
$(document).on('keydown.fndtn.clearing',
|
90
|
+
function (e) { self.keydown(e) });
|
91
|
+
|
92
|
+
S(window).off('.clearing').on('resize.fndtn.clearing',
|
93
|
+
function () { self.resize() });
|
94
|
+
|
95
|
+
this.swipe_events(scope);
|
96
|
+
},
|
97
|
+
|
98
|
+
swipe_events : function (scope) {
|
99
|
+
var self = this,
|
100
|
+
S = self.S;
|
101
|
+
|
102
|
+
S(this.scope)
|
103
|
+
.on('touchstart.fndtn.clearing', '.visible-img', function(e) {
|
104
|
+
if (!e.touches) { e = e.originalEvent; }
|
105
|
+
var data = {
|
106
|
+
start_page_x: e.touches[0].pageX,
|
107
|
+
start_page_y: e.touches[0].pageY,
|
108
|
+
start_time: (new Date()).getTime(),
|
109
|
+
delta_x: 0,
|
110
|
+
is_scrolling: undefined
|
111
|
+
};
|
112
|
+
|
113
|
+
S(this).data('swipe-transition', data);
|
114
|
+
e.stopPropagation();
|
115
|
+
})
|
116
|
+
.on('touchmove.fndtn.clearing', '.visible-img', function(e) {
|
117
|
+
if (!e.touches) { e = e.originalEvent; }
|
118
|
+
// Ignore pinch/zoom events
|
119
|
+
if(e.touches.length > 1 || e.scale && e.scale !== 1) return;
|
120
|
+
|
121
|
+
var data = S(this).data('swipe-transition');
|
122
|
+
|
123
|
+
if (typeof data === 'undefined') {
|
124
|
+
data = {};
|
125
|
+
}
|
126
|
+
|
127
|
+
data.delta_x = e.touches[0].pageX - data.start_page_x;
|
128
|
+
|
129
|
+
if ( typeof data.is_scrolling === 'undefined') {
|
130
|
+
data.is_scrolling = !!( data.is_scrolling || Math.abs(data.delta_x) < Math.abs(e.touches[0].pageY - data.start_page_y) );
|
131
|
+
}
|
132
|
+
|
133
|
+
if (!data.is_scrolling && !data.active) {
|
134
|
+
e.preventDefault();
|
135
|
+
var direction = (data.delta_x < 0) ? 'next' : 'prev';
|
136
|
+
data.active = true;
|
137
|
+
self.nav(e, direction);
|
138
|
+
}
|
139
|
+
})
|
140
|
+
.on('touchend.fndtn.clearing', '.visible-img', function(e) {
|
141
|
+
S(this).data('swipe-transition', {});
|
142
|
+
e.stopPropagation();
|
143
|
+
});
|
144
|
+
},
|
145
|
+
|
146
|
+
assemble : function ($li) {
|
147
|
+
var $el = $li.parent();
|
148
|
+
|
149
|
+
if ($el.parent().hasClass('carousel')) {
|
150
|
+
return;
|
151
|
+
}
|
152
|
+
|
153
|
+
$el.after('<div id="foundationClearingHolder"></div>');
|
154
|
+
var grid = $el.detach();
|
155
|
+
var grid_outerHTML = '';
|
156
|
+
if (grid[0] == null) {
|
157
|
+
return;
|
158
|
+
} else {
|
159
|
+
grid_outerHTML = grid[0].outerHTML;
|
160
|
+
}
|
161
|
+
|
162
|
+
var holder = this.S('#foundationClearingHolder'),
|
163
|
+
settings = $el.data(this.attr_name(true) + '-init'),
|
164
|
+
grid = $el.detach(),
|
165
|
+
data = {
|
166
|
+
grid: '<div class="carousel">' + grid_outerHTML + '</div>',
|
167
|
+
viewing: settings.templates.viewing
|
168
|
+
},
|
169
|
+
wrapper = '<div class="clearing-assembled"><div>' + data.viewing +
|
170
|
+
data.grid + '</div></div>',
|
171
|
+
touch_label = this.settings.touch_label;
|
172
|
+
|
173
|
+
if (Modernizr.touch) {
|
174
|
+
wrapper = $(wrapper).find('.clearing-touch-label').html(touch_label).end();
|
175
|
+
}
|
176
|
+
|
177
|
+
holder.after(wrapper).remove();
|
178
|
+
},
|
179
|
+
|
180
|
+
open : function ($image, current, target) {
|
181
|
+
var self = this,
|
182
|
+
body = $(document.body),
|
183
|
+
root = target.closest('.clearing-assembled'),
|
184
|
+
container = self.S('div', root).first(),
|
185
|
+
visible_image = self.S('.visible-img', container),
|
186
|
+
image = self.S('img', visible_image).not($image),
|
187
|
+
label = self.S('.clearing-touch-label', container),
|
188
|
+
error = false;
|
189
|
+
|
190
|
+
image.error(function () {
|
191
|
+
error = true;
|
192
|
+
});
|
193
|
+
|
194
|
+
function startLoad() {
|
195
|
+
setTimeout(function () {
|
196
|
+
this.image_loaded(image, function () {
|
197
|
+
if (image.outerWidth() === 1 && !error) {
|
198
|
+
startLoad.call(this);
|
199
|
+
} else {
|
200
|
+
cb.call(this, image);
|
201
|
+
}
|
202
|
+
}.bind(this));
|
203
|
+
}.bind(this), 50);
|
204
|
+
}
|
205
|
+
|
206
|
+
function cb (image) {
|
207
|
+
var $image = $(image);
|
208
|
+
image.css('visibility', 'visible');
|
209
|
+
// toggle the gallery
|
210
|
+
body.css('overflow', 'hidden');
|
211
|
+
root.addClass('clearing-blackout');
|
212
|
+
container.addClass('clearing-container');
|
213
|
+
visible_image.show();
|
214
|
+
this.fix_height(target)
|
215
|
+
.caption(self.S('.clearing-caption', visible_image), self.S('img', target))
|
216
|
+
.center_and_label(image, label)
|
217
|
+
.shift(current, target, function () {
|
218
|
+
target.siblings().removeClass('visible');
|
219
|
+
target.addClass('visible');
|
220
|
+
});
|
221
|
+
}
|
222
|
+
|
223
|
+
if (!this.locked()) {
|
224
|
+
// set the image to the selected thumbnail
|
225
|
+
image
|
226
|
+
.attr('src', this.load($image))
|
227
|
+
.css('visibility', 'hidden');
|
228
|
+
|
229
|
+
startLoad.call(this);
|
230
|
+
|
231
|
+
}
|
232
|
+
},
|
233
|
+
|
234
|
+
close : function (e, el) {
|
235
|
+
e.preventDefault();
|
236
|
+
|
237
|
+
var root = (function (target) {
|
238
|
+
if (/blackout/.test(target.selector)) {
|
239
|
+
return target;
|
240
|
+
} else {
|
241
|
+
return target.closest('.clearing-blackout');
|
242
|
+
}
|
243
|
+
}($(el))),
|
244
|
+
body = $(document.body), container, visible_image;
|
245
|
+
|
246
|
+
if (el === e.target && root) {
|
247
|
+
body.css('overflow', '');
|
248
|
+
container = $('div', root).first();
|
249
|
+
visible_image = $('.visible-img', container);
|
250
|
+
this.settings.prev_index = 0;
|
251
|
+
$('ul[' + this.attr_name() + ']', root)
|
252
|
+
.attr('style', '').closest('.clearing-blackout')
|
253
|
+
.removeClass('clearing-blackout');
|
254
|
+
container.removeClass('clearing-container');
|
255
|
+
visible_image.hide();
|
256
|
+
}
|
257
|
+
|
258
|
+
return false;
|
259
|
+
},
|
260
|
+
|
261
|
+
is_open : function (current) {
|
262
|
+
return current.parent().prop('style').length > 0;
|
263
|
+
},
|
264
|
+
|
265
|
+
keydown : function (e) {
|
266
|
+
var clearing = $('.clearing-blackout ul[' + this.attr_name() + ']'),
|
267
|
+
NEXT_KEY = this.rtl ? 37 : 39,
|
268
|
+
PREV_KEY = this.rtl ? 39 : 37,
|
269
|
+
ESC_KEY = 27;
|
270
|
+
|
271
|
+
if (e.which === NEXT_KEY) this.go(clearing, 'next');
|
272
|
+
if (e.which === PREV_KEY) this.go(clearing, 'prev');
|
273
|
+
if (e.which === ESC_KEY) this.S('a.clearing-close').trigger('click');
|
274
|
+
},
|
275
|
+
|
276
|
+
nav : function (e, direction) {
|
277
|
+
var clearing = $('ul[' + this.attr_name() + ']', '.clearing-blackout');
|
278
|
+
|
279
|
+
e.preventDefault();
|
280
|
+
this.go(clearing, direction);
|
281
|
+
},
|
282
|
+
|
283
|
+
resize : function () {
|
284
|
+
var image = $('img', '.clearing-blackout .visible-img'),
|
285
|
+
label = $('.clearing-touch-label', '.clearing-blackout');
|
286
|
+
|
287
|
+
if (image.length) {
|
288
|
+
this.center_and_label(image, label);
|
289
|
+
}
|
290
|
+
},
|
291
|
+
|
292
|
+
// visual adjustments
|
293
|
+
fix_height : function (target) {
|
294
|
+
var lis = target.parent().children(),
|
295
|
+
self = this;
|
296
|
+
|
297
|
+
lis.each(function () {
|
298
|
+
var li = self.S(this),
|
299
|
+
image = li.find('img');
|
300
|
+
|
301
|
+
if (li.height() > image.outerHeight()) {
|
302
|
+
li.addClass('fix-height');
|
303
|
+
}
|
304
|
+
})
|
305
|
+
.closest('ul')
|
306
|
+
.width(lis.length * 100 + '%');
|
307
|
+
|
308
|
+
return this;
|
309
|
+
},
|
310
|
+
|
311
|
+
update_paddles : function (target) {
|
312
|
+
var visible_image = target
|
313
|
+
.closest('.carousel')
|
314
|
+
.siblings('.visible-img');
|
315
|
+
|
316
|
+
if (target.next().length > 0) {
|
317
|
+
this.S('.clearing-main-next', visible_image)
|
318
|
+
.removeClass('disabled');
|
319
|
+
} else {
|
320
|
+
this.S('.clearing-main-next', visible_image)
|
321
|
+
.addClass('disabled');
|
322
|
+
}
|
323
|
+
|
324
|
+
if (target.prev().length > 0) {
|
325
|
+
this.S('.clearing-main-prev', visible_image)
|
326
|
+
.removeClass('disabled');
|
327
|
+
} else {
|
328
|
+
this.S('.clearing-main-prev', visible_image)
|
329
|
+
.addClass('disabled');
|
330
|
+
}
|
331
|
+
},
|
332
|
+
|
333
|
+
center_and_label : function (target, label) {
|
334
|
+
if (!this.rtl) {
|
335
|
+
target.css({
|
336
|
+
marginLeft : -(target.outerWidth() / 2),
|
337
|
+
marginTop : -(target.outerHeight() / 2)
|
338
|
+
});
|
339
|
+
|
340
|
+
if (label.length > 0) {
|
341
|
+
label.css({
|
342
|
+
marginLeft : -(label.outerWidth() / 2),
|
343
|
+
marginTop : -(target.outerHeight() / 2)-label.outerHeight()-10
|
344
|
+
});
|
345
|
+
}
|
346
|
+
} else {
|
347
|
+
target.css({
|
348
|
+
marginRight : -(target.outerWidth() / 2),
|
349
|
+
marginTop : -(target.outerHeight() / 2),
|
350
|
+
left: 'auto',
|
351
|
+
right: '50%'
|
352
|
+
});
|
353
|
+
|
354
|
+
if (label.length > 0) {
|
355
|
+
label.css({
|
356
|
+
marginRight : -(label.outerWidth() / 2),
|
357
|
+
marginTop : -(target.outerHeight() / 2)-label.outerHeight()-10,
|
358
|
+
left: 'auto',
|
359
|
+
right: '50%'
|
360
|
+
});
|
361
|
+
}
|
362
|
+
}
|
363
|
+
return this;
|
364
|
+
},
|
365
|
+
|
366
|
+
// image loading and preloading
|
367
|
+
|
368
|
+
load : function ($image) {
|
369
|
+
if ($image[0].nodeName === "A") {
|
370
|
+
var href = $image.attr('href');
|
371
|
+
} else {
|
372
|
+
var href = $image.parent().attr('href');
|
373
|
+
}
|
374
|
+
|
375
|
+
this.preload($image);
|
376
|
+
|
377
|
+
if (href) return href;
|
378
|
+
return $image.attr('src');
|
379
|
+
},
|
380
|
+
|
381
|
+
preload : function ($image) {
|
382
|
+
this
|
383
|
+
.img($image.closest('li').next())
|
384
|
+
.img($image.closest('li').prev());
|
385
|
+
},
|
386
|
+
|
387
|
+
img : function (img) {
|
388
|
+
if (img.length) {
|
389
|
+
var new_img = new Image(),
|
390
|
+
new_a = this.S('a', img);
|
391
|
+
|
392
|
+
if (new_a.length) {
|
393
|
+
new_img.src = new_a.attr('href');
|
394
|
+
} else {
|
395
|
+
new_img.src = this.S('img', img).attr('src');
|
396
|
+
}
|
397
|
+
}
|
398
|
+
return this;
|
399
|
+
},
|
400
|
+
|
401
|
+
// image caption
|
402
|
+
|
403
|
+
caption : function (container, $image) {
|
404
|
+
var caption = $image.attr('data-caption');
|
405
|
+
|
406
|
+
if (caption) {
|
407
|
+
container
|
408
|
+
.html(caption)
|
409
|
+
.show();
|
410
|
+
} else {
|
411
|
+
container
|
412
|
+
.text('')
|
413
|
+
.hide();
|
414
|
+
}
|
415
|
+
return this;
|
416
|
+
},
|
417
|
+
|
418
|
+
// directional methods
|
419
|
+
|
420
|
+
go : function ($ul, direction) {
|
421
|
+
var current = this.S('.visible', $ul),
|
422
|
+
target = current[direction]();
|
423
|
+
|
424
|
+
if (target.length) {
|
425
|
+
this.S('img', target)
|
426
|
+
.trigger('click', [current, target]);
|
427
|
+
}
|
428
|
+
},
|
429
|
+
|
430
|
+
shift : function (current, target, callback) {
|
431
|
+
var clearing = target.parent(),
|
432
|
+
old_index = this.settings.prev_index || target.index(),
|
433
|
+
direction = this.direction(clearing, current, target),
|
434
|
+
dir = this.rtl ? 'right' : 'left',
|
435
|
+
left = parseInt(clearing.css('left'), 10),
|
436
|
+
width = target.outerWidth(),
|
437
|
+
skip_shift;
|
438
|
+
|
439
|
+
var dir_obj = {};
|
440
|
+
|
441
|
+
// we use jQuery animate instead of CSS transitions because we
|
442
|
+
// need a callback to unlock the next animation
|
443
|
+
// needs support for RTL **
|
444
|
+
if (target.index() !== old_index && !/skip/.test(direction)){
|
445
|
+
if (/left/.test(direction)) {
|
446
|
+
this.lock();
|
447
|
+
dir_obj[dir] = left + width;
|
448
|
+
clearing.animate(dir_obj, 300, this.unlock());
|
449
|
+
} else if (/right/.test(direction)) {
|
450
|
+
this.lock();
|
451
|
+
dir_obj[dir] = left - width;
|
452
|
+
clearing.animate(dir_obj, 300, this.unlock());
|
453
|
+
}
|
454
|
+
} else if (/skip/.test(direction)) {
|
455
|
+
// the target image is not adjacent to the current image, so
|
456
|
+
// do we scroll right or not
|
457
|
+
skip_shift = target.index() - this.settings.up_count;
|
458
|
+
this.lock();
|
459
|
+
|
460
|
+
if (skip_shift > 0) {
|
461
|
+
dir_obj[dir] = -(skip_shift * width);
|
462
|
+
clearing.animate(dir_obj, 300, this.unlock());
|
463
|
+
} else {
|
464
|
+
dir_obj[dir] = 0;
|
465
|
+
clearing.animate(dir_obj, 300, this.unlock());
|
466
|
+
}
|
467
|
+
}
|
468
|
+
|
469
|
+
callback();
|
470
|
+
},
|
471
|
+
|
472
|
+
direction : function ($el, current, target) {
|
473
|
+
var lis = this.S('li', $el),
|
474
|
+
li_width = lis.outerWidth() + (lis.outerWidth() / 4),
|
475
|
+
up_count = Math.floor(this.S('.clearing-container').outerWidth() / li_width) - 1,
|
476
|
+
target_index = lis.index(target),
|
477
|
+
response;
|
478
|
+
|
479
|
+
this.settings.up_count = up_count;
|
480
|
+
|
481
|
+
if (this.adjacent(this.settings.prev_index, target_index)) {
|
482
|
+
if ((target_index > up_count)
|
483
|
+
&& target_index > this.settings.prev_index) {
|
484
|
+
response = 'right';
|
485
|
+
} else if ((target_index > up_count - 1)
|
486
|
+
&& target_index <= this.settings.prev_index) {
|
487
|
+
response = 'left';
|
488
|
+
} else {
|
489
|
+
response = false;
|
490
|
+
}
|
491
|
+
} else {
|
492
|
+
response = 'skip';
|
493
|
+
}
|
494
|
+
|
495
|
+
this.settings.prev_index = target_index;
|
496
|
+
|
497
|
+
return response;
|
498
|
+
},
|
499
|
+
|
500
|
+
adjacent : function (current_index, target_index) {
|
501
|
+
for (var i = target_index + 1; i >= target_index - 1; i--) {
|
502
|
+
if (i === current_index) return true;
|
503
|
+
}
|
504
|
+
return false;
|
505
|
+
},
|
506
|
+
|
507
|
+
// lock management
|
508
|
+
|
509
|
+
lock : function () {
|
510
|
+
this.settings.locked = true;
|
511
|
+
},
|
512
|
+
|
513
|
+
unlock : function () {
|
514
|
+
this.settings.locked = false;
|
515
|
+
},
|
516
|
+
|
517
|
+
locked : function () {
|
518
|
+
return this.settings.locked;
|
519
|
+
},
|
520
|
+
|
521
|
+
off : function () {
|
522
|
+
this.S(this.scope).off('.fndtn.clearing');
|
523
|
+
this.S(window).off('.fndtn.clearing');
|
524
|
+
},
|
525
|
+
|
526
|
+
reflow : function () {
|
527
|
+
this.init();
|
528
|
+
}
|
529
|
+
};
|
530
|
+
|
531
|
+
}(jQuery, this, this.document));
|