anything-slider 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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/anything-slider.gemspec +24 -0
- data/app/assets/images/default.png +0 -0
- data/app/assets/javascripts/jquery.anythingslider.js +952 -0
- data/app/assets/stylesheets/anythingslider.sass +203 -0
- data/lib/anything/slider.rb +8 -0
- data/lib/anything/slider/version.rb +5 -0
- data/lib/generators/slider/install/install_generator.rb +14 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 43fc2fd7194a8809bce91250e5a9c3babcee6785
|
4
|
+
data.tar.gz: 9998b495b06c6eec39ec295214e7a431eace44e6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 85886a7c0c63f6fbe25fad4a5c6fb2e941c22480bf2b1053b5c318cabd211929f58211b8ec1e603089306eec559e3d95da533a300e1332de8ccea0fb72ae5b92
|
7
|
+
data.tar.gz: 78e1792ebcf09ba12f31b71de4e70fe9165bffce6bc9f7fd747ca17677a94c505411fd4b51347e544bd11e82e37013af4a53a9398de59a5c4c015fb1953776a5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Oscar Hugo Cardenas Lopez
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Anything::Slider
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'anything-slider'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install anything-slider
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'anything/slider/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "anything-slider"
|
8
|
+
spec.version = Anything::Slider::VERSION
|
9
|
+
spec.authors = ["Oscar Hugo Cardenas Lopez"]
|
10
|
+
spec.email = ["ohcl87@hotmail.com"]
|
11
|
+
spec.description = %q{This is a personal gem to add anything slider efect in rails application}
|
12
|
+
spec.summary = %q{provide a rails genetator and easy to configure}
|
13
|
+
spec.homepage = "https://github.com/sorsucrel/anything-slider"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "haml"
|
24
|
+
end
|
Binary file
|
@@ -0,0 +1,952 @@
|
|
1
|
+
/*!
|
2
|
+
AnythingSlider v1.9.2
|
3
|
+
Original by Chris Coyier: http://css-tricks.com
|
4
|
+
Get the latest version: https://github.com/CSS-Tricks/AnythingSlider
|
5
|
+
|
6
|
+
To use the navigationFormatter function, you must have a function that
|
7
|
+
accepts two paramaters, and returns a string of HTML text.
|
8
|
+
|
9
|
+
index = integer index (1 based);
|
10
|
+
panel = jQuery wrapped LI item this tab references
|
11
|
+
@return = Must return a string of HTML/Text
|
12
|
+
|
13
|
+
navigationFormatter: function(index, panel){
|
14
|
+
return "Panel #" + index; // This would have each tab with the text 'Panel #X' where X = index
|
15
|
+
}
|
16
|
+
*/
|
17
|
+
/*jshint browser:true, jquery:true, unused:false */
|
18
|
+
;(function($, win, doc) {
|
19
|
+
"use strict";
|
20
|
+
$.anythingSlider = function(el, options) {
|
21
|
+
|
22
|
+
var base = this, o, t;
|
23
|
+
|
24
|
+
// Wraps the ul in the necessary divs and then gives Access to jQuery element
|
25
|
+
base.el = el;
|
26
|
+
base.$el = $(el).addClass('anythingBase').wrap('<div class="anythingSlider"><div class="anythingWindow" /></div>');
|
27
|
+
|
28
|
+
// Add a reverse reference to the DOM object
|
29
|
+
base.$el.data("AnythingSlider", base);
|
30
|
+
|
31
|
+
base.init = function(){
|
32
|
+
|
33
|
+
// Added "o" to be used in the code instead of "base.options" which doesn't get modifed by the compiler - reduces size by ~1k
|
34
|
+
base.options = o = $.extend({}, $.anythingSlider.defaults, options);
|
35
|
+
|
36
|
+
base.initialized = false;
|
37
|
+
if ($.isFunction(o.onBeforeInitialize)) { base.$el.bind('before_initialize', o.onBeforeInitialize); }
|
38
|
+
base.$el.trigger('before_initialize', base);
|
39
|
+
|
40
|
+
// Add "as-oldie" class to body for css purposes
|
41
|
+
$('<!--[if lte IE 8]><script>jQuery("body").addClass("as-oldie");</script><![endif]-->').appendTo('body').remove();
|
42
|
+
|
43
|
+
// Cache existing DOM elements for later
|
44
|
+
// base.$el = original ul
|
45
|
+
// for wrap - get parent() then closest in case the ul has "anythingSlider" class
|
46
|
+
base.$wrapper = base.$el.parent().closest('div.anythingSlider').addClass('anythingSlider-' + o.theme);
|
47
|
+
base.$outer = base.$wrapper.parent();
|
48
|
+
base.$window = base.$el.closest('div.anythingWindow');
|
49
|
+
base.$win = $(win);
|
50
|
+
|
51
|
+
base.$controls = $('<div class="anythingControls"></div>');
|
52
|
+
base.$nav = $('<ul class="thumbNav"><li><a><span></span></a></li></ul>');
|
53
|
+
base.$startStop = $('<a href="#" class="start-stop"></a>');
|
54
|
+
|
55
|
+
if (o.buildStartStop || o.buildNavigation) {
|
56
|
+
base.$controls.appendTo( (o.appendControlsTo && $(o.appendControlsTo).length) ? $(o.appendControlsTo) : base.$wrapper);
|
57
|
+
}
|
58
|
+
if (o.buildNavigation) {
|
59
|
+
base.$nav.appendTo( (o.appendNavigationTo && $(o.appendNavigationTo).length) ? $(o.appendNavigationTo) : base.$controls );
|
60
|
+
}
|
61
|
+
if (o.buildStartStop) {
|
62
|
+
base.$startStop.appendTo( (o.appendStartStopTo && $(o.appendStartStopTo).length) ? $(o.appendStartStopTo) : base.$controls );
|
63
|
+
}
|
64
|
+
|
65
|
+
// Figure out how many sliders are on the page for indexing
|
66
|
+
base.runTimes = $('.anythingBase').length;
|
67
|
+
// hash tag regex - fixes issue #432
|
68
|
+
base.regex = (o.hashTags) ? new RegExp('panel' + base.runTimes + '-(\\d+)', 'i') : null;
|
69
|
+
if (base.runTimes === 1) { base.makeActive(); } // make the first slider on the page active
|
70
|
+
|
71
|
+
// Set up a few defaults & get details
|
72
|
+
base.flag = false; // event flag to prevent multiple calls (used in control click/focusin)
|
73
|
+
if (o.autoPlayLocked) { o.autoPlay = true; } // if autoplay is locked, start playing
|
74
|
+
base.playing = o.autoPlay; // slideshow state; removed "startStopped" option
|
75
|
+
base.slideshow = false; // slideshow flag needed to correctly trigger slideshow events
|
76
|
+
base.hovered = false; // actively hovering over the slider
|
77
|
+
base.panelSize = []; // will contain dimensions and left position of each panel
|
78
|
+
base.currentPage = base.targetPage = o.startPanel = parseInt(o.startPanel,10) || 1; // make sure this isn't a string
|
79
|
+
o.changeBy = parseInt(o.changeBy,10) || 1;
|
80
|
+
|
81
|
+
// set slider type, but keep backward compatibility with the vertical option
|
82
|
+
t = (o.mode || 'h').toLowerCase().match(/(h|v|f)/);
|
83
|
+
t = o.vertical ? 'v' : (t || ['h'])[0];
|
84
|
+
o.mode = t === 'v' ? 'vertical' : t === 'f' ? 'fade' : 'horizontal';
|
85
|
+
if (t === 'f') {
|
86
|
+
o.showMultiple = 1; // all slides are stacked in fade mode
|
87
|
+
o.infiniteSlides = false; // no cloned slides
|
88
|
+
}
|
89
|
+
|
90
|
+
base.adj = (o.infiniteSlides) ? 0 : 1; // adjust page limits for infinite or limited modes
|
91
|
+
base.adjustMultiple = 0;
|
92
|
+
if (o.playRtl) { base.$wrapper.addClass('rtl'); }
|
93
|
+
|
94
|
+
// Build start/stop button
|
95
|
+
if (o.buildStartStop) { base.buildAutoPlay(); }
|
96
|
+
|
97
|
+
// Build forwards/backwards buttons
|
98
|
+
if (o.buildArrows) { base.buildNextBackButtons(); }
|
99
|
+
|
100
|
+
base.$lastPage = base.$targetPage = base.$currentPage;
|
101
|
+
|
102
|
+
base.updateSlider();
|
103
|
+
|
104
|
+
// Expand slider to fit parent
|
105
|
+
if (o.expand) {
|
106
|
+
base.$window.css({ width: '100%', height: '100%' }); // needed for Opera
|
107
|
+
base.checkResize();
|
108
|
+
}
|
109
|
+
|
110
|
+
// Make sure easing function exists.
|
111
|
+
if (!$.isFunction($.easing[o.easing])) { o.easing = "swing"; }
|
112
|
+
|
113
|
+
// If pauseOnHover then add hover effects
|
114
|
+
if (o.pauseOnHover) {
|
115
|
+
base.$wrapper.hover(function() {
|
116
|
+
if (base.playing) {
|
117
|
+
base.$el.trigger('slideshow_paused', base);
|
118
|
+
base.clearTimer(true);
|
119
|
+
}
|
120
|
+
}, function() {
|
121
|
+
if (base.playing) {
|
122
|
+
base.$el.trigger('slideshow_unpaused', base);
|
123
|
+
base.startStop(base.playing, true);
|
124
|
+
}
|
125
|
+
});
|
126
|
+
}
|
127
|
+
|
128
|
+
// Hide/Show navigation & play/stop controls
|
129
|
+
base.slideControls(false);
|
130
|
+
base.$wrapper.bind('mouseenter mouseleave', function(e){
|
131
|
+
// add hovered class to outer wrapper
|
132
|
+
$(this)[e.type === 'mouseenter' ? 'addClass' : 'removeClass']('anythingSlider-hovered');
|
133
|
+
base.hovered = (e.type === 'mouseenter') ? true : false;
|
134
|
+
base.slideControls(base.hovered);
|
135
|
+
});
|
136
|
+
|
137
|
+
// Add keyboard navigation
|
138
|
+
$(doc).keyup(function(e){
|
139
|
+
// Stop arrow keys from working when focused on form items
|
140
|
+
if (o.enableKeyboard && base.$wrapper.hasClass('activeSlider') && !e.target.tagName.match('TEXTAREA|INPUT|SELECT')) {
|
141
|
+
if (o.mode !== 'vertical' && (e.which === 38 || e.which === 40)) { return; }
|
142
|
+
switch (e.which) {
|
143
|
+
case 39: case 40: // right & down arrow
|
144
|
+
base.goForward();
|
145
|
+
break;
|
146
|
+
case 37: case 38: // left & up arrow
|
147
|
+
base.goBack();
|
148
|
+
break;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
});
|
152
|
+
|
153
|
+
// If a hash can not be used to trigger the plugin, then go to start panel - see issue #432
|
154
|
+
base.currentPage = ((o.hashTags) ? base.gotoHash() : '') || o.startPanel || 1;
|
155
|
+
base.gotoPage(base.currentPage, false, null, -1);
|
156
|
+
|
157
|
+
// Binds events
|
158
|
+
var triggers = "slideshow_resized slideshow_paused slideshow_unpaused slide_init slide_begin slideshow_stop slideshow_start initialized swf_completed".split(" ");
|
159
|
+
$.each("onSliderResize onShowPause onShowUnpause onSlideInit onSlideBegin onShowStop onShowStart onInitialized onSWFComplete".split(" "), function(i,f){
|
160
|
+
if ($.isFunction(o[f])){
|
161
|
+
base.$el.bind(triggers[i], o[f]);
|
162
|
+
}
|
163
|
+
});
|
164
|
+
if ($.isFunction(o.onSlideComplete)){
|
165
|
+
// Added setTimeout (zero time) to ensure animation is complete... see this bug report: http://bugs.jquery.com/ticket/7157
|
166
|
+
base.$el.bind('slide_complete', function(){
|
167
|
+
setTimeout(function(){ o.onSlideComplete(base); }, 0);
|
168
|
+
return false;
|
169
|
+
});
|
170
|
+
}
|
171
|
+
base.initialized = true;
|
172
|
+
base.$el.trigger('initialized', base);
|
173
|
+
|
174
|
+
// trigger the slideshow
|
175
|
+
base.startStop(o.autoPlay);
|
176
|
+
|
177
|
+
};
|
178
|
+
|
179
|
+
// called during initialization & to update the slider if a panel is added or deleted
|
180
|
+
base.updateSlider = function(){
|
181
|
+
// needed for updating the slider
|
182
|
+
base.$el.children('.cloned').remove();
|
183
|
+
base.navTextVisible = base.$nav.find('span:first').css('visibility') !== 'hidden';
|
184
|
+
base.$nav.empty();
|
185
|
+
// set currentPage to 1 in case it was zero - occurs when adding slides after removing them all
|
186
|
+
base.currentPage = base.currentPage || 1;
|
187
|
+
|
188
|
+
base.$items = base.$el.children();
|
189
|
+
base.pages = base.$items.length;
|
190
|
+
base.dir = (o.mode === 'vertical') ? 'top' : 'left';
|
191
|
+
o.showMultiple = parseInt(o.showMultiple, 10) || 1; // only integers allowed
|
192
|
+
o.navigationSize = (o.navigationSize === false) ? 0 : parseInt(o.navigationSize,10) || 0;
|
193
|
+
|
194
|
+
// Fix tabbing through the page, but don't change the view if the link is in view (showMultiple = true)
|
195
|
+
base.$items.find('a').unbind('focus.AnythingSlider').bind('focus.AnythingSlider', function(e){
|
196
|
+
var panel = $(this).closest('.panel'),
|
197
|
+
indx = base.$items.index(panel) + base.adj; // index can be -1 in nested sliders - issue #208
|
198
|
+
base.$items.find('.focusedLink').removeClass('focusedLink');
|
199
|
+
$(this).addClass('focusedLink');
|
200
|
+
base.$window.scrollLeft(0).scrollTop(0);
|
201
|
+
if ( ( indx !== -1 && (indx >= base.currentPage + o.showMultiple || indx < base.currentPage) ) ) {
|
202
|
+
base.gotoPage(indx);
|
203
|
+
e.preventDefault();
|
204
|
+
}
|
205
|
+
});
|
206
|
+
if (o.showMultiple > 1) {
|
207
|
+
if (o.showMultiple > base.pages) { o.showMultiple = base.pages; }
|
208
|
+
base.adjustMultiple = (o.infiniteSlides && base.pages > 1) ? 0 : o.showMultiple - 1;
|
209
|
+
}
|
210
|
+
|
211
|
+
// Hide navigation & player if there is only one page
|
212
|
+
base.$controls
|
213
|
+
.add(base.$nav)
|
214
|
+
.add(base.$startStop)
|
215
|
+
.add(base.$forward)
|
216
|
+
.add(base.$back)[(base.pages <= 1) ? 'hide' : 'show']();
|
217
|
+
if (base.pages > 1) {
|
218
|
+
// Build/update navigation tabs
|
219
|
+
base.buildNavigation();
|
220
|
+
}
|
221
|
+
|
222
|
+
// Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
|
223
|
+
// This supports the "infinite" scrolling, also ensures any cloned elements don't duplicate an ID
|
224
|
+
// Moved removeAttr before addClass otherwise IE7 ignores the addClass: http://bugs.jquery.com/ticket/9871
|
225
|
+
if (o.mode !== 'fade' && o.infiniteSlides && base.pages > 1) {
|
226
|
+
base.$el.prepend( base.$items.filter(':last').clone().addClass('cloned') );
|
227
|
+
// Add support for multiple sliders shown at the same time
|
228
|
+
if (o.showMultiple > 1) {
|
229
|
+
base.$el.append( base.$items.filter(':lt(' + o.showMultiple + ')').clone().addClass('cloned multiple') );
|
230
|
+
} else {
|
231
|
+
base.$el.append( base.$items.filter(':first').clone().addClass('cloned') );
|
232
|
+
}
|
233
|
+
base.$el.find('.cloned').each(function(){
|
234
|
+
// disable all focusable elements in cloned panels to prevent shifting the panels by tabbing
|
235
|
+
$(this).find('a,input,textarea,select,button,area,form').attr({ disabled : 'disabled', name : '' });
|
236
|
+
$(this).find('[id]')[ $.fn.addBack ? 'addBack' : 'andSelf' ]().removeAttr('id');
|
237
|
+
});
|
238
|
+
}
|
239
|
+
|
240
|
+
// We just added two items, time to re-cache the list, then get the dimensions of each panel
|
241
|
+
base.$items = base.$el.addClass(o.mode).children().addClass('panel');
|
242
|
+
base.setDimensions();
|
243
|
+
|
244
|
+
// Set the dimensions of each panel
|
245
|
+
if (o.resizeContents) {
|
246
|
+
base.$items.css('width', base.width);
|
247
|
+
base.$wrapper
|
248
|
+
.css('width', base.getDim(base.currentPage)[0])
|
249
|
+
.add(base.$items).css('height', base.height);
|
250
|
+
} else {
|
251
|
+
base.$win.load(function(){
|
252
|
+
// set dimensions after all images load
|
253
|
+
base.setDimensions();
|
254
|
+
// make sure the outer wrapper is set properly
|
255
|
+
t = base.getDim(base.currentPage);
|
256
|
+
base.$wrapper.css({ width: t[0], height: t[1] });
|
257
|
+
base.setCurrentPage(base.currentPage, false);
|
258
|
+
});
|
259
|
+
}
|
260
|
+
|
261
|
+
if (base.currentPage > base.pages) {
|
262
|
+
base.currentPage = base.pages;
|
263
|
+
}
|
264
|
+
base.setCurrentPage(base.currentPage, false);
|
265
|
+
base.$nav.find('a').eq(base.currentPage - 1).addClass('cur'); // update current selection
|
266
|
+
|
267
|
+
if (o.mode === 'fade') {
|
268
|
+
t = base.$items.eq(base.currentPage-1);
|
269
|
+
if (o.resumeOnVisible) {
|
270
|
+
// prevent display: none;
|
271
|
+
t.css({ opacity: 1 }).siblings().css({ opacity: 0 });
|
272
|
+
} else {
|
273
|
+
// allow display: none; - resets video
|
274
|
+
base.$items.css('opacity',1);
|
275
|
+
t.fadeIn(0).siblings().fadeOut(0);
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
};
|
280
|
+
|
281
|
+
// Creates the numbered navigation links
|
282
|
+
base.buildNavigation = function() {
|
283
|
+
if (o.buildNavigation && (base.pages > 1)) {
|
284
|
+
var a, c, i, t, $li;
|
285
|
+
base.$items.filter(':not(.cloned)').each(function(j){
|
286
|
+
$li = $('<li/>');
|
287
|
+
i = j + 1;
|
288
|
+
c = (i === 1 ? ' first' : '') + (i === base.pages ? ' last' : '');
|
289
|
+
a = '<a class="panel' + i + ( base.navTextVisible ? '"' : ' ' + o.tooltipClass + '" title="@"' ) + ' href="#"><span>@</span></a>';
|
290
|
+
// If a formatter function is present, use it
|
291
|
+
if ($.isFunction(o.navigationFormatter)) {
|
292
|
+
t = o.navigationFormatter(i, $(this));
|
293
|
+
if (typeof(t) === "string") {
|
294
|
+
$li.html(a.replace(/@/g,t));
|
295
|
+
} else {
|
296
|
+
$li = $('<li/>', t);
|
297
|
+
}
|
298
|
+
} else {
|
299
|
+
$li.html(a.replace(/@/g,i));
|
300
|
+
}
|
301
|
+
$li
|
302
|
+
.appendTo(base.$nav)
|
303
|
+
.addClass(c)
|
304
|
+
.data('index', i);
|
305
|
+
});
|
306
|
+
base.$nav.children('li').bind(o.clickControls, function(e) {
|
307
|
+
if (!base.flag && o.enableNavigation) {
|
308
|
+
// prevent running functions twice (once for click, second time for focusin)
|
309
|
+
base.flag = true; setTimeout(function(){ base.flag = false; }, 100);
|
310
|
+
base.gotoPage( $(this).data('index') );
|
311
|
+
}
|
312
|
+
e.preventDefault();
|
313
|
+
});
|
314
|
+
|
315
|
+
// Add navigation tab scrolling - use !! in case someone sets the size to zero
|
316
|
+
if (!!o.navigationSize && o.navigationSize < base.pages) {
|
317
|
+
if (!base.$controls.find('.anythingNavWindow').length){
|
318
|
+
base.$nav
|
319
|
+
.before('<ul><li class="prev"><a href="#"><span>' + o.backText + '</span></a></li></ul>')
|
320
|
+
.after('<ul><li class="next"><a href="#"><span>' + o.forwardText + '</span></a></li></ul>')
|
321
|
+
.wrap('<div class="anythingNavWindow"></div>');
|
322
|
+
}
|
323
|
+
// include half of the left position to include extra width from themes like tabs-light and tabs-dark (still not perfect)
|
324
|
+
base.navWidths = base.$nav.find('li').map(function(){
|
325
|
+
return $(this).outerWidth(true) + Math.ceil(parseInt($(this).find('span').css('left'),10)/2 || 0);
|
326
|
+
}).get();
|
327
|
+
base.navLeft = base.currentPage;
|
328
|
+
// add 25 pixels (old IE needs more than 5) to make sure the tabs don't wrap to the next line
|
329
|
+
base.$nav.width( base.navWidth( 1, base.pages + 1 ) + 25 );
|
330
|
+
base.$controls.find('.anythingNavWindow')
|
331
|
+
.width( base.navWidth( 1, o.navigationSize + 1 ) ).end()
|
332
|
+
.find('.prev,.next').bind(o.clickControls, function(e) {
|
333
|
+
if (!base.flag) {
|
334
|
+
base.flag = true; setTimeout(function(){ base.flag = false; }, 200);
|
335
|
+
base.navWindow( base.navLeft + o.navigationSize * ( $(this).is('.prev') ? -1 : 1 ) );
|
336
|
+
}
|
337
|
+
e.preventDefault();
|
338
|
+
});
|
339
|
+
}
|
340
|
+
|
341
|
+
}
|
342
|
+
};
|
343
|
+
|
344
|
+
base.navWidth = function(x,y){
|
345
|
+
var i, s = Math.min(x,y),
|
346
|
+
e = Math.max(x,y),
|
347
|
+
w = 0;
|
348
|
+
for (i = s; i < e; i++) {
|
349
|
+
w += base.navWidths[i-1] || 0;
|
350
|
+
}
|
351
|
+
return w;
|
352
|
+
};
|
353
|
+
|
354
|
+
base.navWindow = function(n){
|
355
|
+
if (!!o.navigationSize && o.navigationSize < base.pages && base.navWidths) {
|
356
|
+
var p = base.pages - o.navigationSize + 1;
|
357
|
+
n = (n <= 1) ? 1 : (n > 1 && n < p) ? n : p;
|
358
|
+
if (n !== base.navLeft) {
|
359
|
+
base.$controls.find('.anythingNavWindow').animate(
|
360
|
+
{ scrollLeft: base.navWidth(1, n), width: base.navWidth(n, n + o.navigationSize) },
|
361
|
+
{ queue: false, duration: o.animationTime });
|
362
|
+
base.navLeft = n;
|
363
|
+
}
|
364
|
+
}
|
365
|
+
};
|
366
|
+
|
367
|
+
// Creates the Forward/Backward buttons
|
368
|
+
base.buildNextBackButtons = function() {
|
369
|
+
base.$forward = $('<span class="arrow forward"><a href="#"><span>' + o.forwardText + '</span></a></span>');
|
370
|
+
base.$back = $('<span class="arrow back"><a href="#"><span>' + o.backText + '</span></a></span>');
|
371
|
+
|
372
|
+
// Bind to the forward and back buttons
|
373
|
+
base.$back.bind(o.clickBackArrow, function(e) {
|
374
|
+
// prevent running functions twice (once for click, second time for swipe)
|
375
|
+
if (o.enableArrows && !base.flag) {
|
376
|
+
base.flag = true; setTimeout(function(){ base.flag = false; }, 100);
|
377
|
+
base.goBack();
|
378
|
+
}
|
379
|
+
e.preventDefault();
|
380
|
+
});
|
381
|
+
base.$forward.bind(o.clickForwardArrow, function(e) {
|
382
|
+
// prevent running functions twice (once for click, second time for swipe)
|
383
|
+
if (o.enableArrows && !base.flag) {
|
384
|
+
base.flag = true; setTimeout(function(){ base.flag = false; }, 100);
|
385
|
+
base.goForward();
|
386
|
+
}
|
387
|
+
e.preventDefault();
|
388
|
+
});
|
389
|
+
// using tab to get to arrow links will show they have focus (outline is disabled in css)
|
390
|
+
base.$back.add(base.$forward).find('a').bind('focusin focusout',function(){
|
391
|
+
$(this).toggleClass('hover');
|
392
|
+
});
|
393
|
+
|
394
|
+
// Append elements to page
|
395
|
+
base.$back.appendTo( (o.appendBackTo && $(o.appendBackTo).length) ? $(o.appendBackTo) : base.$wrapper );
|
396
|
+
base.$forward.appendTo( (o.appendForwardTo && $(o.appendForwardTo).length) ? $(o.appendForwardTo) : base.$wrapper );
|
397
|
+
|
398
|
+
base.arrowWidth = base.$forward.width(); // assuming the left & right arrows are the same width - used for toggle
|
399
|
+
base.arrowRight = parseInt(base.$forward.css('right'), 10);
|
400
|
+
base.arrowLeft = parseInt(base.$back.css('left'), 10);
|
401
|
+
|
402
|
+
};
|
403
|
+
|
404
|
+
// Creates the Start/Stop button
|
405
|
+
base.buildAutoPlay = function(){
|
406
|
+
base.$startStop
|
407
|
+
.html('<span>' + (base.playing ? o.stopText : o.startText) + '</span>')
|
408
|
+
.bind(o.clickSlideshow, function(e) {
|
409
|
+
if (o.enableStartStop) {
|
410
|
+
base.startStop(!base.playing);
|
411
|
+
base.makeActive();
|
412
|
+
if (base.playing && !o.autoPlayDelayed) {
|
413
|
+
base.goForward(true, o.playRtl);
|
414
|
+
}
|
415
|
+
}
|
416
|
+
e.preventDefault();
|
417
|
+
})
|
418
|
+
// show button has focus while tabbing
|
419
|
+
.bind('focusin focusout',function(){
|
420
|
+
$(this).toggleClass('hover');
|
421
|
+
});
|
422
|
+
};
|
423
|
+
|
424
|
+
// Adjust slider dimensions on parent element resize
|
425
|
+
base.checkResize = function(stopTimer){
|
426
|
+
// checking document visibility -
|
427
|
+
var vis = !!(doc.hidden || doc.webkitHidden || doc.mozHidden || doc.msHidden);
|
428
|
+
clearTimeout(base.resizeTimer);
|
429
|
+
base.resizeTimer = setTimeout(function(){
|
430
|
+
var w = base.$outer.width(),
|
431
|
+
h = base.$outer[0].tagName === "BODY" ? base.$win.height() : base.$outer.height();
|
432
|
+
// base.width = width of one panel, so multiply by # of panels; outerPad is padding added for arrows.
|
433
|
+
// ignore changes if window hidden
|
434
|
+
if (!vis && (base.lastDim[0] !== w || base.lastDim[1] !== h)) {
|
435
|
+
|
436
|
+
base.setDimensions(); // adjust panel sizes
|
437
|
+
|
438
|
+
//callback for slider resize
|
439
|
+
base.$el.trigger('slideshow_resized', base);
|
440
|
+
|
441
|
+
// make sure page is lined up (use -1 animation time, so we can differeniate it from when animationTime = 0)
|
442
|
+
base.gotoPage(base.currentPage, base.playing, null, -1);
|
443
|
+
|
444
|
+
}
|
445
|
+
if (typeof(stopTimer) === 'undefined'){ base.checkResize(); }
|
446
|
+
|
447
|
+
// increase time if page is hidden; but don't stop it completely
|
448
|
+
}, vis ? 2000 : 500);
|
449
|
+
};
|
450
|
+
|
451
|
+
// Set panel dimensions to either resize content or adjust panel to content
|
452
|
+
base.setDimensions = function(){
|
453
|
+
|
454
|
+
// reset element width & height
|
455
|
+
base.$wrapper.find('.anythingWindow, .anythingBase, .panel')[ $.fn.addBack ? 'addBack' : 'andSelf' ]().css({ width: '', height: '' });
|
456
|
+
base.width = base.$el.width();
|
457
|
+
base.height = base.$el.height();
|
458
|
+
base.outerPad = [ base.$wrapper.innerWidth() - base.$wrapper.width(), base.$wrapper.innerHeight() - base.$wrapper.height() ];
|
459
|
+
var w, h, c, t, edge = 0,
|
460
|
+
fullsize = { width: '100%', height: '100%' },
|
461
|
+
// determine panel width
|
462
|
+
pw = (o.showMultiple > 1 && o.mode === 'horizontal') ? base.width || base.$window.width()/o.showMultiple : base.$window.width(),
|
463
|
+
ph = (o.showMultiple > 1 && o.mode === 'vertical') ? base.height/o.showMultiple || base.$window.height()/o.showMultiple : base.$window.height();
|
464
|
+
if (o.expand){
|
465
|
+
base.lastDim = [ base.$outer.width(), base.$outer.height() ];
|
466
|
+
w = base.lastDim[0] - base.outerPad[0];
|
467
|
+
h = base.lastDim[1] - base.outerPad[1];
|
468
|
+
base.$wrapper.add(base.$window).css({ width: w, height: h });
|
469
|
+
base.height = h = (o.showMultiple > 1 && o.mode === 'vertical') ? ph : h;
|
470
|
+
base.width = pw = (o.showMultiple > 1 && o.mode === 'horizontal') ? w/o.showMultiple : w;
|
471
|
+
base.$items.css({ width: pw, height: ph });
|
472
|
+
}
|
473
|
+
base.$items.each(function(i){
|
474
|
+
t = $(this);
|
475
|
+
c = t.children();
|
476
|
+
if (o.resizeContents){
|
477
|
+
// resize panel
|
478
|
+
w = base.width;
|
479
|
+
h = base.height;
|
480
|
+
t.css({ width: w, height: h });
|
481
|
+
if (c.length) {
|
482
|
+
if (c[0].tagName === "EMBED") { c.attr(fullsize); } // needed for IE7; also c.length > 1 in IE7
|
483
|
+
if (c[0].tagName === "OBJECT") { c.find('embed').attr(fullsize); }
|
484
|
+
// resize panel contents, if solitary (wrapped content or solitary image)
|
485
|
+
if (c.length === 1){ c.css(fullsize); }
|
486
|
+
}
|
487
|
+
} else {
|
488
|
+
// get panel width & height and save it
|
489
|
+
if (o.mode === 'vertical') {
|
490
|
+
w = t.css('display','inline-block').width();
|
491
|
+
t.css('display','');
|
492
|
+
} else {
|
493
|
+
w = t.width() || base.width; // if image hasn't finished loading, width will be zero, so set it to base width instead
|
494
|
+
}
|
495
|
+
if (c.length === 1 && w >= pw){
|
496
|
+
w = (c.width() >= pw) ? pw : c.width(); // get width of solitary child
|
497
|
+
c.css('max-width', w); // set max width for all children
|
498
|
+
}
|
499
|
+
t.css({ width: w, height: '' }); // set width of panel
|
500
|
+
h = (c.length === 1 ? c.outerHeight(true) : t.height()); // get height after setting width
|
501
|
+
if (h <= base.outerPad[1]) { h = base.height; } // if height less than the outside padding, then set it to the preset height
|
502
|
+
t.css('height', h);
|
503
|
+
}
|
504
|
+
base.panelSize[i] = [w,h,edge];
|
505
|
+
edge += (o.mode === 'vertical') ? h : w;
|
506
|
+
});
|
507
|
+
// Set total width of slider
|
508
|
+
base.$el.css((o.mode === 'vertical' ? 'height' : 'width'), o.mode === 'fade' ? base.width : edge );
|
509
|
+
};
|
510
|
+
|
511
|
+
// get dimension of multiple panels, as needed
|
512
|
+
base.getDim = function(page){
|
513
|
+
var t, i, w = base.width, h = base.height;
|
514
|
+
if (base.pages < 1 || isNaN(page)) { return [ w, h ]; } // prevent errors when base.panelSize is empty
|
515
|
+
page = (o.infiniteSlides && base.pages > 1) ? page : page - 1;
|
516
|
+
i = base.panelSize[page];
|
517
|
+
if (i) {
|
518
|
+
w = i[0] || w;
|
519
|
+
h = i[1] || h;
|
520
|
+
}
|
521
|
+
if (o.showMultiple > 1) {
|
522
|
+
for (i = 1; i < o.showMultiple; i++) {
|
523
|
+
t = page + i;
|
524
|
+
if (o.mode === 'vertical') {
|
525
|
+
w = Math.max(w, base.panelSize[t][0]);
|
526
|
+
h += base.panelSize[t][1];
|
527
|
+
} else {
|
528
|
+
w += base.panelSize[t][0];
|
529
|
+
h = Math.max(h, base.panelSize[t][1]);
|
530
|
+
}
|
531
|
+
}
|
532
|
+
}
|
533
|
+
return [w,h];
|
534
|
+
};
|
535
|
+
|
536
|
+
base.goForward = function(autoplay, rtl) {
|
537
|
+
// targetPage changes before animation so if rapidly changing pages, it will have the correct current page
|
538
|
+
base.gotoPage(base[ o.allowRapidChange ? 'targetPage' : 'currentPage'] + o.changeBy * (rtl ? -1 : 1), autoplay);
|
539
|
+
};
|
540
|
+
|
541
|
+
base.goBack = function(autoplay) {
|
542
|
+
base.gotoPage(base[ o.allowRapidChange ? 'targetPage' : 'currentPage'] - o.changeBy, autoplay);
|
543
|
+
};
|
544
|
+
|
545
|
+
base.gotoPage = function(page, autoplay, callback, time) {
|
546
|
+
if (autoplay !== true) {
|
547
|
+
autoplay = false;
|
548
|
+
base.startStop(false);
|
549
|
+
base.makeActive();
|
550
|
+
}
|
551
|
+
// check if page is an id or class name
|
552
|
+
if (/^[#|.]/.test(page) && $(page).length) {
|
553
|
+
page = $(page).closest('.panel').index() + base.adj;
|
554
|
+
}
|
555
|
+
|
556
|
+
// rewind effect occurs here when changeBy > 1
|
557
|
+
if (o.changeBy !== 1){
|
558
|
+
var adj = base.pages - base.adjustMultiple;
|
559
|
+
if (page < 1) {
|
560
|
+
page = o.stopAtEnd ? 1 : ( o.infiniteSlides ? base.pages + page : ( o.showMultiple > 1 - page ? 1 : adj ) );
|
561
|
+
}
|
562
|
+
if (page > base.pages) {
|
563
|
+
page = o.stopAtEnd ? base.pages : ( o.showMultiple > 1 - page ? 1 : page -= adj );
|
564
|
+
} else if (page >= adj) {
|
565
|
+
// show multiple adjustments
|
566
|
+
page = adj;
|
567
|
+
}
|
568
|
+
}
|
569
|
+
|
570
|
+
if (base.pages <= 1) { return; } // prevents animation
|
571
|
+
base.$lastPage = base.$currentPage;
|
572
|
+
if (typeof(page) !== "number") {
|
573
|
+
page = parseInt(page,10) || o.startPanel;
|
574
|
+
base.setCurrentPage(page);
|
575
|
+
}
|
576
|
+
|
577
|
+
// pause YouTube videos before scrolling or prevent change if playing
|
578
|
+
if (autoplay && o.isVideoPlaying(base)) { return; }
|
579
|
+
if (o.stopAtEnd && !o.infiniteSlides && page > base.pages - o.showMultiple) { page = base.pages - o.showMultiple + 1; } // fixes #515
|
580
|
+
base.exactPage = page;
|
581
|
+
if (page > base.pages + 1 - base.adj) { page = (!o.infiniteSlides && !o.stopAtEnd) ? 1 : base.pages; }
|
582
|
+
if (page < base.adj ) { page = (!o.infiniteSlides && !o.stopAtEnd) ? base.pages : 1; }
|
583
|
+
if (!o.infiniteSlides) { base.exactPage = page; } // exact page used by the fx extension
|
584
|
+
base.currentPage = ( page > base.pages ) ? base.pages : ( page < 1 ) ? 1 : base.currentPage;
|
585
|
+
base.$currentPage = base.$items.eq(base.currentPage - base.adj);
|
586
|
+
base.targetPage = (page === 0) ? base.pages : (page > base.pages) ? 1 : page;
|
587
|
+
base.$targetPage = base.$items.eq(base.targetPage - base.adj);
|
588
|
+
time = typeof time !== 'undefined' ? time : o.animationTime;
|
589
|
+
// don't trigger events when time < 0 - to prevent FX from firing multiple times on page resize
|
590
|
+
if (time >= 0) { base.$el.trigger('slide_init', base); }
|
591
|
+
// toggle arrows/controls only if there is time to see it - fix issue #317
|
592
|
+
if (time > 0) { base.slideControls(true); }
|
593
|
+
|
594
|
+
// Set visual
|
595
|
+
if (o.buildNavigation){
|
596
|
+
base.setNavigation(base.targetPage);
|
597
|
+
}
|
598
|
+
|
599
|
+
// When autoplay isn't passed, we stop the timer
|
600
|
+
if (autoplay !== true) { autoplay = false; }
|
601
|
+
// Stop the slider when we reach the last page, if the option stopAtEnd is set to true
|
602
|
+
if (!autoplay || (o.stopAtEnd && page === base.pages)) { base.startStop(false); }
|
603
|
+
|
604
|
+
if (time >= 0) { base.$el.trigger('slide_begin', base); }
|
605
|
+
|
606
|
+
// delay starting slide animation
|
607
|
+
setTimeout(function(d){
|
608
|
+
var t, p, empty = true;
|
609
|
+
if (o.allowRapidChange) {
|
610
|
+
base.$wrapper.add(base.$el).add(base.$items).stop(true, true);
|
611
|
+
}
|
612
|
+
// resize slider if content size varies
|
613
|
+
if (!o.resizeContents) {
|
614
|
+
// animating the wrapper resize before the window prevents flickering in Firefox
|
615
|
+
// don't animate the dimension if it hasn't changed - fix for issue #264
|
616
|
+
p = base.getDim(page); d = {};
|
617
|
+
// prevent animating a dimension to zero
|
618
|
+
if (base.$wrapper.width() !== p[0]) { d.width = p[0] || base.width; empty = false; }
|
619
|
+
if (base.$wrapper.height() !== p[1]) { d.height = p[1] || base.height; empty = false; }
|
620
|
+
if (!empty) {
|
621
|
+
base.$wrapper.filter(':not(:animated)').animate(d, { queue: false, duration: (time < 0 ? 0 : time), easing: o.easing });
|
622
|
+
}
|
623
|
+
}
|
624
|
+
|
625
|
+
if (o.mode === 'fade') {
|
626
|
+
if (base.$lastPage[0] !== base.$targetPage[0]) {
|
627
|
+
base.fadeIt( base.$lastPage, 0, time );
|
628
|
+
base.fadeIt( base.$targetPage, 1, time, function(){ base.endAnimation(page, callback, time); });
|
629
|
+
} else {
|
630
|
+
base.endAnimation(page, callback, time);
|
631
|
+
}
|
632
|
+
} else {
|
633
|
+
d = {};
|
634
|
+
d[base.dir] = -base.panelSize[(o.infiniteSlides && base.pages > 1) ? page : page - 1][2];
|
635
|
+
// resize width of base element (ul) if vertical & width of content varies
|
636
|
+
if (o.mode === 'vertical' && !o.resizeContents) { d.width = p[0]; }
|
637
|
+
// Animate Slider
|
638
|
+
base.$el.filter(':not(:animated)').animate(
|
639
|
+
d, { queue: false, duration: time < 0 ? 0 : time, easing: o.easing, complete: function(){ base.endAnimation(page, callback, time); } }
|
640
|
+
);
|
641
|
+
}
|
642
|
+
}, parseInt(o.delayBeforeAnimate, 10) || 0);
|
643
|
+
};
|
644
|
+
|
645
|
+
base.endAnimation = function(page, callback, time){
|
646
|
+
if (page === 0) {
|
647
|
+
base.$el.css( base.dir, o.mode === 'fade' ? 0 : -base.panelSize[base.pages][2]);
|
648
|
+
page = base.pages;
|
649
|
+
} else if (page > base.pages) {
|
650
|
+
// reset back to start position
|
651
|
+
base.$el.css( base.dir, o.mode === 'fade' ? 0 : -base.panelSize[1][2]);
|
652
|
+
page = 1;
|
653
|
+
}
|
654
|
+
base.exactPage = page;
|
655
|
+
base.setCurrentPage(page, false);
|
656
|
+
|
657
|
+
if (o.mode === 'fade') {
|
658
|
+
// make sure non current panels are hidden (rapid slide changes)
|
659
|
+
base.fadeIt( base.$items.not(':eq(' + (page - base.adj) + ')'), 0, 0);
|
660
|
+
}
|
661
|
+
|
662
|
+
if (!base.hovered) { base.slideControls(false); }
|
663
|
+
|
664
|
+
if (o.hashTags) { base.setHash(page); }
|
665
|
+
|
666
|
+
if (time >= 0) { base.$el.trigger('slide_complete', base); }
|
667
|
+
// callback from external slide control: $('#slider').anythingSlider(4, function(slider){ })
|
668
|
+
if (typeof callback === 'function') { callback(base); }
|
669
|
+
|
670
|
+
// Continue slideshow after a delay
|
671
|
+
if (o.autoPlayLocked && !base.playing) {
|
672
|
+
setTimeout(function(){
|
673
|
+
base.startStop(true);
|
674
|
+
// subtract out slide delay as the slideshow waits that additional time.
|
675
|
+
}, o.resumeDelay - (o.autoPlayDelayed ? o.delay : 0));
|
676
|
+
}
|
677
|
+
};
|
678
|
+
|
679
|
+
base.fadeIt = function(el, toOpacity, time, callback){
|
680
|
+
var t = time < 0 ? 0 : time;
|
681
|
+
if (o.resumeOnVisible) {
|
682
|
+
el.filter(':not(:animated)').fadeTo(t, toOpacity, callback);
|
683
|
+
} else {
|
684
|
+
el.filter(':not(:animated)')[ toOpacity === 0 ? 'fadeOut' : 'fadeIn' ](t, callback);
|
685
|
+
}
|
686
|
+
};
|
687
|
+
|
688
|
+
base.setCurrentPage = function(page, move) {
|
689
|
+
page = parseInt(page, 10);
|
690
|
+
|
691
|
+
if (base.pages < 1 || page === 0 || isNaN(page)) { return; }
|
692
|
+
if (page > base.pages + 1 - base.adj) { page = base.pages - base.adj; }
|
693
|
+
if (page < base.adj ) { page = 1; }
|
694
|
+
|
695
|
+
// hide/show arrows based on infinite scroll mode
|
696
|
+
if (o.buildArrows && !o.infiniteSlides && o.stopAtEnd){
|
697
|
+
base.$forward[ page === base.pages - base.adjustMultiple ? 'addClass' : 'removeClass']('disabled');
|
698
|
+
base.$back[ page === 1 ? 'addClass' : 'removeClass']('disabled');
|
699
|
+
if (page === base.pages && base.playing) { base.startStop(); }
|
700
|
+
}
|
701
|
+
|
702
|
+
// Only change left if move does not equal false
|
703
|
+
if (!move) {
|
704
|
+
var d = base.getDim(page);
|
705
|
+
base.$wrapper
|
706
|
+
.css({ width: d[0], height: d[1] })
|
707
|
+
.add(base.$window).scrollLeft(0).scrollTop(0); // reset in case tabbing changed this scrollLeft - probably overly redundant
|
708
|
+
base.$el.css( base.dir, o.mode === 'fade' ? 0 : -base.panelSize[(o.infiniteSlides && base.pages > 1) ? page : page - 1][2] );
|
709
|
+
}
|
710
|
+
|
711
|
+
// Update local variable
|
712
|
+
base.currentPage = page;
|
713
|
+
base.$currentPage = base.$items.removeClass('activePage').eq(page - base.adj).addClass('activePage');
|
714
|
+
|
715
|
+
if (o.buildNavigation){
|
716
|
+
base.setNavigation(page);
|
717
|
+
}
|
718
|
+
|
719
|
+
};
|
720
|
+
|
721
|
+
base.setNavigation = function(page){
|
722
|
+
base.$nav
|
723
|
+
.find('.cur').removeClass('cur').end()
|
724
|
+
.find('a').eq(page - 1).addClass('cur');
|
725
|
+
};
|
726
|
+
|
727
|
+
base.makeActive = function(){
|
728
|
+
// Set current slider as active so keyboard navigation works properly
|
729
|
+
if (!base.$wrapper.hasClass('activeSlider')){
|
730
|
+
$('.activeSlider').removeClass('activeSlider');
|
731
|
+
base.$wrapper.addClass('activeSlider');
|
732
|
+
}
|
733
|
+
};
|
734
|
+
|
735
|
+
// This method tries to find a hash that matches an ID and panel-X
|
736
|
+
// If either found, it tries to find a matching item
|
737
|
+
// If that is found as well, then it returns the page number
|
738
|
+
base.gotoHash = function(){
|
739
|
+
var h = win.location.hash,
|
740
|
+
i = h.indexOf('&'),
|
741
|
+
n = h.match(base.regex);
|
742
|
+
// test for "/#/" or "/#!/" used by the jquery address plugin - $('#/') breaks jQuery
|
743
|
+
if (n === null && !/^#&/.test(h) && !/#!?\//.test(h) && !/\=/.test(h)) {
|
744
|
+
// #quote2&panel1-3&panel3-3
|
745
|
+
h = h.substring(0, (i >= 0 ? i : h.length));
|
746
|
+
// ensure the element is in the same slider
|
747
|
+
n = ($(h).length && $(h).closest('.anythingBase')[0] === base.el) ? base.$items.index($(h).closest('.panel')) + base.adj : null;
|
748
|
+
} else if (n !== null) {
|
749
|
+
// #&panel1-3&panel3-3
|
750
|
+
n = (o.hashTags) ? parseInt(n[1],10) : null;
|
751
|
+
}
|
752
|
+
return n;
|
753
|
+
};
|
754
|
+
|
755
|
+
base.setHash = function(n){
|
756
|
+
var s = 'panel' + base.runTimes + '-',
|
757
|
+
h = win.location.hash;
|
758
|
+
if ( typeof h !== 'undefined' ) {
|
759
|
+
win.location.hash = (h.indexOf(s) > 0) ? h.replace(base.regex, s + n) : h + "&" + s + n;
|
760
|
+
}
|
761
|
+
};
|
762
|
+
|
763
|
+
// Slide controls (nav and play/stop button up or down)
|
764
|
+
base.slideControls = function(toggle){
|
765
|
+
var dir = (toggle) ? 'slideDown' : 'slideUp',
|
766
|
+
t1 = (toggle) ? 0 : o.animationTime,
|
767
|
+
t2 = (toggle) ? o.animationTime : 0,
|
768
|
+
op = (toggle) ? 1 : 0,
|
769
|
+
sign = (toggle) ? 0 : 1; // 0 = visible, 1 = hidden
|
770
|
+
if (o.toggleControls) {
|
771
|
+
base.$controls.stop(true,true).delay(t1)[dir](o.animationTime/2).delay(t2);
|
772
|
+
}
|
773
|
+
if (o.buildArrows && o.toggleArrows) {
|
774
|
+
if (!base.hovered && base.playing) { sign = 1; op = 0; } // don't animate arrows during slideshow
|
775
|
+
base.$forward.stop(true,true).delay(t1).animate({ right: base.arrowRight + (sign * base.arrowWidth), opacity: op }, o.animationTime/2);
|
776
|
+
base.$back.stop(true,true).delay(t1).animate({ left: base.arrowLeft + (sign * base.arrowWidth), opacity: op }, o.animationTime/2);
|
777
|
+
}
|
778
|
+
};
|
779
|
+
|
780
|
+
base.clearTimer = function(paused){
|
781
|
+
// Clear the timer only if it is set
|
782
|
+
if (base.timer) {
|
783
|
+
win.clearInterval(base.timer);
|
784
|
+
if (!paused && base.slideshow) {
|
785
|
+
base.$el.trigger('slideshow_stop', base);
|
786
|
+
base.slideshow = false;
|
787
|
+
}
|
788
|
+
}
|
789
|
+
};
|
790
|
+
|
791
|
+
// Pass startStop(false) to stop and startStop(true) to play
|
792
|
+
base.startStop = function(playing, paused) {
|
793
|
+
if (playing !== true) { playing = false; } // Default if not supplied is false
|
794
|
+
base.playing = playing;
|
795
|
+
|
796
|
+
if (playing && !paused) {
|
797
|
+
base.$el.trigger('slideshow_start', base);
|
798
|
+
base.slideshow = true;
|
799
|
+
}
|
800
|
+
|
801
|
+
// Toggle playing and text
|
802
|
+
if (o.buildStartStop) {
|
803
|
+
base.$startStop.toggleClass('playing', playing).find('span').html( playing ? o.stopText : o.startText );
|
804
|
+
// add button text to title attribute if it is hidden by text-indent
|
805
|
+
if ( base.$startStop.find('span').css('visibility') === "hidden" ) {
|
806
|
+
base.$startStop.addClass(o.tooltipClass).attr( 'title', playing ? o.stopText : o.startText );
|
807
|
+
}
|
808
|
+
}
|
809
|
+
|
810
|
+
// Pause slideshow while video is playing
|
811
|
+
if (playing){
|
812
|
+
base.clearTimer(true); // Just in case this was triggered twice in a row
|
813
|
+
base.timer = win.setInterval(function() {
|
814
|
+
if ( !!(doc.hidden || doc.webkitHidden || doc.mozHidden || doc.msHidden) ) {
|
815
|
+
// stop slideshow if the page isn't visible (issue #463)
|
816
|
+
if (!o.autoPlayLocked) {
|
817
|
+
base.startStop();
|
818
|
+
}
|
819
|
+
} else if ( !o.isVideoPlaying(base) ) {
|
820
|
+
// prevent autoplay if video is playing
|
821
|
+
base.goForward(true, o.playRtl);
|
822
|
+
} else if (!o.resumeOnVideoEnd) {
|
823
|
+
// stop slideshow if resume if false
|
824
|
+
base.startStop();
|
825
|
+
}
|
826
|
+
}, o.delay);
|
827
|
+
} else {
|
828
|
+
base.clearTimer();
|
829
|
+
}
|
830
|
+
};
|
831
|
+
|
832
|
+
// Trigger the initialization
|
833
|
+
base.init();
|
834
|
+
};
|
835
|
+
|
836
|
+
$.anythingSlider.defaults = {
|
837
|
+
// Appearance
|
838
|
+
theme : "default", // Theme name, add the css stylesheet manually
|
839
|
+
mode : "horiz", // Set mode to "horizontal", "vertical" or "fade" (only first letter needed); replaces vertical option
|
840
|
+
expand : false, // If true, the entire slider will expand to fit the parent element
|
841
|
+
resizeContents : true, // If true, solitary images/objects in the panel will expand to fit the viewport
|
842
|
+
showMultiple : false, // Set this value to a number and it will show that many slides at once
|
843
|
+
easing : "swing", // Anything other than "linear" or "swing" requires the easing plugin or jQuery UI
|
844
|
+
|
845
|
+
buildArrows : true, // If true, builds the forwards and backwards buttons
|
846
|
+
buildNavigation : true, // If true, builds a list of anchor links to link to each panel
|
847
|
+
buildStartStop : true, // ** If true, builds the start/stop button
|
848
|
+
|
849
|
+
/*
|
850
|
+
// commented out as this will reduce the size of the minified version
|
851
|
+
appendForwardTo : null, // Append forward arrow to a HTML element (jQuery Object, selector or HTMLNode), if not null
|
852
|
+
appendBackTo : null, // Append back arrow to a HTML element (jQuery Object, selector or HTMLNode), if not null
|
853
|
+
appendControlsTo : null, // Append controls (navigation + start-stop) to a HTML element (jQuery Object, selector or HTMLNode), if not null
|
854
|
+
appendNavigationTo : null, // Append navigation buttons to a HTML element (jQuery Object, selector or HTMLNode), if not null
|
855
|
+
appendStartStopTo : null, // Append start-stop button to a HTML element (jQuery Object, selector or HTMLNode), if not null
|
856
|
+
*/
|
857
|
+
|
858
|
+
toggleArrows : false, // If true, side navigation arrows will slide out on hovering & hide @ other times
|
859
|
+
toggleControls : false, // if true, slide in controls (navigation + play/stop button) on hover and slide change, hide @ other times
|
860
|
+
|
861
|
+
startText : "Start", // Start button text
|
862
|
+
stopText : "Stop", // Stop button text
|
863
|
+
forwardText : "»", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
|
864
|
+
backText : "«", // Link text used to move the slider back (hidden by CSS, replace with arrow image)
|
865
|
+
tooltipClass : "tooltip", // Class added to navigation & start/stop button (text copied to title if it is hidden by a negative text indent)
|
866
|
+
|
867
|
+
// Function
|
868
|
+
enableArrows : true, // if false, arrows will be visible, but not clickable.
|
869
|
+
enableNavigation : true, // if false, navigation links will still be visible, but not clickable.
|
870
|
+
enableStartStop : true, // if false, the play/stop button will still be visible, but not clickable. Previously "enablePlay"
|
871
|
+
enableKeyboard : true, // if false, keyboard arrow keys will not work for this slider.
|
872
|
+
|
873
|
+
// Navigation
|
874
|
+
startPanel : 1, // This sets the initial panel
|
875
|
+
changeBy : 1, // Amount to go forward or back when changing panels.
|
876
|
+
hashTags : true, // Should links change the hashtag in the URL?
|
877
|
+
infiniteSlides : true, // if false, the slider will not wrap & not clone any panels
|
878
|
+
navigationFormatter : null, // Details at the top of the file on this use (advanced use)
|
879
|
+
navigationSize : false, // Set this to the maximum number of visible navigation tabs; false to disable
|
880
|
+
|
881
|
+
// Slideshow options
|
882
|
+
autoPlay : false, // If true, the slideshow will start running; replaces "startStopped" option
|
883
|
+
autoPlayLocked : false, // If true, user changing slides will not stop the slideshow
|
884
|
+
autoPlayDelayed : false, // If true, starting a slideshow will delay advancing slides; if false, the slider will immediately advance to the next slide when slideshow starts
|
885
|
+
pauseOnHover : true, // If true & the slideshow is active, the slideshow will pause on hover
|
886
|
+
stopAtEnd : false, // If true & the slideshow is active, the slideshow will stop on the last page. This also stops the rewind effect when infiniteSlides is false.
|
887
|
+
playRtl : false, // If true, the slideshow will move right-to-left
|
888
|
+
|
889
|
+
// Times
|
890
|
+
delay : 3000, // How long between slideshow transitions in AutoPlay mode (in milliseconds)
|
891
|
+
resumeDelay : 15000, // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
|
892
|
+
animationTime : 600, // How long the slideshow transition takes (in milliseconds)
|
893
|
+
delayBeforeAnimate : 0, // How long to pause slide animation before going to the desired slide (used if you want your "out" FX to show).
|
894
|
+
|
895
|
+
/*
|
896
|
+
// Callbacks - commented out to reduce size of the minified version - they still work
|
897
|
+
onSliderResize : function(e, slider) {}, // Callback when slider resizes
|
898
|
+
onBeforeInitialize : function(e, slider) {}, // Callback before the plugin initializes
|
899
|
+
onInitialized : function(e, slider) {}, // Callback when the plugin finished initializing
|
900
|
+
onShowStart : function(e, slider) {}, // Callback on slideshow start
|
901
|
+
onShowStop : function(e, slider) {}, // Callback after slideshow stops
|
902
|
+
onShowPause : function(e, slider) {}, // Callback when slideshow pauses
|
903
|
+
onShowUnpause : function(e, slider) {}, // Callback when slideshow unpauses - may not trigger properly if user clicks on any controls
|
904
|
+
onSlideInit : function(e, slider) {}, // Callback when slide initiates, before control animation
|
905
|
+
onSlideBegin : function(e, slider) {}, // Callback before slide animates
|
906
|
+
onSlideComplete : function(slider) {}, // Callback when slide completes - no event variable!
|
907
|
+
*/
|
908
|
+
|
909
|
+
// Interactivity
|
910
|
+
clickForwardArrow : "click", // Event used to activate forward arrow functionality (e.g. add jQuery mobile's "swiperight")
|
911
|
+
clickBackArrow : "click", // Event used to activate back arrow functionality (e.g. add jQuery mobile's "swipeleft")
|
912
|
+
clickControls : "click focusin", // Events used to activate navigation control functionality
|
913
|
+
clickSlideshow : "click", // Event used to activate slideshow play/stop button
|
914
|
+
allowRapidChange : false, // If true, allow rapid changing of the active pane, instead of ignoring activity during animation
|
915
|
+
|
916
|
+
// Video
|
917
|
+
resumeOnVideoEnd : true, // If true & the slideshow is active & a supported video is playing, it will pause the autoplay until the video is complete
|
918
|
+
resumeOnVisible : true, // If true the video will resume playing, if previously paused; if false, the video remains paused.
|
919
|
+
isVideoPlaying : function(base){ return false; } // return true if video is playing or false if not - used by video extension
|
920
|
+
|
921
|
+
// deprecated - use the video extension wmode option now
|
922
|
+
// addWmodeToObject : "opaque" // If your slider has a video supported by the extension, the script will automatically add a wmode parameter with this setting
|
923
|
+
|
924
|
+
};
|
925
|
+
|
926
|
+
$.fn.anythingSlider = function(options, callback) {
|
927
|
+
|
928
|
+
return this.each(function(){
|
929
|
+
var page, anySlide = $(this).data('AnythingSlider');
|
930
|
+
|
931
|
+
// initialize the slider but prevent multiple initializations
|
932
|
+
if ((typeof(options)).match('object|undefined')){
|
933
|
+
if (!anySlide) {
|
934
|
+
(new $.anythingSlider(this, options));
|
935
|
+
} else {
|
936
|
+
anySlide.updateSlider();
|
937
|
+
}
|
938
|
+
// If options is a number, process as an external link to page #: $(element).anythingSlider(#)
|
939
|
+
} else if (/\d/.test(options) && !isNaN(options) && anySlide) {
|
940
|
+
page = (typeof(options) === "number") ? options : parseInt($.trim(options),10); // accepts " 2 "
|
941
|
+
// ignore out of bound pages
|
942
|
+
if ( page >= 1 && page <= anySlide.pages ) {
|
943
|
+
anySlide.gotoPage(page, false, callback); // page #, autoplay, one time callback
|
944
|
+
}
|
945
|
+
// Accept id or class name
|
946
|
+
} else if (/^[#|.]/.test(options) && $(options).length) {
|
947
|
+
anySlide.gotoPage(options, false, callback);
|
948
|
+
}
|
949
|
+
});
|
950
|
+
};
|
951
|
+
|
952
|
+
})(jQuery, window, document);
|