/* AnythingSlider v1.4 By Chris Coyier: http://css-tricks.com with major improvements by Doug Neiner: http://pixelgraphics.us/ based on work by Remy Sharp: http://jqueryfordesigners.com/ To use the navigationFormatter function, you must have a function that accepts two paramaters, and returns a string of HTML text. index = integer index (1 based); panel = jQuery wrapped LI item this tab references @return = Must return a string of HTML/Text navigationFormatter: function(index, panel){ return "Panel #" + index; // This would have each tab with the text 'Panel #X' where X = index } */ (function($) { $.anythingSlider = function(el, options) { // To avoid scope issues, use 'base' instead of 'this' // to reference this class from internal events and functions. var base = this; // Wraps the ul in the necessary divs and then gives Access to jQuery element base.$el = $(el).addClass('anythingBase').wrap('
'); // Add a reverse reference to the DOM object base.$el.data("AnythingSlider", base); base.init = function(){ base.options = $.extend({},$.anythingSlider.defaults, options); // Cache existing DOM elements for later // base.$el = original ul base.$wrapper = base.$el.parent().closest('div.anythingSlider'); // parent() then closest incase the ul has anythingSlider class base.$window = base.$el.closest('div.anythingWindow'); base.$items = base.$el.find('> li').addClass('panel'); base.$objects = base.$items.find('object'); base.$dimensions = []; // Set up a few defaults & get details base.currentPage = base.options.startPanel; base.timer = null; base.playing = false; base.pages = base.$items.length; base.$objlen = !!base.$objects.length; // Get index (run time) of this slider on the page base.runTimes = $('div.anythingSlider').index(base.$wrapper) + 1; // Make sure easing function exists. if (!$.isFunction($.easing[base.options.easing])) { base.options.easing = "swing"; } // Set the dimensions if (base.options.resizeContents) { if (base.options.width) { base.$wrapper.css('width', base.options.width); base.$items.css('width', base.options.width); } if (base.options.height) { base.$wrapper.css('height', base.options.height); base.$items.css('height', base.options.height); } if (base.$objlen){ base.$objects.find('embed').andSelf().css({ width : '100%', height: '100%' }); } } // initialize youtube api - doesn't work in IE (someone have a solution?) base.$objects.each(function(){ if ($(this).find('[src*=youtube]').length){ $(this).parent() .wrap('
') .find('embed[src*=youtube]').attr('src', function(i,s){ return s + '&enablejsapi=1&version=3'; }).end() .find('param[value*=youtube]').attr('value', function(i,v){ return v + '&enablejsapi=1&version=3'; }).end() // detach/appendTo required for Chrome .detach() .appendTo($('#yt-temp')) .unwrap(); } }); // Remove navigation & player if there is only one page if (base.pages === 1) { base.options.autoPlay = false; base.options.buildNavigation = false; base.options.buildArrows = false; } // If autoPlay functionality is included, then initialize the settings if (base.options.autoPlay) { base.playing = !base.options.startStopped; // Sets the playing variable to false if startStopped is true base.buildAutoPlay(); } // Build the navigation base.buildNavigation(); // Top and tail the list with 'visible' number of items, top has the last section, and tail has the first // This supports the "infinite" scrolling // Ensures any cloned elements with ID's have unique ID's var $itemClone = base.$items.filter(':last').clone().addClass('cloned'); base.$items.filter(':first').before( $itemClone.attr('id', function(i,id){ return (id==='') ? '' : id + "-cloned"; }) ); $itemClone = base.$items.filter(':first').clone().addClass('cloned'); base.$items.filter(':last' ).after($itemClone.attr('id', function(i,id){ return (id==='') ? '' : id + "-cloned"; }) ); // We just added two items, time to re-cache the list, then get the dimensions of each panel base.$items = base.$el.find('> li'); // reselect base.setDimensions(); if (!base.options.resizeContents) { $(window).load(function(){ base.setDimensions(); }); } // set dimensions after all images load // Build forwards/backwards buttons if (base.options.buildArrows) { base.buildNextBackButtons(); } // If pauseOnHover then add hover effects if (base.options.pauseOnHover) { base.$wrapper.hover(function() { base.clearTimer(); }, function() { base.startStop(base.playing); }); } // If a hash can not be used to trigger the plugin, then go to start panel if ((base.options.hashTags === true && !base.gotoHash()) || base.options.hashTags === false) { base.setCurrentPage(base.options.startPanel, false); } // Fix tabbing through the page base.$items.find('a').focus(function(){ base.$items.find('.focusedLink').removeClass('focusedLink'); $(this).addClass('focusedLink'); base.$items.each(function(i){ if ($(this).find('a.focusedLink').length) { base.gotoPage(i); return false; } }); }); // Add keyboard navigation $(window).keyup(function(e){ if (base.$wrapper.is('.activeSlider')) { switch (e.which) { case 39: // right arrow base.goForward(); break; case 37: //left arrow base.goBack(); break; } } }); }; // Creates the numbered navigation links base.buildNavigation = function() { base.$nav = $('