Untitled diff

Created Diff never expires
268 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
305 lines
558 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
595 lines
/*
/*!
anythingSlider v1.2
AnythingSlider v1.8.17
Original by Chris Coyier: http://css-tricks.com
By Chris Coyier: http://css-tricks.com
Get the latest version: https://github.com/CSS-Tricks/AnythingSlider
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
To use the navigationFormatter function, you must have a function that
accepts two paramaters, and returns a string of HTML text.
accepts two paramaters, and returns a string of HTML text.
index = integer index (1 based);
index = integer index (1 based);
panel = jQuery wrapped LI item this tab references
panel = jQuery wrapped LI item this tab references
@return = Must return a string of HTML/Text
@return = Must return a string of HTML/Text
navigationFormatter: function(index, panel){
navigationFormatter: function(index, panel){
return index + " Panel"; // This would have each tab with the text 'X Panel' where X = index
return "Panel #" + index; // This would have each tab with the text 'Panel #X' where X = index
}
}
*/
*/
/*jshint browser:true, jquery:true, unused:false */
;(function($, win, doc) {
"use strict";
$.anythingSlider = function(el, options) {
(function($){
var base = this, o, t;
$.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;
// Access to jQuery and DOM versions of element
base.$el = $(el);
base.el = el;
// Set up a few defaults
// Wraps the ul in the necessary divs and then gives Access to jQuery element
base.currentPage = 1;
base.el = el;
base.timer = null;
base.$el = $(el).addClass('anythingBase').wrap('<div class="anythingSlider"><div class="anythingWindow" /></div>');
base.playing = false;
// Add a reverse reference to the DOM object
// Add a reverse reference to the DOM object
base.$el.data("AnythingSlider", base);
base.$el.data("AnythingSlider", base);
base.init = function(){
base.options = $.extend({},$.anythingSlider.defaults, options);
// Cache existing DOM elements for later
base.$wrapper = base.$el.find('> div').css('overflow', 'hidden');
base.$slider = base.$wrapper.find('> ul');
base.$items = base.$slider.find('> li');
base.$single = base.$items.filter(':first');
// Build the navigation if needed
base.init = function(){
if(base.options.buildNavigation) base.buildNavigation();
// Get the details
base.singleWidth = base.$single.outerWidth();
base.pages = base.$items.length;
// Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
// Added "o" to be used in the code instead of "base.options" which doesn't get modifed by the compiler - reduces size by ~1k
// This supports the "infinite" scrolling
base.options = o = $.extend({}, $.anythingSlider.defaults, options);
base.$items.filter(':first').before(base.$items.filter(':last').clone().addClass('cloned'));
base.$items.filter(':last' ).after(base.$items.filter(':first').clone().addClass('cloned'));
// We just added two items, time to re-cache the list
base.initialized = false;
base.$items = base.$slider.find('> li'); // reselect
if ($.isFunction(o.onBeforeInitialize)) { base.$el.bind('before_initialize', o.onBeforeInitialize); }
base.$el.trigger('before_initialize', base);
// Setup our forward/backward navigation
base.buildNextBackButtons();
// Add "as-oldie" class to body for css purposes
$('<!--[if lte IE 8]><script>jQuery("body").addClass("as-oldie");</script><![endif]-->').appendTo('body').remove();
// If autoPlay functionality is included, then initialize the settings
if(base.options.autoPlay) {
// Cache existing DOM elements for later
base.playing = !base.options.startStopped; // Sets the playing variable to false if startStopped is true
// base.$el = original ul
base.buildAutoPlay();
// for wrap - get parent() then closest in case the ul has "anythingSlider" class
};
base.$wrapper = base.$el.parent().closest('div.anythingSlider').addClass('anythingSlider-' + o.theme);
base.$outer = base.$wrapper.parent();
base.$window = base.$el.closest('div.anythingWindow');
base.$win = $(win);
base.$controls = $('<div class="anythingControls"></div>');
base.$nav = $('<ul class="thumbNav"><li><a><span></span></a></li></ul>');
base.$startStop = $('<a href="#" class="start-stop"></a>');
if (o.buildStartStop || o.buildNavigation) {
base.$controls.appendTo( (o.appendControlsTo && $(o.appendControlsTo).length) ? $(o.appendControlsTo) : base.$wrapper);
}
if (o.buildNavigation) {
base.$nav.appendTo( (o.appendNavigationTo && $(o.appendNavigationTo).length) ? $(o.appendNavigationTo) : base.$controls );
}
if (o.buildStartStop) {
base.$startStop.appendTo( (o.appendStartStopTo && $(o.appendStartStopTo).length) ? $(o.appendStartStopTo) : base.$controls );
}
// Figure out how many sliders are on the page for indexing
base.runTimes = $('.anythingBase').length;
// hash tag regex - fixes issue #432
base.regex = (o.hashTags) ? new RegExp('panel' + base.runTimes + '-(\\d+)', 'i') : null;
if (base.runTimes === 1) { base.makeActive(); } // make the first slider on the page active
// Set up a few defaults & get details
base.flag = false; // event flag to prevent multiple calls (used in control click/focusin)
if (o.autoPlayLocked) { o.autoPlay = true; } // if autoplay is locked, start playing
base.playing = o.autoPlay; // slideshow state; removed "startStopped" option
base.slideshow = false; // slideshow flag needed to correctly trigger slideshow events
base.hovered = false; // actively hovering over the slider
base.panelSize = []; // will contain dimensions and left position of each panel
base.currentPage = base.targetPage = o.startPanel = parseInt(o.startPanel,10) || 1; // make sure this isn't a string
o.changeBy = parseInt(o.changeBy,10) || 1;
// set slider type, but keep backward compatibility with the vertical option
t = (o.mode || 'h').toLowerCase().match(/(h|v|f)/);
t = o.vertical ? 'v' : (t || ['h'])[0];
o.mode = t === 'v' ? 'vertical' : t === 'f' ? 'fade' : 'horizontal';
if (t === 'f') {
o.showMultiple = 1; // all slides are stacked in fade mode
o.infiniteSlides = false; // no cloned slides
}
base.adj = (o.infiniteSlides) ? 0 : 1; // adjust page limits for infinite or limited modes
base.adjustMultiple = 0;
if (o.playRtl) { base.$wrapper.addClass('rtl'); }
// Build start/stop button
if (o.buildStartStop) { base.buildAutoPlay(); }
// Build forwards/backwards buttons
if (o.buildArrows) { base.buildNextBackButtons(); }
base.$lastPage = base.$targetPage = base.$currentPage;
base.updateSlider();
// Expand slider to fit parent
if (o.expand) {
base.$window.css({ width: '100%', height: '100%' }); // needed for Opera
base.checkResize();
}
// Make sure easing function exists.
if (!$.isFunction($.easing[o.easing])) { o.easing = "swing"; }
// If pauseOnHover then add hover effects
// If pauseOnHover then add hover effects
if(base.options.pauseOnHover) {
if (o.pauseOnHover) {
base.$el.hover(function(){
base.$wrapper.hover(function() {
base.clearTimer();
if (base.playing) {
}, function(){
base.$el.trigger('slideshow_paused', base);
base.startStop(base.playing);
base.clearTimer(true);
}
}, function() {
if (base.playing) {
base.$el.trigger('slideshow_unpaused', base);
base.startStop(base.playing, true);
}
});
});
}
}
// If a hash can not be used to trigger the plugin, then go to page 1
if((base.options.hashTags == true && !base.gotoHash()) || base.options.hashTags == false){
base.setCurrentPage(1);
};
};
base.gotoPage = function(page, autoplay){
// Hide/Show navigation & play/stop controls
// When autoplay isn't passed, we stop the timer
base.slideControls(false);
if(autoplay !== true) autoplay = false;
base.$wrapper.bind('mouseenter mouseleave', function(e){
if(!autoplay) base.startStop(false);
// add hovered class to outer wrapper
$(this)[e.type === 'mouseenter' ? 'addClass' : 'removeClass']('anythingSlider-hovered');
if(typeof(page) == "undefined" || page == null) {
base.hovered = (e.type === 'mouseenter') ? true : false;
page = 1;
base.slideControls(base.hovered);
base.setCurrentPage(1);
});
};
// Just check for bounds
if(page > base.pages + 1) page = base.pages;
if(page < 0 ) page = 1;
var dir = page < base.currentPage ? -1 : 1,
// Add keyboard navigation
n = Math.abs(base.currentPage - page),
$(doc).keyup(function(e){
left = base.singleWidth * dir * n;
// Stop arrow keys from working when focused on form items
if (o.enableKeyboard && base.$wrapper.hasClass('activeSlider') && !e.target.tagName.match('TEXTAREA|INPUT|SELECT')) {
base.$wrapper.filter(':not(:animated)').animate({
if (o.mode !== 'vertical' && (e.which === 38 || e.which === 40)) { return; }
scrollLeft : '+=' + left
switch (e.which) {
}, base.options.animationTime, base.options.easing, function () {
case 39: case 40: // right & down arrow
if (page == 0) {
base.goForward();
base.$wrapper.scrollLeft(base.singleWidth * base.pages);
break;
page = base.pages;
case 37: case 38: // left & up arrow
} else if (page > base.pages) {
base.goBack();
base.$wrapper.scrollLeft(base.singleWidth);
break;
// reset back to start position
}
page = 1;
}
};
});
base.setCurrentPage(page);
});
};
base.setCurrentPage = function(page, move){
// Set visual
if(base.options.buildNavigation){
base.$nav.find('.cur').removeClass('cur');
$(base.$navLinks[page - 1]).addClass('cur');
};
// Only change left if move does not equal false
if(move !== false) base.$wrapper.scrollLeft(base.singleWidth * page);
// Update local variable
// If a hash can not be used to trigger the plugin, then go to start panel - see issue #432
base.currentPage = page;
base.currentPage = ((o.hashTags) ? base.gotoHash() : '') || o.startPanel || 1;
base.gotoPage(base.currentPage, false, null, -1);
// Binds events
var triggers = "slideshow_paused slideshow_unpaused slide_init slide_begin slideshow_stop slideshow_start initialized swf_completed".split(" ");
$.each("onShowPause onShowUnpause onSlideInit onSlideBegin onShowStop onShowStart onInitialized onSWFComplete".split(" "), function(i,f){
if ($.isFunction(o[f])){
base.$el.bind(triggers[i], o[f]);
}
});
if ($.isFunction(o.onSlideComplete)){
// Added setTimeout (zero time) to ensure animation is complete... see this bug report: http://bugs.jquery.com/ticket/7157
base.$el.bind('slide_complete', function(){
setTimeout(function(){ o.onSlideComplete(base); }, 0);
return false;
});
}
base.initialized = true;
base.$el.trigger('initialized', base);
// trigger the slideshow
base.startStop(o.autoPlay);
};
};
base.goForward = function(autoplay){
// called during initialization & to update the slider if a panel is added or deleted
if(autoplay !== true) autoplay = false;
base.updateSlider = function(){
base.gotoPage(base.currentPage + 1, autoplay);
// needed for updating the slider
base.$el.children('.cloned').remove();
base.navTextVisible = base.$nav.find('span:first').css('visibility') !== 'hidden';
base.$nav.empty();
// set currentPage to 1 in case it was zero - occurs when adding slides after removing them all
base.currentPage = base.currentPage || 1;
base.$items = base.$el.children();
base.pages = base.$items.length;
base.dir = (o.mode === 'vertical') ? 'top' : 'left';
o.showMultiple = (o.mode === 'vertical') ? 1 : parseInt(o.showMultiple,10) || 1; // only integers allowed
o.navigationSize = (o.navigationSize === false) ? 0 : parseInt(o.navigationSize,10) || 0;
// Fix tabbing through the page, but don't change the view if the link is in view (showMultiple = true)
base.$items.find('a').unbind('focus.AnythingSlider').bind('focus.AnythingSlider', function(e){
var panel = $(this).closest('.panel'),
indx = base.$items.index(panel) + base.adj; // index can be -1 in nested sliders - issue #208
base.$items.find('.focusedLink').removeClass('focusedLink');
$(this).addClass('focusedLink');
base.$window.scrollLeft(0).scrollTop(0);
if ( ( indx !== -1 && (indx >= base.currentPage + o.showMultiple || indx < base.currentPage) ) ) {
base.gotoPage(indx);
e.preventDefault();
}
});
if (o.showMultiple > 1) {
if (o.showMultiple > base.pages) { o.showMultiple = base.pages; }
base.adjustMultiple = (o.infiniteSlides && base.pages > 1) ? 0 : o.showMultiple - 1;
}
// Hide navigation & player if there is only one page
base.$controls
.add(base.$nav)
.add(base.$startStop)
.add(base.$forward)
.add(base.$back)[(base.pages <= 1) ? 'hide' : 'show']();
if (base.pages > 1) {
// Build/update navigation tabs
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, also ensures any cloned elements don't duplicate an ID
// Moved removeAttr before addClass otherwise IE7 ignores the addClass: http://bugs.jquery.com/ticket/9871
if (o.mode !== 'fade' && o.infiniteSlides && base.pages > 1) {
base.$el.prepend( base.$items.filter(':last').clone().addClass('cloned') );
// Add support for multiple sliders shown at the same time
if (o.showMultiple > 1) {
base.$el.append( base.$items.filter(':lt(' + o.showMultiple + ')').clone().addClass('cloned multiple') );
} else {
base.$el.append( base.$items.filter(':first').clone().addClass('cloned') );
}
base.$el.find('.cloned').each(function(){
// disable all focusable elements in cloned panels to prevent shifting the panels by tabbing
$(this).find('a,input,textarea,select,button,area,form').attr({ disabled : 'disabled', name : '' });
$(this).find('[id]').andSelf().removeAttr('id');
});
}
// We just added two items, time to re-cache the list, then get the dimensions of each panel
base.$items = base.$el.addClass(o.mode).children().addClass('panel');
base.setDimensions();
// Set the dimensions of each panel
if (o.resizeContents) {
base.$items.css('width', base.width);
base.$wrapper
.css('width', base.getDim(base.currentPage)[0])
.add(base.$items).css('height', base.height);
} else {
base.$win.load(function(){
// set dimensions after all images load
base.setDimensions();
// make sure the outer wrapper is set properly
t = base.getDim(base.currentPage);
base.$wrapper.css({ width: t[0], height: t[1] });
base.setCurrentPage(base.currentPage, false);
});
}
if (base.currentPage > base.pages) {
base.currentPage = base.pages;
}
base.setCurrentPage(base.currentPage, false);
base.$nav.find('a').eq(base.currentPage - 1).addClass('cur'); // update current selection
if (o.mode === 'fade') {
var t = base.$items.eq(base.currentPage-1);
if (o.resumeOnVisible) {
// prevent display: none;
t.css({ opacity: 1 }).siblings().css({ opacity: 0 });
} else {
// allow display: none; - resets video
base.$items.css('opacity',1);
t.fadeIn(0).siblings().fadeOut(0);
}
}
};
};
base.goBack = function(){
// Creates the numbered navigation links
base.gotoPage(base.currentPage - 1);
base.buildNavigation = function() {
if (o.buildNavigation && (base.pages > 1)) {
var a, c, i, t, $li;
base.$items.filter(':not(.cloned)').each(function(j){
$li = $('<li/>');
i = j + 1;
c = (i === 1 ? ' first' : '') + (i === base.pages ? ' last' : '');
a = '<a class="panel' + i + ( base.navTextVisible ? '"' : ' ' + o.tooltipClass + '" title="@"' ) + ' href="#"><span>@</span></a>';
// If a formatter function is present, use it
if ($.isFunction(o.navigationFormatter)) {
t = o.navigationFormatter(i, $(this));
if (typeof(t) === "string") {
$li.html(a.replace(/@/g,t));
} else {
$li = $('<li/>', t);
}
} else {
$li.html(a.replace(/@/g,i));
}
$li
.appendTo(base.$nav)
.addClass(c)
.data('index', i);
});
base.$nav.children('li').bind(o.clickControls, function(e) {
if (!base.flag && o.enableNavigation) {
// prevent running functions twice (once for click, second time for focusin)
base.flag = true; setTimeout(function(){ base.flag = false; }, 100);
base.gotoPage( $(this).data('index') );
}
e.preventDefault();
});
// Add navigation tab scrolling - use !! in case someone sets the size to zero
if (!!o.navigationSize && o.navigationSize < base.pages) {
if (!base.$controls.find('.anythingNavWindow').length){
base.$nav
.before('<ul><li class="prev"><a href="#"><span>' + o.backText + '</span></a></li></ul>')
.after('<ul><li class="next"><a href="#"><span>' + o.forwardText + '</span></a></li></ul>')
.wrap('<div class="anythingNavWindow"></div>');
}
// include half of the left position to include extra width from themes like tabs-light and tabs-dark (still not perfect)
base.navWidths = base.$nav.find('li').map(function(){
return $(this).outerWidth(true) + Math.ceil(parseInt($(this).find('span').css('left'),10)/2 || 0);
}).get();
base.navLeft = base.currentPage;
// add 25 pixels (old IE needs more than 5) to make sure the tabs don't wrap to the next line
base.$nav.width( base.navWidth( 1, base.pages + 1 ) + 25 );
base.$controls.find('.anythingNavWindow')
.width( base.navWidth( 1, o.navigationSize + 1 ) ).end()
.find('.prev,.next').bind(o.clickControls, function(e) {
if (!base.flag) {
base.flag = true; setTimeout(function(){ base.flag = false; }, 200);
base.navWindow( base.navLeft + o.navigationSize * ( $(this).is('.prev') ? -1 : 1 ) );
}
e.preventDefault();
});
}
}
};
};
// This method tries to find a hash that matches panel-X
base.navWidth = function(x,y){
// If found, it tries to find a matching item
var i, s = Math.min(x,y),
// If that is found as well, then that item starts visible
e = Math.max(x,y),
base.gotoHash = function(){
w = 0;
if(/^#?panel-\d+$/.test(window.location.hash)){
for (i = s; i < e; i++) {
var index = parseInt(window.location.hash.substr(7));
w += base.navWidths[i-1] || 0;
var $item = base.$items.filter(':eq(' + index + ')');
}
if($item.length != 0){
return w;
base.setCurrentPage(index);
return true;
};
};
return false; // A item wasn't found;
};
};
// Creates the numbered navigation links
base.navWindow = function(n){
base.buildNavigation = function(){
if (!!o.navigationSize && o.navigationSize < base.pages && base.navWidths) {
base.$nav = $("<div id='thumbNav'></div>").appendTo(base.$el);
var p = base.pages - o.navigationSize + 1;
base.$items.each(function(i,el){
n = (n <= 1) ? 1 : (n > 1 && n < p) ? n : p;
var index = i + 1;
if (n !== base.navLeft) {
var $a = $("<a href='#'></a>");
base.$controls.find('.anythingNavWindow').animate(
{ scrollLeft: base.navWidth(1, n), width: base.navWidth(n, n + o.navigationSize) },
// If a formatter function is present, use it
{ queue: false, duration: o.animationTime });
if( typeof(base.options.navigationFormatter) == "function"){
base.navLeft = n;
$a.html(base.options.navigationFormatter(index, $(this)));
} else {
$a.text(index);
}
}
$a.click(function(e){
}
base.gotoPage(index);
if (base.options.hashTags)
base.setHash('panel-' + index);
e.preventDefault();
});
base.$nav.append($a);
});
base.$navLinks = base.$nav.find('> a');
};
};
// Creates the Forward/Backward buttons
// Creates the Forward/Backward buttons
base.buildNextBackButtons = function(){
base.buildNextBackButtons = function() {
var $forward = $('<a class="arrow forward">&gt;</a>'),
base.$forward = $('<span class="arrow forward"><a href="#"><span>' + o.forwardText + '</span></a></span>');
$back = $('<a class="arrow back">&lt;</a>');
base.$back = $('<span class="arrow back"><a href="#"><span>' + o.backText + '</span></a></span>');
// Bind to the forward and back buttons
// Bind to the forward and back buttons
$back.click(function(e){
base.$back.bind(o.clickBackArrow, function(e) {
base.goBack();
// prevent running functions twice (once for click, second time for swipe)
if (o.enableArrows && !base.flag) {
base.flag = true; setTimeout(function(){ base.flag = false; }, 100);
base.goBack();
}
e.preventDefault();
e.preventDefault();
});
});
base.$forward.bind(o.clickForwardArrow, function(e) {
$forward.click(function(e){
// prevent running functions twice (once for click, second time for swipe)
base.goForward();
if (o.enableArrows && !base.flag) {
base.flag = true; setTimeout(function(){ base.flag = false; }, 100);
base.goForward();
}
e.preventDefault();
e.preventDefault();
});
});
// using tab to get to arrow links will show they have focus (outline is disabled in css)
base.$back.add(base.$forward).find('a').bind('focusin focusout',function(){
$(this).toggleClass('hover');
});
// Append elements to page
// Append elements to page
base.$wrapper.after($back).after($forward);
base.$back.appendTo( (o.appendBackTo && $(o.appendBackTo).length) ? $(o.appendBackTo) : base.$wrapper );
base.$forward.appendTo( (o.appendForwardTo && $(o.appendForwardTo).length) ? $(o.appendForwardTo) : base.$wrapper );
base.arrowWidth = base.$forward.width(); // assuming the left & right arrows are the same width - used for toggle
base.arrowRight = parseInt(base.$forward.css('right'), 10);
base.arrowLeft = parseInt(base.$back.css('left'), 10);
};
};
// Creates the Start/Stop button
// Creates the Start/Stop button
base.buildAutoPlay = function(){
base.buildAutoPlay = function(){
base.$startStop
.html('<span>' + (base.playing ? o.stopText : o.startText) + '</span>')
.bind(o.clickSlideshow, function(e) {
if (o.enableStartStop) {
base.startStop(!base.playing);
base.makeActive();
if (base.playing && !o.autoPlayDelayed) {
base.goForward(true);
}
}
e.preventDefault();
})
// show button has focus while tabbing
.bind('focusin focusout',function(){
$(this).toggleClass('hover');
});
};
base.$startStop = $("<a href='#' id='start-stop'></a>").html(base.playing ? base.options.stopText : base.options.startText);
// Adjust slider dimensions on parent element resize
base.$el.append(base.$startStop);
base.checkResize = function(stopTimer){
base.$startStop.click(function(e){
// checking document visibility -
base.startStop(!base.playing);
var vis = !!(doc.hidden || doc.webkitHidden || doc.mozHidden || doc.msHidden);
e.preventDefault();
clearTimeout(base.resizeTimer);
});
base.resizeTimer = setTimeout(function(){
var w = base.$outer.width(),
h = base.$outer[0].tagName === "BODY" ? base.$win.height() : base.$outer.height();
// base.width = width of one panel, so multiply by # of panels; outerPad is padding added for arrows.
// ignore changes if window hidden
if (!vis && (base.lastDim[0] !== w || base.lastDim[1] !== h)) {
base.setDimensions(); // adjust panel sizes
// make sure page is lined up (use -1 animation time, so we can differeniate it from when animationTime = 0)
base.gotoPage(base.currentPage, base.playing, null, -1);
}
if (typeof(stopTimer) === 'undefined'){ base.checkResize(); }
// increase time if page is hidden; but don't stop it completely
}, vis ? 2000 : 500);
};
// Use the same setting, but trigger the start;
// Set panel dimensions to either resize content or adjust panel to content
base.startStop(base.playing);
base.setDimensions = function(){
// reset element width & height
base.$wrapper.find('.anythingWindow, .anythingBase, .panel').andSelf().css({ width: '', height: '' });
base.width = base.$el.width();
base.height = base.$el.height();
base.outerPad = [ base.$wrapper.innerWidth() - base.$wrapper.width(), base.$wrapper.innerHeight() - base.$wrapper.height() ];
var w, h, c, t, edge = 0,
fullsize = { width: '100%', height: '100%' },
// determine panel width
pw = (o.showMultiple > 1) ? base.width || base.$window.width()/o.showMultiple : base.$window.width(),
winw = base.$win.width();
if (o.expand){
base.lastDim = [ base.$outer.width(), base.$outer.height() ];
w = base.lastDim[0] - base.outerPad[0];
base.height = h = base.lastDim[1] - base.outerPad[1];
base.$wrapper.add(base.$window).css({ width: w, height: h });
base.width = pw = (o.showMultiple > 1) ? w/o.showMultiple : w;
base.$items.css({ width: pw, height: h });
}
base.$items.each(function(i){
t = $(this);
c = t.children();
if (o.resizeContents){
// resize panel
w = base.width;
h = base.height;
t.css({ width: w, height: h });
if (c.length) {
if (c[0].tagName === "EMBED") { c.attr(fullsize); } // needed for IE7; also c.length > 1 in IE7
if (c[0].tagName === "OBJECT") { c.find('embed').attr(fullsize); }
// resize panel contents, if solitary (wrapped content or solitary image)
if (c.length === 1){ c.css(fullsize); }
}
} else {
// get panel width & height and save it
w = t.width() || base.width; // if image hasn't finished loading, width will be zero, so set it to base width instead
if (c.length === 1 && w >= winw){
w = (c.width() >= winw) ? pw : c.width(); // get width of solitary child
c.css('max-width', w); // set max width for all children
}
t.css({ width: w, height: '' }); // set width of panel
h = (c.length === 1 ? c.outerHeight(true) : t.height()); // get height after setting width
if (h <= base.outerPad[1]) { h = base.height; } // if height less than the outside padding, then set it to the preset height
t.css('height', h);
}
base.panelSize[i] = [w,h,edge];
edge += (o.mode === 'vertical') ? h : w;
});
// Set total width of slider
base.$el.css((o.mode === 'vertical' ? 'height' : 'width'), o.mode === 'fade' ? base.width : edge );
};
};
// Handles stopping and playing the slideshow
// get dimension of multiple panels, as needed
// Pass startStop(false) to stop and startStop(true) to play
base.getDim = function(page){
base.startStop = function(playing){
var i, w = base.width, h = base.height;
if(playing !== true) playing = false; // Default if not supplied is false
if (base.pages < 1 || isNaN(page)) { return [ w, h ]; } // prevent errors when base.panelSize is empty
page = (o.infiniteSlides && base.pages > 1) ? page : page - 1;
// Update variable
i = base.panelSize[page];
base.playing = playing;
if (i) {
w = i[0] || w;
// Toggle playing and text
h = i[1] || h;
if(base.options.autoPlay) base.$startStop.toggleClass("playing", playing).html( playing ? base.options.stopText : base.options.startText );
}
if (o.showMultiple > 1) {
if(playing){
for (i=1; i < o.showMultiple; i++) {
base.clearTimer(); // Just in case this was triggered twice in a row
w += base.panelSize[(page + i)][0];
base.timer = window.setInterval(function(){
h = Math.max(h, base.panelSize[page + i][1]);
base.goForward(true);
}
}, base.options.delay);
}
} else {
return [w,h];
base.clearTimer();
};
};
};
base.clearTimer = function(){
base.goForward = function(autoplay) {
// Clear the timer only if it is set
// targetPage changes before animation so if rapidly changing pages, it will have the correct current page
if(base.timer) window.clearInterval(base.timer);
base.gotoPage(base[ o.allowRapidChange ? 'targetPage' : 'currentPage'] + o.changeBy * (o.playRtl ? -1 : 1), autoplay);
};
};
// Taken from AJAXY jquery.history Plugin
base.goBack = function(autoplay) {
base.setHash = function ( hash ) {
base.gotoPage(base[ o.allowRapidChange ? 'targetPage' : 'currentPage'] + o.changeBy * (o.playRtl ? 1 : -1), autoplay);
// Write hash
if ( typeof window.location.hash !== 'undefined' ) {
if ( window.location.hash !== hash ) {
window.location.hash = hash;
};
} else if ( location.hash !== hash ) {
location.hash = hash;
};
// Done
return hash;
};
};
// <-- End AJAXY code
base.gotoPage = function(page, autoplay, callback, time) {
if (autoplay !== true) {
autoplay = false;
base.startStop(false);
base.makeActive();
}
// check if page is an id or class name
if (/^[#|.]/.test(page) && $(page).length) {
page = $(page).closest('.panel').index() + base.adj;
}
// Trigger the initialization
// rewind effect occurs here when changeBy > 1
base.init();
if (o.changeBy !== 1){
};
var adj = base.pages - base.adjustMultiple;
if (page < 1) {
page = o.stopAtEnd ? 1 : ( o.infiniteSlides ? base.pages + page : ( o.showMultiple > 1 - page ? 1 : adj ) );
}
if (page > base.pages) {
//
page = o.stopAtEnd ? base.pages : ( o.showMultiple > 1 - page ? 1 : page -= adj );
} else if (page >= adj) {
// show multiple adjustments
page = adj;
}
}
if (base.pages <= 1) { return; } // prevents animation
$.anythingSlider.defaults = {
base.$lastPage = base.$currentPage;
easing: "swing", // Anything other than "linear" or "swing" requires the easing plugin
if (typeof(page) !== "number") {
autoPlay: true, // This turns off the entire FUNCTIONALY, not just if it starts running or not
page = parseInt(page,10) || o.startPanel;
startStopped: false, // If autoPlay is on, this can force it to start stopped
base.setCurrentPage(page);
delay: 3000, // How long between slide transitions in AutoPlay mode
}
animationTime: 600, // How long the slide transition takes
hashTags: true, // Should links change the hashtag in the URL?
buildNavigation: true, // If true, builds and list of anchor links to link to each slide
pauseOnHover: true, // If true, and autoPlay is enabled, the show will pause on hover
startText: "Start", // Start text
stopText: "Stop", // Stop text
navigationFormatter: null // Details at the top of the file on this use (advanced use)
};
$.fn.anythingSlider = function(options){
// pause YouTube videos before scrolling or prevent change if playing
if(typeof(options) == "object"){
if (autoplay && o.isVideoPlaying(base)) { return; }
return this.each(function(i){
(new $.anythingSlider(this, options));
// This plugin supports multiple instances, but only one can support hash-tag support
base.exactPage = page;
// This disables hash-tags on all items but the first one
if (page > base.pages + 1 - base.adj) { page = (!o.infiniteSlides && !o.stopAtEnd) ? 1 : base.pages; }
options.hashTags = false;
if (page < base.adj ) { page = (!o.infiniteSlides && !o.stopAtEnd) ? base.pages : 1; }
});
if (!o.infiniteSlides) { base.exactPage = page; } // exact page used by the fx extension
} else if (typeof(options) == "number") {
base.currentPage = ( page > base.pages ) ? base.pages : ( page < 1 ) ? 1 : base.currentPage;
base.$currentPage = base.$items.eq(base.currentPage - base.adj);
base.targetPage = (page === 0) ? base.pages : (page > base.pages) ? 1 : page;
base.$targetPage = base.$items.eq(base.targetPage - base.adj);
time = typeof time !== 'undefined' ? time : o.animationTime;
// don't trigger events when time < 0 - to prevent FX from firing multiple times on page resize
if (time >= 0) { base.$el.trigger('slide_init', base); }
// toggle arrows/controls only if there is time to see it - fix issue #317
if (time > 0) { base.slideControls(true); }
return this.each(function(i){
// Set visual
var anySlide = $(this).data('AnythingSlider');
if (o.buildNavigation){
if(anySlide){
base.setNavigation(base.targetPage);
anySlide.gotoPage(options);
}
// When autoplay isn't passed, we stop the timer
if (autoplay !== true) { autoplay = false; }
// Stop the slider when we reach the last page, if the option stopAtEnd is set to true
if (!autoplay || (o.stopAtEnd && page === base.pages)) { base.startStop(false); }
if (time >= 0) { base.$el.trigger('slide_begin', base); }
// delay starting slide animation
setTimeout(function(d){
var p, empty = true;
if (o.allowRapidChange) {
base.$wrapper.add(base.$el).add(base.$items).stop(true, true);
}
}
});
// resi
}
};
})(jQuery);