Share this diff
1/* 1/*!
2 anythingSlider v1.2 2 AnythingSlider v1.8.17
3 3 Original by Chris Coyier: http://css-tricks.com
4 By Chris Coyier: http://css-tricks.com 4 Get the latest version: https://github.com/CSS-Tricks/AnythingSlider
5 with major improvements by Doug Neiner: http://pixelgraphics.us/  
6 based on work by Remy Sharp: http://jqueryfordesigners.com/  
7  
8 5
9 To use the navigationFormatter function, you must have a function that 6 To use the navigationFormatter function, you must have a function that
10 accepts two paramaters, and returns a string of HTML text. 7 accepts two paramaters, and returns a string of HTML text.
11 8
12 index = integer index (1 based); 9 index = integer index (1 based);
13 panel = jQuery wrapped LI item this tab references 10 panel = jQuery wrapped LI item this tab references
14 @return = Must return a string of HTML/Text 11 @return = Must return a string of HTML/Text
15 12
16 navigationFormatter: function(index, panel){ 13 navigationFormatter: function(index, panel){
17 return index + " Panel"; // This would have each tab with the text 'X Panel' where X = index 14 return "Panel #" + index; // This would have each tab with the text 'Panel #X' where X = index
18 } 15 }
19*/ 16*/
20 17/*jshint browser:true, jquery:true, unused:false */
21(function($){ 18;(function($, win, doc) {
22 19 "use strict";
23 $.anythingSlider = function(el, options){ 20 $.anythingSlider = function(el, options) {
24 // To avoid scope issues, use 'base' instead of 'this' 21
25 // to reference this class from internal events and functions. 22 var base = this, o, t;
26 var base = this; 23
27 24 // Wraps the ul in the necessary divs and then gives Access to jQuery element
28 // Access to jQuery and DOM versions of element 25 base.el = el;
29 base.$el = $(el); 26 base.$el = $(el).addClass('anythingBase').wrap('<div class="anythingSlider"><div class="anythingWindow" /></div>');
30 base.el = el; 27
31 28 // Add a reverse reference to the DOM object
32 // Set up a few defaults 29 base.$el.data("AnythingSlider", base);
33 base.currentPage = 1; 30
34 base.timer = null; 31 base.init = function(){
35 base.playing = false; 32
36 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
37 // Add a reverse reference to the DOM object 34 base.options = o = $.extend({}, $.anythingSlider.defaults, options);
38 base.$el.data("AnythingSlider", base); 35
39 36 base.initialized = false;
40 base.init = function(){ 37 if ($.isFunction(o.onBeforeInitialize)) { base.$el.bind('before_initialize', o.onBeforeInitialize); }
41 base.options = $.extend({},$.anythingSlider.defaults, options); 38 base.$el.trigger('before_initialize', base);
42 39
43 // Cache existing DOM elements for later 40 // Add "as-oldie" class to body for css purposes
44 base.$wrapper = base.$el.find('> div').css('overflow', 'hidden'); 41 $('<!--[if lte IE 8]><script>jQuery("body").addClass("as-oldie");</script><![endif]-->').appendTo('bod
y').remove();
45 base.$slider = base.$wrapper.find('> ul'); 42
46 base.$items = base.$slider.find('> li'); 43 // Cache existing DOM elements for later
47 base.$single = base.$items.filter(':first'); 44 // base.$el = original ul
48 45 // for wrap - get parent() then closest in case the ul has "anythingSlider" class
49 // Build the navigation if needed 46 base.$wrapper = base.$el.parent().closest('div.anythingSlider').addClass('anythingSlider-' + o.theme);
50 if(base.options.buildNavigation) base.buildNavigation(); 47 base.$outer = base.$wrapper.parent();
51 48 base.$window = base.$el.closest('div.anythingWindow');
52 // Get the details 49 base.$win = $(win);
53 base.singleWidth = base.$single.outerWidth(); 50
54 base.pages = base.$items.length; 51 base.$controls = $('<div class="anythingControls"></div>');
55 52 base.$nav = $('<ul class="thumbNav"><li><a><span></span></a></li></ul>');
56 // Top and tail the list with 'visible' number of items, top has the last section, and tail has the first 53 base.$startStop = $('<a href="#" class="start-stop"></a>');
57 // This supports the "infinite" scrolling  
58 base.$items.filter(':first').before(base.$items.filter(':last').clone().addClass
('cloned'));
 
59 base.$items.filter(':last' ).after(base.$items.filter(':first').clone().addClass('cloned'));  
60  
61 // We just added two items, time to re-cache the list  
62 base.$items = base.$slider.find('> li'); // reselect  
63  
64 // Setup our forward/backward navigation  
65 base.buildNextBackButtons();  
66  
67 // If autoPlay functionality is included, then initialize the settings  
68 if(base.options.autoPlay) {  
69 base.playing = !base.options.startStopped; // Sets the playing variable to false if startStopped is true  
70 base.buildAutoPlay();  
71 };  
72 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
73 // If pauseOnHover then add hover effects 113 // If pauseOnHover then add hover effects
74 if(base.options.pauseOnHover) { 114 if (o.pauseOnHover) {
75 base.$el.hover(function(){ 115 base.$wrapper.hover(function() {
76 base.clearTimer(); 116 if (base.playing) {
77 }, function(){ 117 base.$el.trigger('slideshow_paused', base);
78 base.startStop(base.playing); 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 }
79 }); 125 });
80 } 126 }
81  
82 // If a hash can not be used to trigger the plugin, then go to page 1  
83 if((base.options.hashTags == true && !base.gotoHash()) || base.options.hashTags == false){  
84 base.setCurrentPage(1);  
85 };  
86 };  
87 127
88 base.gotoPage = function(page, autoplay){ 128 // Hide/Show navigation & play/stop controls
89 // When autoplay isn't passed, we stop the timer 129 base.slideControls(false);
90 if(autoplay !== true) autoplay = false; 130 base.$wrapper.bind('mouseenter mouseleave', function(e){
91 if(!autoplay) base.startStop(false); 131 // add hovered class to outer wrapper
92 132 $(this)[e.type === 'mouseenter' ? 'addClass' : 'removeClass']('anythingSlider-hovered');
93 if(typeof(page) == "undefined" || page == null) { 133 base.hovered = (e.type === 'mouseenter') ? true : false;
94 page = 1; 134 base.slideControls(base.hovered);
95 base.setCurrentPage(1); 135 });
96 }; 136
97 137 // Add keyboard navigation
98 // Just check for bounds 138 $(doc).keyup(function(e){
99 if(page > base.pages + 1) page = base.pages; 139 // Stop arrow keys from working when focused on form items
100 if(page < 0 ) page = 1; 140 if (o.enableKeyboard && base.$wrapper.hasClass('activeSlider') && !e.target.tagName.match('TEXTAREA|INPUT|SELECT')) {
101 141 if (o.mode !== 'vertical' && (e.which === 38 || e.which === 40)) { return; }
102 var dir = page < base.currentPage ? -1 : 1, 142 switch (e.which) {
103                n = Math.abs(base.currentPage - page), 143 case 39: case 40: // right & down arrow
104                left = base.singleWidth * dir * n; 144 base.goForward();
105 145 break;
106 base.$wrapper.filter(':not(:animated)').animate({ 146 case 37: case 38: // left & up arrow
107                scrollLeft : '+=' + left 147 base.goBack();
108 }, base.options.animationTime, base.options.easing, function () { 148 break;
109                if (page == 0) { 149 }
110                base.$wrapper.scrollLeft(base.singleWidth * base.pages); 150 }
111 page = base.pages; 151 });
112                } else if (page > base.pages) { 152
113                base.$wrapper.scrollLeft(base.singleWidth); 153 // If a hash can not be used to trigger the plugin, then go to start panel - see issue #432
114                // reset back to start position 154 base.currentPage = ((o.hashTags) ? base.gotoHash() : '') || o.startPanel || 1;
115                page = 1; 155 base.gotoPage(base.currentPage, false, null, -1);
116                }; 156
117 base.setCurrentPage(page); 157 // Binds events
118 158 var triggers = "slideshow_paused slideshow_unpaused slide_init slide_begin slideshow_stop slideshow_start initialized swf_completed".split(" ");
119 }); 159 $.each("onShowPause onShowUnpause onSlideInit onSlideBegin onShowStop onShowStart onInitialized onSWFComplete".split(" "), function(i,f){
120 }; 160 if ($.isFunction(o[f])){
121 161 base.$el.bind(triggers[i], o[f]);
122 base.setCurrentPage = function(page, move){ 162 }
123 // Set visual 163 });
124 if(base.options.buildNavigation){ 164 if ($.isFunction(o.onSlideComplete)){
125 base.$nav.find('.cur').removeClass('cur'); 165 // Added setTimeout (zero time) to ensure animation is complete... see this bug report: http://bugs.jquery.com/ticket/7157
126 $(base.$navLinks[page - 1]).addClass('cur'); 166 base.$el.bind('slide_complete', function(){
127 }; 167 setTimeout(function(){ o.onSlideComplete(base); }, 0);
128 168 return false;
129 // Only change left if move does not equal false 169 });
130 if(move !== false) base.$wrapper.scrollLeft(base.singleWidth * page); 170 }
 171 base.initialized = true;
 172 base.$el.trigger('initialized', base);
 173
 174 // trigger the slideshow
 175 base.startStop(o.autoPlay);
131 176
132 // Update local variable  
133 base.currentPage = page;  
134 };  
135  
136 base.goForward = function(autoplay){  
137 if(autoplay !== true) autoplay = false;  
138 base.gotoPage(base.currentPage + 1, autoplay);  
139 };  
140  
141 base.goBack = function(){  
142 base.gotoPage(base.currentPage - 1);  
143 };  
144  
145 // This method tries to find a hash that matches panel-X  
146 // If found, it tries to find a matching item  
147 // If that is found as well, then that item starts visible  
148 base.gotoHash = function(){  
149 if(/^#?panel-\d+$/.test(window.location.hash)){  
150 var index = parseInt(window.location.hash.substr(7));  
151 var $item = base.$items.filter(':eq(' + index + ')');  
152 if($item.length != 0){  
153 base.setCurrentPage(index);  
154 return true;  
155 };  
156 };  
157 return false; // A item wasn't found;  
158 }; 177 };
159 178
160 // Creates the numbered navigation links 179 // called during initialization & to update the slider if a panel is added or deleted
161 base.buildNavigation = function(){ 180 base.updateSlider = function(){
162 base.$nav = $("<div id='thumbNav'></div>").appendTo(base.$el); 181 // needed for updating the slider
163 base.$items.each(function(i,el){ 182 base.$el.children('.cloned').remove();
164 var index = i + 1; 183 base.navTextVisible = base.$nav.find('span:first').css('visibility') !== 'hidden';
165 var $a = $("<a href='#'></a>"); 184 base.$nav.empty();
166 185 // set currentPage to 1 in case it was zero - occurs when adding slides after removing them all
167 // If a formatter function is present, use it 186 base.currentPage = base.currentPage || 1;
168 if( typeof(base.options.navigationFormatter) == "function"){ 187
169 $a.html(base.options.navigationFormatter(index, $(this))); 188 base.$items = base.$el.children();
 189 base.pages = base.$items.length;
 190 base.dir = (o.mode === 'vertical') ? 'top' : 'left';
 191 o.showMultiple = (o.mode === 'vertical') ? 1 : 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') );
170 } else { 230 } else {
171 $a.text(index); 231 base.$el.append( base.$items.filter(':first').clone().addClass('cloned') );
172 } 232 }
173 $a.click(function(e){ 233 base.$el.find('.cloned').each(function(){
174                base.gotoPage(index); 234 // disable all focusable elements in cloned panels to prevent shifting the panels by tabbing
175                235 $(this).find('a,input,textarea,select,button,area,form').attr({ disabled : 'disabled', name : '' });
176                if (base.options.hashTags) 236 $(this).find('[id]').andSelf().removeAttr('id');
177 base.setHash('panel-' + index);  
178  
179                e.preventDefault();  
180 }); 237 });
181 base.$nav.append($a); 238 }
182 }); 239
183 base.$navLinks = base.$nav.find('> a'); 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 var 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;
184 }; 352 };
185 353
186 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
187 // Creates the Forward/Backward buttons 367 // Creates the Forward/Backward buttons
188 base.buildNextBackButtons = function(){ 368 base.buildNextBackButtons = function() {
189 var $forward = $('<a class="arrow forward">&gt;</a>'), 369 base.$forward = $('<span class="arrow forward"><a href="#"><span>' + o.forwardText + '</span></a></span>');
190 $back = $('<a class="arrow back">&lt;</a>'); 370 base.$back = $('<span class="arrow back"><a href="#"><span>' + o.backText + '</span></a></span>');
191 371
192 // Bind to the forward and back buttons 372 // Bind to the forward and back buttons
193 $back.click(function(e){ 373 base.$back.bind(o.clickBackArrow, function(e) {
194                base.goBack(); 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 }
195 e.preventDefault(); 379 e.preventDefault();
196 }); 380 });
197 381 base.$forward.bind(o.clickForwardArrow, function(e) {
198 $forward.click(function(e){ 382 // prevent running functions twice (once for click, second time for swipe)
199                base.goForward(); 383 if (o.enableArrows && !base.flag) {
 384 base.flag = true; setTimeout(function(){ base.flag = false; }, 100);
 385 base.goForward();
 386 }
200 e.preventDefault(); 387 e.preventDefault();
201 }); 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 });
202 393
203 // Append elements to page 394 // Append elements to page
204 base.$wrapper.after($back).after($forward); 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
205 }; 402 };
206 403
207 // Creates the Start/Stop button 404 // Creates the Start/Stop button
208 base.buildAutoPlay = function(){ 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);
 414 }
 415 }
 416 e.preventDefault();
 417 })
 418 // show button has focus while tabbing
 419 .bind('focusin focusout',function(){
 420 $(this).toggleClass('hover');
 421 });
 422 };
209 423
210 base.$startStop = $("<a href='#' id='start-stop'></a>").html(base.playing ? base.options.stopText : base.options.startText); 424 // Adjust slider dimensions on parent element resize
211 base.$el.append(base.$startStop); 425 base.checkResize = function(stopTimer){
212 base.$startStop.click(function(e){ 426 // checking document visibility -
213 base.startStop(!base.playing); 427 var vis = !!(doc.hidden || doc.webkitHidden || doc.mozHidden || doc.msHidden);
214 e.preventDefault(); 428 clearTimeout(base.resizeTimer);
215 }); 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 base.setDimensions(); // adjust panel sizes
 436 // make sure page is lined up (use -1 animation time, so we can differeniate it from when animationTime = 0)
 437 base.gotoPage(base.currentPage, base.playing, null, -1);
 438 }
 439 if (typeof(stopTimer) === 'undefined'){ base.checkResize(); }
 440 // increase time if page is hidden; but don't stop it completely
 441 }, vis ? 2000 : 500);
 442 };
 443
 444 // Set panel dimensions to either resize content or adjust panel to content
 445 base.setDimensions = function(){
 446
 447 // reset element width & height
 448 base.$wrapper.find('.anythingWindow, .anythingBase, .panel').andSelf().css({ width: '', height: '' });
 449 base.width = base.$el.width();
 450 base.height = base.$el.height();
 451 base.outerPad = [ base.$wrapper.innerWidth() - base.$wrapper.width(), base.$wrapper.innerHeight() - base.$wrapper.height() ];
 452
 453 var w, h, c, t, edge = 0,
 454 fullsize = { width: '100%', height: '100%' },
 455 // determine panel width
 456 pw = (o.showMultiple > 1) ? base.width || base.$window.width()/o.showMultiple : base.$window.width(),
 457 winw = base.$win.width();
 458 if (o.expand){
 459 base.lastDim = [ base.$outer.width(), base.$outer.height() ];
 460 w = base.lastDim[0] - base.outerPad[0];
 461 base.height = h = base.lastDim[1] - base.outerPad[1];
 462 base.$wrapper.add(base.$window).css({ width: w, height: h });
 463 base.width = pw = (o.showMultiple > 1) ? w/o.showMultiple : w;
 464 base.$items.css({ width: pw, height: h });
 465 }
 466 base.$items.each(function(i){
 467 t = $(this);
 468 c = t.children();
 469 if (o.resizeContents){
 470 // resize panel
 471 w = base.width;
 472 h = base.height;
 473 t.css({ width: w, height: h });
 474 if (c.length) {
 475 if (c[0].tagName === "EMBED") { c.attr(fullsize); } // needed for IE7; also c.length > 1 in IE7
 476 if (c[0].tagName === "OBJECT") { c.find('embed').attr(fullsize); }
 477 // resize panel contents, if solitary (wrapped content or solitary image)
 478 if (c.length === 1){ c.css(fullsize); }
 479 }
 480 } else {
 481 // get panel width & height and save it
 482 w = t.width() || base.width; // if image hasn't finished loading, width will be zero, so set it to base width instead
 483 if (c.length === 1 && w >= winw){
 484 w = (c.width() >= winw) ? pw : c.width(); // get width of solitary child
 485 c.css('max-width', w); // set max width for all children
 486 }
 487 t.css({ width: w, height: '' }); // set width of panel
 488 h = (c.length === 1 ? c.outerHeight(true) : t.height()); // get height after setting width
 489 if (h <= base.outerPad[1]) { h = base.height; } // if height less than the outside padding, then set it to the preset height
 490 t.css('height', h);
 491 }
 492 base.panelSize[i] = [w,h,edge];
 493 edge += (o.mode === 'vertical') ? h : w;
 494 });
 495 // Set total width of slider
 496 base.$el.css((o.mode === 'vertical' ? 'height' : 'width'), o.mode === 'fade' ? base.width : edge );
 497 };
 498
 499 // get dimension of multiple panels, as needed
 500 base.getDim = function(page){
 501 var i, w = base.width, h = base.height;
 502 if (base.pages < 1 || isNaN(page)) { return [ w, h ]; } // prevent errors when base.panelSize is empty
 503 page = (o.infiniteSlides && base.pages > 1) ? page : page - 1;
 504 i = base.panelSize[page];
 505 if (i) {
 506 w = i[0] || w;
 507 h = i[1] || h;
 508 }
 509 if (o.showMultiple > 1) {
 510 for (i=1; i < o.showMultiple; i++) {
 511 w += base.panelSize[(page + i)][0];
 512 h = Math.max(h, base.panelSize[page + i][1]);
 513 }
 514 }
 515 return [w,h];
 516 };
 517
 518 base.goForward = function(autoplay) {
 519 // targetPage changes before animation so if rapidly changing pages, it will have the correct current page
 520 base.gotoPage(base[ o.allowRapidChange ? 'targetPage' : 'currentPage'] + o.changeBy * (o.playRtl ? -1 : 1), autoplay);
 521 };
 522
 523 base.goBack = function(autoplay) {
 524 base.gotoPage(base[ o.allowRapidChange ? 'targetPage' : 'currentPage'] + o.changeBy * (o.playRtl ? 1 : -1), autoplay);
 525 };
 526
 527 base.gotoPage = function(page, autoplay, callback, time) {
 528 if (autoplay !== true) {
 529 autoplay = false;
 530 base.startStop(false);
 531 base.makeActive();
 532 }
 533 // check if page is an id or class name
 534 if (/^[#|.]/.test(page) && $(page).length) {
 535 page = $(page).closest('.panel').index() + base.adj;
 536 }
 537
 538 // rewind effect occurs here when changeBy > 1
 539 if (o.changeBy !== 1){
 540 var adj = base.pages - base.adjustMultiple;
 541 if (page < 1) {
 542 page = o.stopAtEnd ? 1 : ( o.infiniteSlides ? base.pages + page : ( o.showMultiple > 1 - page ? 1 : adj ) );
 543 }
 544 if (page > base.pages) {
 545 //
 546 page = o.stopAtEnd ? base.pages : ( o.showMultiple > 1 - page ? 1 : page -= adj );
 547 } else if (page >= adj) {
 548 // show multiple adjustments
 549 page = adj;
 550 }
 551 }
 552
 553 if (base.pages <= 1) { return; } // prevents animation
 554 base.$lastPage = base.$currentPage;
 555 if (typeof(page) !== "number") {
 556 page = parseInt(page,10) || o.startPanel;
 557 base.setCurrentPage(page);
 558 }
 559
 560 // pause YouTube videos before scrolling or prevent change if playing
 561 if (autoplay && o.isVideoPlaying(base)) { return; }
 562
 563 base.exactPage = page;
 564 if (page > base.pages + 1 - base.adj) { page = (!o.infiniteSlides && !o.stopAtEnd) ? 1 : base.pages; }
 565 if (page < base.adj ) { page = (!o.infiniteSlides && !o.stopAtEnd) ? base.pages : 1; }
 566 if (!o.infiniteSlides) { base.exactPage = page; } // exact page used by the fx extension
 567 base.currentPage = ( page > base.pages ) ? base.pages : ( page < 1 ) ? 1 : base.currentPage;
 568 base.$currentPage = base.$items.eq(base.currentPage - base.adj);
 569 base.targetPage = (page === 0) ? base.pages : (page > base.pages) ? 1 : page;
 570 base.$targetPage = base.$items.eq(base.targetPage - base.adj);
 571 time = typeof time !== 'undefined' ? time : o.animationTime;
 572 // don't trigger events when time < 0 - to prevent FX from firing multiple times on page resize
 573 if (time >= 0) { base.$el.trigger('slide_init', base); }
 574 // toggle arrows/controls only if there is time to see it - fix issue #317
 575 if (time > 0) { base.slideControls(true); }
 576
 577 // Set visual
 578 if (o.buildNavigation){
 579 base.setNavigation(base.targetPage);
 580 }
 581
 582 // When autoplay isn't passed, we stop the timer
 583 if (autoplay !== true) { autoplay = false; }
 584 // Stop the slider when we reach the last page, if the option stopAtEnd is set to true
 585 if (!autoplay || (o.stopAtEnd && page === base.pages)) { base.startStop(false); }
 586
 587 if (time >= 0) { base.$el.trigger('slide_begin', base); }
 588
 589 // delay starting slide animation
 590 setTimeout(function(d){
 591 var p, empty = true;
 592 if (o.allowRapidChange) {
 593 base.$wrapper.add(base.$el).add(base.$items).stop(true, true);
 594 }
 595 // resize slider if content size varies
 596 if (!o.resizeContents) {
 597 // animating the wrapper resize before the window prevents flickering in Firefox
 598 // don't animate the dimension if it hasn't changed - fix for issue #264
 599 p = base.getDim(page); d = {};
 600 // prevent animating a dimension to zero
 601 if (base.$wrapper.width() !== p[0]) { d.width = p[0] || base.width; empty = false; }
 602 if (base.$wrapper.height() !== p[1]) { d.height = p[1] || base.height; empty = false; }
 603 if (!empty) {
 604 base.$wrapper.filter(':not(:animated)').animate(d, { queue: false, duration: (time < 0 ? 0 : time), easing: o.easing });
 605 }
 606 }
 607
 608 if (o.mode === 'fade') {
 609 if (base.$lastPage[0] !== base.$targetPage[0]) {
 610 base.fadeIt( base.$lastPage, 0, time );
 611 base.fadeIt( base.$targetPage, 1, time, function(){ base.endAnimation(page, callback, time); });
 612 } else {
 613 base.endAnimation(page, callback, time);
 614 }
 615 } else {
 616 d = {};
 617 d[base.dir] = -base.panelSize[(o.infiniteSlides && base.pages > 1) ? page : page - 1][2];
 618 // Animate Slider
 619 base.$el.filter(':not(:animated)').animate(
 620 d, { queue: false, duration: time < 0 ? 0 : time, easing: o.easing, complete: function(){ base.endAnimation(page, callback, time); } }
 621 );
 622 }
 623 }, parseInt(o.delayBeforeAnimate, 10) || 0);
 624 };
 625
 626 base.endAnimation = function(page, callback, time){
 627 if (page === 0) {
 628 base.$el.css( base.dir, o.mode === 'fade' ? 0 : -base.panelSize[base.pages][2]);
 629 page = base.pages;
 630 } else if (page > base.pages) {
 631 // reset back to start position
 632 base.$el.css( base.dir, o.mode === 'fade' ? 0 : -base.panelSize[1][2]);
 633 page = 1;
 634 }
 635 base.exactPage = page;
 636 base.setCurrentPage(page, false);
 637
 638 if (o.mode === 'fade') {
 639 // make sure non current panels are hidden (rapid slide changes)
 640 base.fadeIt( base.$items.not(':eq(' + (page - base.adj) + ')'), 0, 0);
 641 }
 642
 643 if (!base.hovered) { base.slideControls(false); }
 644
 645 if (o.hashTags) { base.setHash(page); }
 646
 647 if (time >= 0) { base.$el.trigger('slide_complete', base); }
 648 // callback from external slide control: $('#slider').anythingSlider(4, function(slider){ })
 649 if (typeof callback === 'function') { callback(base); }
 650
 651 // Continue slideshow after a delay
 652 if (o.autoPlayLocked && !base.playing) {
 653 setTimeout(function(){
 654 base.startStop(true);
 655 // subtract out slide delay as the slideshow waits that additional time.
 656 }, o.resumeDelay - (o.autoPlayDelayed ? o.delay : 0));
 657 }
 658 };
 659
 660 base.fadeIt = function(el, toOpacity, time, callback){
 661 var t = time < 0 ? 0 : time;
 662 if (o.resumeOnVisible) {
 663 el.filter(':not(:animated)').fadeTo(t, toOpacity, callback);
 664 } else {
 665 el.filter(':not(:animated)')[ toOpacity === 0 ? 'fadeOut' : 'fadeIn' ](t, callback);
 666 }
 667 };
 668
 669 base.setCurrentPage = function(page, move) {
 670 page = parseInt(page, 10);
 671
 672 if (base.pages < 1 || page === 0 || isNaN(page)) { return; }
 673 if (page > base.pages + 1 - base.adj) { page = base.pages - base.adj; }
 674 if (page < base.adj ) { page = 1; }
 675
 676 // hide/show arrows based on infinite scroll mode
 677 if (o.buildArrows && !o.infiniteSlides && o.stopAtEnd){
 678 base.$forward[ page === base.pages - base.adjustMultiple ? 'addClass' : 'removeClass']('disabled');
 679 base.$back[ page === 1 ? 'addClass' : 'removeClass']('disabled');
 680 if (page === base.pages && base.playing) { base.startStop(); }
 681 }
 682
 683 // Only change left if move does not equal false
 684 if (!move) {
 685 var d = base.getDim(page);
 686 base.$wrapper
 687 .css({ width: d[0], height: d[1] })
 688 .add(base.$window).scrollLeft(0).scrollTop(0); // reset in case tabbing changed this scrollLeft - probably overly redundant
 689 base.$el.css( base.dir, o.mode === 'fade' ? 0 : -base.panelSize[(o.infiniteSlides && base.pages > 1) ? page : page - 1][2] );
 690 }
 691
 692 // Update local variable
 693 base.currentPage = page;
 694 base.$currentPage = base.$items.removeClass('activePage').eq(page - base.adj).addClass('activePage');
216 695
217 // Use the same setting, but trigger the start; 696 if (o.buildNavigation){
218 base.startStop(base.playing); 697 base.setNavigation(page);
 698 }
 699
 700 };
 701
 702 base.setNavigation = function(page){
 703 base.$nav
 704 .find('.cur').removeClass('cur').end()
 705 .find('a').eq(page - 1).addClass('cur');
 706 };
 707
 708 base.makeActive = function(){
 709 // Set current slider as active so keyboard navigation works properly
 710 if (!base.$wrapper.hasClass('activeSlider')){
 711 $('.activeSlider').removeClass('activeSlider');
 712 base.$wrapper.addClass('activeSlider');
 713 }
 714 };
 715
 716 // This method tries to find a hash that matches an ID and panel-X
 717 // If either found, it tries to find a matching item
 718 // If that is found as well, then it returns the page number
 719 base.gotoHash = function(){
 720 var h = win.location.hash,
 721 i = h.indexOf('&'),
 722 n = h.match(base.regex);
 723 // test for "/#/" or "/#!/" used by the jquery address plugin - $('#/') breaks jQuery
 724 if (n === null && !/^#&/.test(h) && !/#!?\//.test(h) && !/\=/.test(h)) {
 725 // #quote2&panel1-3&panel3-3
 726 h = h.substring(0, (i >= 0 ? i : h.length));
 727 // ensure the element is in the same slider
 728 n = ($(h).length && $(h).closest('.anythingBase')[0] === base.el) ? base.$items.index($(h).closest('.panel')) + base.adj : null;
 729 } else if (n !== null) {
 730 // #&panel1-3&panel3-3
 731 n = (o.hashTags) ? parseInt(n[1],10) : null;
 732 }
 733 return n;
 734 };
 735
 736 base.setHash = function(n){
 737 var s = 'panel' + base.runTimes + '-',
 738 h = win.location.hash;
 739 if ( typeof h !== 'undefined' ) {
 740 win.location.hash = (h.indexOf(s) > 0) ? h.replace(base.regex, s + n) : h + "&" + s + n;
 741 }
219 }; 742 };
220 743
221 // Handles stopping and playing the slideshow 744 // Slide controls (nav and play/stop button up or down)
 745 base.slideControls = function(toggle){
 746 var dir = (toggle) ? 'slideDown' : 'slideUp',
 747 t1 = (toggle) ? 0 : o.animationTime,
 748 t2 = (toggle) ? o.animationTime : 0,
 749 op = (toggle) ? 1 : 0,
 750 sign = (toggle) ? 0 : 1; // 0 = visible, 1 = hidden
 751 if (o.toggleControls) {
 752 base.$controls.stop(true,true).delay(t1)[dir](o.animationTime/2).delay(t2);
 753 }
 754 if (o.buildArrows && o.toggleArrows) {
 755 if (!base.hovered && base.playing) { sign = 1; op = 0; } // don't animate arrows during slideshow
 756 base.$forward.stop(true,true).delay(t1).animate({ right: base.arrowRight + (sign * base.arrowWidth), opacity: op }, o.animationTime/2);
 757 base.$back.stop(true,true).delay(t1).animate({ left: base.arrowLeft + (sign * base.arrowWidth), opacity: op }, o.animationTime/2);
 758 }
 759 };
 760
 761 base.clearTimer = function(paused){
 762 // Clear the timer only if it is set
 763 if (base.timer) {
 764 win.clearInterval(base.timer);
 765 if (!paused && base.slideshow) {
 766 base.$el.trigger('slideshow_stop', base);
 767 base.slideshow = false;
 768 }
 769 }
 770 };
 771
