Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a gotoNeutral() trigger by calling eAccordion() without args.

  • Loading branch information...
commit 884f54cc38bd651911a0ead9a9a460c936507d55 1 parent 2cbc0fc
Dean Sofer authored
View
8 js/jquery.elegantAccordion.js
@@ -256,7 +256,6 @@
};
$.fn.eAccordion = function(options) {
-
if (typeof(options) == "object"){
return this.each(function(i){
(new $.eAccordion(this, options));
@@ -271,6 +270,13 @@
}
});
+ } else {
+ return this.each(function(i) {
+ var eSlide = $(this).data('ElegantAccordion');
+ if (eSlide) {
+ eSlide.gotoNeutral();
+ }
+ });
}
};
View
2  js/jquery.elegantAccordion.min.js
@@ -1 +1 @@
-(function(b){var a=0;b.eAccordion=function(d,c){var e=this;a++;e.runTimes=a;e.$el=b(d);e.currentPage=1;e.timer=null;e.playing=false;e.$el.data("ElegantAccordion",e);e.init=function(){e.options=b.extend({},b.eAccordion.defaults,c);e.$items=e.$el.children("li");e.$single=e.$items.last();e.$single.css("margin-right","-20px");if(e.options.height){e.$items.css("height",e.options.height);}e.pages=e.$items.length;var f;if(e.options.expandedWidth.indexOf("%")>-1){f=e.$el.width()*(parseInt(e.options.expandedWidth)/100);}else{f=parseInt(e.options.expandedWidth);}e.contractedWidth=(e.$el.width()-f)/(e.pages-1);if(e.options.autoPlay){e.playing=!e.options.startStopped;e.startStop(e.playing);}if(e.options.pauseOnHover&&e.options.autoPlay){e.$el.hover(function(){e.clearTimer();},function(){e.startStop(e.playing);});}e.$items.filter("[data-bg]").each(function(){var g=b(this);g.css("backgroundImage","url("+g.data("bg")+")");});e.$items.hover(function(){e.startStop(false);e.gotoPage(e.$items.index(this)+1);},function(){if(!e.clickStopped){if(e.options.autoPlay){e.startStop(true);}else{if(e.options.neutralState){e.gotoNeutral();}}}}).click(function(){e.startStop(false);e.clickStopped=true;}).children("div").width(f);if((e.options.hashTags==true&&!e.gotoHash())||e.options.hashTags==false){e.gotoPage(1,false);}if(e.options.neutralState){e.neutralWidth=(100/e.pages)+"%";e.gotoNeutral(false);}};e.gotoPage=function(h,f){if(typeof(h)=="undefined"||h==null){h=1;}if(e.options.stopAtEnd){if(h==e.pages){e.startStop(false);}}if(h>e.pages){h=1;}if(h<1){h=1;}var g=e.$items.eq(h-1);duration=(f!==false)?e.options.animationTime:0;g.stop(true,true).animate({width:e.options.expandedWidth},duration,e.options.easing);g.children("h2").stop(true,true).animate({opacity:0},duration);g.children("div").stop(true,true).animate({opacity:1,marginBottom:0,paddingBottom:0},duration);$siblings=g.siblings();$siblings.stop(true,true).animate({width:e.contractedWidth},duration,e.options.easing);$siblings.children("h2").stop(true,true).animate({opacity:0.9},duration);$siblings.children("div").stop(true,true).animate({opacity:0,marginBottom:"-"+e.options.bgHeight,paddingBottom:e.options.bgHeight},duration);e.currentPage=h;};e.gotoNeutral=function(f){duration=(f!==false)?e.options.animationTime:0;e.$items.stop(true,true).animate({width:e.neutralWidth},duration,e.options.easing);e.$items.children("h2").stop(true,true).animate({opacity:0.9},duration);e.$items.children("div").stop(true,true).animate({opacity:0,marginBottom:"-"+e.options.bgHeight,paddingBottom:e.options.bgHeight},duration);};e.goForward=function(){e.gotoPage(e.currentPage+1);};e.goBack=function(){e.gotoPage(e.currentPage-1);};e.gotoHash=function(){var i=window.location.hash.match(/^#?panel(\d+)-(\d+)$/);if(i){var g=parseInt(i[1]);if(g==e.runTimes){var f=parseInt(i[2]);var h=e.$items.filter(":eq("+f+")");if(h.length!=0){e.gotoPage(f,false);return true;}}}return false;};e.startStop=function(f){if(f!==true){f=false;}e.playing=f;if(f){e.clearTimer();e.timer=window.setInterval(function(){e.goForward();},e.options.delay);}else{e.clearTimer();}};e.clearTimer=function(){if(e.timer){window.clearInterval(e.timer);}};e.setHash=function(f){if(typeof window.location.hash!=="undefined"){if(window.location.hash!==f){window.location.hash=f;}}else{if(location.hash!==f){location.hash=f;}}return f;};e.init();};b.eAccordion.defaults={easing:"swing",autoPlay:true,startStopped:false,stopAtEnd:false,delay:4000,animationTime:100,hashTags:true,pauseOnHover:true,height:null,expandedWidth:"60%",neutralState:false,bgHeight:"340px"};b.fn.eAccordion=function(c){if(typeof(c)=="object"){return this.each(function(d){(new b.eAccordion(this,c));});}else{if(typeof(c)=="number"){return this.each(function(d){var e=b(this).data("ElegantAccordion");if(e){e.gotoPage(c);}});}}};})(jQuery);
+(function(b){var a=0;b.eAccordion=function(d,c){var e=this;a++;e.runTimes=a;e.$el=b(d);e.currentPage=1;e.timer=null;e.playing=false;e.$el.data("ElegantAccordion",e);e.init=function(){e.options=b.extend({},b.eAccordion.defaults,c);e.$items=e.$el.children("li");e.$single=e.$items.last();e.$single.css("margin-right","-20px");if(e.options.height){e.$items.css("height",e.options.height);}e.pages=e.$items.length;var f;if(e.options.expandedWidth.indexOf("%")>-1){f=e.$el.width()*(parseInt(e.options.expandedWidth)/100);}else{f=parseInt(e.options.expandedWidth);}e.contractedWidth=(e.$el.width()-f)/(e.pages-1);if(e.options.autoPlay){e.playing=!e.options.startStopped;e.startStop(e.playing);}if(e.options.pauseOnHover&&e.options.autoPlay){e.$el.hover(function(){e.clearTimer();},function(){e.startStop(e.playing);});}e.$items.filter("[data-bg]").each(function(){var g=b(this);g.css("backgroundImage","url("+g.data("bg")+")");});e.$items.hover(function(){e.startStop(false);e.gotoPage(e.$items.index(this)+1);},function(){if(!e.clickStopped){if(e.options.autoPlay){e.startStop(true);}else{if(e.options.neutralState){e.gotoNeutral();}}}}).click(function(){e.startStop(false);e.clickStopped=true;}).children("div").width(f);if((e.options.hashTags==true&&!e.gotoHash())||e.options.hashTags==false){e.gotoPage(1,false);}if(e.options.neutralState){e.neutralWidth=(100/e.pages)+"%";e.gotoNeutral(false);}};e.gotoPage=function(h,f){if(typeof(h)=="undefined"||h==null){h=1;}if(e.options.stopAtEnd){if(h==e.pages){e.startStop(false);}}if(h>e.pages){h=1;}if(h<1){h=1;}var g=e.$items.eq(h-1);duration=(f!==false)?e.options.animationTime:0;g.stop(true,true).animate({width:e.options.expandedWidth},duration,e.options.easing);g.children("h2").stop(true,true).animate({opacity:0},duration);g.children("div").stop(true,true).animate({opacity:1,marginBottom:0,paddingBottom:0},duration);$siblings=g.siblings();$siblings.stop(true,true).animate({width:e.contractedWidth},duration,e.options.easing);$siblings.children("h2").stop(true,true).animate({opacity:0.9},duration);$siblings.children("div").stop(true,true).animate({opacity:0,marginBottom:"-"+e.options.bgHeight,paddingBottom:e.options.bgHeight},duration);e.currentPage=h;};e.gotoNeutral=function(f){duration=(f!==false)?e.options.animationTime:0;e.$items.stop(true,true).animate({width:e.neutralWidth},duration,e.options.easing);e.$items.children("h2").stop(true,true).animate({opacity:0.9},duration);e.$items.children("div").stop(true,true).animate({opacity:0,marginBottom:"-"+e.options.bgHeight,paddingBottom:e.options.bgHeight},duration);};e.goForward=function(){e.gotoPage(e.currentPage+1);};e.goBack=function(){e.gotoPage(e.currentPage-1);};e.gotoHash=function(){var i=window.location.hash.match(/^#?panel(\d+)-(\d+)$/);if(i){var g=parseInt(i[1]);if(g==e.runTimes){var f=parseInt(i[2]);var h=e.$items.filter(":eq("+f+")");if(h.length!=0){e.gotoPage(f,false);return true;}}}return false;};e.startStop=function(f){if(f!==true){f=false;}e.playing=f;if(f){e.clearTimer();e.timer=window.setInterval(function(){e.goForward();},e.options.delay);}else{e.clearTimer();}};e.clearTimer=function(){if(e.timer){window.clearInterval(e.timer);}};e.setHash=function(f){if(typeof window.location.hash!=="undefined"){if(window.location.hash!==f){window.location.hash=f;}}else{if(location.hash!==f){location.hash=f;}}return f;};e.init();};b.eAccordion.defaults={easing:"swing",autoPlay:true,startStopped:false,stopAtEnd:false,delay:4000,animationTime:100,hashTags:true,pauseOnHover:true,height:null,expandedWidth:"60%",neutralState:false,bgHeight:"340px"};b.fn.eAccordion=function(c){if(typeof(c)=="object"){return this.each(function(d){(new b.eAccordion(this,c));});}else{if(typeof(c)=="number"){return this.each(function(d){var e=b(this).data("ElegantAccordion");if(e){e.gotoPage(c);}});}else{return this.each(function(d){var e=b(this).data("ElegantAccordion");if(e){e.gotoNeutral();}});}}};})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.