222 // Pass startStop(false) to stop and startStop(true) to play 772 // Pass startStop(false) to stop and startStop(true) to play
223 base.startStop = function(playing){ 773 base.startStop = function(playing, paused) {
224 if(playing !== true) playing = false; // Default if not supplied is false 774 if (playing !== true) { playing = false; } // Default if not supplied is false
225  
226 // Update variable  
227 base.playing = playing; 775 base.playing = playing;
228 776
 777 if (playing && !paused) {
 778 base.$el.trigger('slideshow_start', base);
 779 base.slideshow = true;
 780 }
 781
229 // Toggle playing and text 782 // Toggle playing and text
230 if(base.options.autoPlay) base.$startStop.toggleClass("playing", playing).html( playing ? base.options.stopText : base.options.startText ); 783 if (o.buildStartStop) {
231 784 base.$startStop.toggleClass('playing', playing).find('span').html( playing ? o.stopText : o.startText );
232 if(playing){ 785 // add button text to title attribute if it is hidden by text-indent
233 base.clearTimer(); // Just in case this was triggered twice in a row 786 if ( base.$startStop.find('span').css('visibility') === "hidden" ) {
234 base.timer = window.setInterval(function(){ 787 base.$startStop.addClass(o.tooltipClass).attr( 'title', playing ? o.stopText : o.startText );
235 base.goForward(true); 788 }
236 }, base.options.delay); 789 }
 790
 791 // Pause slideshow while video is playing
 792 if (playing){
 793 base.clearTimer(true); // Just in case this was triggered twice in a row
 794 base.timer = win.setInterval(function() {
 795 if ( !!(doc.hidden || doc.webkitHidden || doc.mozHidden || doc.msHidden) ) {
 796 // stop slideshow if the page isn't visible (issue #463)
 797 if (!o.autoPlayLocked) {
 798 base.startStop();
 799 }
 800 } else if ( !o.isVideoPlaying(base) ) {
 801 // prevent autoplay if video is playing
 802 base.goForward(true);
 803 } else if (!o.resumeOnVideoEnd) {
 804 // stop slideshow if resume if false
 805 base.startStop();
 806 }
 807 }, o.delay);
237 } else { 808 } else {
238 base.clearTimer(); 809 base.clearTimer();
239 }; 810 }
240 };  
241  
242 base.clearTimer = function(){  
243 // Clear the timer only if it is set  
244 if(base.timer) window.clearInterval(base.timer);  
245 };  
246  
247 // Taken from AJAXY jquery.history Plugin  
248 base.setHash = function ( hash ) {  
249 // Write hash  
250 if ( typeof window.location.hash !== 'undefined' ) {  
251 if ( window.location.hash !== hash ) {  
252 window.location.hash = hash;  
253 };  
254 } else if ( location.hash !== hash ) {  
255 location.hash = hash;  
256 };  
257  
258 // Done  
259 return hash;  
260 }; 811 };
261 // <-- End AJAXY code  
262  
263 812
264 // Trigger the initialization 813 // Trigger the initialization
265 base.init(); 814 base.init();
266 }; 815 };
267 816
268 817 $.anythingSlider.defaults = {
269 $.anythingSlider.defaults = { 818 // Appearance
270 easing: "swing",                // Anything other than "linear" or "swing" requires the easing plugin 819 theme : "default", // Theme name, add the css stylesheet manually
271 autoPlay: true,                // This turns off the entire FUNCTIONALY, not just if it starts running or not 820 mode                : "horiz", // Set mode to "horizontal", "vertical" or "fade" (only first letter needed); replaces vertical option
272 startStopped: false, // If autoPlay is on, this can force it to start stopped 821 expand : false, // If true, the entire slider will expand to fit the parent element
273 delay: 3000,                // How long between slide transitions in AutoPlay mode 822 resizeContents : true, // If true, solitary images/objects in the panel will expand to fit the viewport
274 animationTime: 600, // How long the slide transition takes 823 showMultiple : false, // Set this value to a number and it will show that many slides at once
275 hashTags: true,                // Should links change the hashtag in the URL? 824 easing : "swing", // Anything other than "linear" or "swing" requires the easing plugin or jQuery UI
276 buildNavigation: true, // If true, builds and list of anchor links to link to each slide 825
277 pauseOnHover: true, // If true, and autoPlay is enabled, the show will pause on hover 826 buildArrows : true, // If true, builds the forwards and backwards buttons
278 startText: "Start", // Start text 827 buildNavigation : true, // If true, builds a list of anchor links to link to each panel
279 stopText: "Stop", // Stop text 828 buildStartStop : true, // ** If true, builds the start/stop button
280 navigationFormatter: null // Details at the top of the file on this use (advanced use) 829
281 }; 830/*
282 831 // commented out as this will reduce the size of the minified version
283 832 appendForwardTo : null, // Append forward arrow to a HTML element (jQuery Object, selector or HTMLNode), if not null
284 $.fn.anythingSlider = function(options){ 833 appendBackTo : null, // Append back arrow to a HTML element (jQuery Object, selector or HTMLNode), if not null
285 if(typeof(options) == "object"){ 834 appendControlsTo : null, // Append controls (navigation + start-stop) to a HTML element (jQuery Object, selector or HTMLNode), if not null
286 return this.each(function(i){ 835 appendNavigationTo : null, // Append navigation buttons to a HTML element (jQuery Object, selector or HTMLNode), if not null
287 (new $.anythingSlider(this, options)); 836 appendStartStopTo : null, // Append start-stop button to a HTML element (jQuery Object, selector or HTMLNode), if not null
288 837*/
289 // This plugin supports multiple instances, but only one can support hash-tag support 838
290 // This disables hash-tags on all items but the first one 839 toggleArrows : false, // If true, side navigation arrows will slide out on hovering & hide @ other times
291 options.hashTags = false; 840 toggleControls : false, // if true, slide in controls (navigation + play/stop button) on hover and slide change, hide @ other times
292 }); 841
293 } else if (typeof(options) == "number") { 842 startText : "Start", // Start button text
294 843 stopText : "Stop", // Stop button text
295 return this.each(function(i){ 844 forwardText : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
296 var anySlide = $(this).data('AnythingSlider'); 845 backText : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)
297 if(anySlide){ 846 tooltipClass : "tooltip", // Class added to navigation & start/stop button (text copied to title if it is hidden by a negative text indent)
298 anySlide.gotoPage(options); 847
 848 // Function
 849 enableArrows : true, // if false, arrows will be visible, but not clickable.
 850 enableNavigation : true, // if false, navigation links will still be visible, but not clickable.
 851 enableStartStop : true, // if false, the play/stop button will still be visible, but not clickable. Previously "enablePlay"
 852 enableKeyboard : true, // if false, keyboard arrow keys will not work for this slider.
 853
 854 // Navigation
 855 startPanel : 1, // This sets the initial panel
 856 changeBy : 1, // Amount to go forward or back when changing panels.
 857 hashTags : true, // Should links change the hashtag in the URL?
 858 infiniteSlides : true, // if false, the slider will not wrap & not clone any panels
 859 navigationFormatter : null, // Details at the top of the file on this use (advanced use)
 860 navigationSize : false, // Set this to the maximum number of visible navigation tabs; false to disable
 861
 862 // Slideshow options
 863 autoPlay : false, // If true, the slideshow will start running; replaces "startStopped" option
 864 autoPlayLocked : false, // If true, user changing slides will not stop the slideshow
 865 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
 866 pauseOnHover : true, // If true & the slideshow is active, the slideshow will pause on hover
 867 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.
 868 playRtl : false, // If true, the slideshow will move right-to-left
 869
 870 // Times
 871 delay : 3000, // How long between slideshow transitions in AutoPlay mode (in milliseconds)
 872 resumeDelay : 15000, // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
 873 animationTime : 600, // How long the slideshow transition takes (in milliseconds)
 874 delayBeforeAnimate : 0, // How long to pause slide animation before going to the desired slide (used if you want your "out" FX to show).
 875
 876/*
 877 // Callbacks - commented out to reduce size of the minified version - they still work
 878 onBeforeInitialize : function(e, slider) {}, // Callback before the plugin initializes
 879 onInitialized : function(e, slider) {}, // Callback when the plugin finished initializing
 880 onShowStart : function(e, slider) {}, // Callback on slideshow start
 881 onShowStop : function(e, slider) {}, // Callback after slideshow stops
 882 onShowPause : function(e, slider) {}, // Callback when slideshow pauses
 883 onShowUnpause : function(e, slider) {}, // Callback when slideshow unpauses - may not trigger properly if user clicks on any controls
 884 onSlideInit : function(e, slider) {}, // Callback when slide initiates, before control animation
 885 onSlideBegin : function(e, slider) {}, // Callback before slide animates
 886 onSlideComplete : function(slider) {}, // Callback when slide completes - no event variable!
 887*/
 888
 889 // Interactivity
 890 clickForwardArrow : "click", // Event used to activate forward arrow functionality (e.g. add jQuery mobile's "swiperight")
 891 clickBackArrow : "click", // Event used to activate back arrow functionality (e.g. add jQuery mobile's "swipeleft")
 892 clickControls : "click focusin", // Events used to activate navigation control functionality
 893 clickSlideshow : "click", // Event used to activate slideshow play/stop button
 894 allowRapidChange : false, // If true, allow rapid changing of the active pane, instead of ignoring activity during animation
 895
 896 // Video
 897 resumeOnVideoEnd : true, // If true & the slideshow is active & a supported video is playing, it will pause the autoplay until the video is complete
 898 resumeOnVisible : true, // If true the video will resume playing (if previously paused, except for YouTube iframe - known issue); if false, the video remains paused.
 899 addWmodeToObject : "opaque", // If your slider has an embedded object, the script will automatically add a wmode parameter with this setting
 900 isVideoPlaying : function(base){ return false; } // return true if video is playing or false if not - used by video extension
 901
 902 };
 903
 904 $.fn.anythingSlider = function(options, callback) {
 905
 906 return this.each(function(){
 907 var page, anySlide = $(this).data('AnythingSlider');
 908
 909 // initialize the slider but prevent multiple initializations
 910 if ((typeof(options)).match('object|undefined')){
 911 if (!anySlide) {
 912 (new $.anythingSlider(this, options));
 913 } else {
 914 anySlide.updateSlider();
299 } 915 }
300 }); 916 // If options is a number, process as an external link to page #: $(element).anythingSlider(#)
301 } 917 } else if (/\d/.test(options) && !isNaN(options) && anySlide) {
302 }; 918 page = (typeof(options) === "number") ? options : parseInt($.trim(options),10); // accepts " 2 "
 919 // ignore out of bound pages
 920 if ( page >= 1 && page <= anySlide.pages ) {
 921 anySlide.gotoPage(page, false, callback); // page #, autoplay, one time callback
 922 }
 923 // Accept id or class name
 924 } else if (/^[#|.]/.test(options) && $(options).length) {
 925 anySlide.gotoPage(options, false, callback);
 926 }
 927 });
 928 };
303 929
304 930})(jQuery, window, document);
305})(jQuery); 
ORIGINAL TEXT
CHANGED TEXT