/ Published in: jQuery
Expand |
Embed | Plain Text
$(document).ready(function(){ //setup width on tour items var itemLeft = 0; $(".cz-setup-width").each(function(el){ $(this).css("margin-left",itemLeft+"px"); itemLeft = itemLeft+$(this).width(); }); $(".tour-note p:not(:first)").hide(); var left = 0; var navLeft = 0; var inc = $(".tour-item:first").width(); var paddingLeft = $(".back").width(); var paddingRight = $(".forward").width(); var leftTotal = left; var counter = 0; left = 0; $(".forward a").click(function(){ if(counter+1 == $(".tour-nav a").size()){ counter = 0; $(".tour-nav li:first a").click(); return false; } $(".tour-note").css({opacity:0}); left = (left+inc); $(".back").removeClass("disabled"); var cur = $(".tour-nav li.active"); cur.removeClass("active"); cur.next("li").addClass("active"); $(".tour-item-container").animate({ marginLeft: "-"+(left)+"px" }, 500,'swing',function(){ $(".tour-note p").hide(); $(".tour-note p:eq("+counter+")").show(); $(".tour-note").animate({opacity:1},500); }); counter++; return false; }); $(".back a").click(function(){ if(counter == 0){ counter = $(".tour-nav li").size()-1; $(".tour-nav li:last a").click(); return false; } $(".tour-note").css({opacity:0}); left = left-inc; var cur = $(".tour-nav li.active"); cur.removeClass("active"); cur.prev("li").addClass("active"); navLeft = navLeft - 200; $(".tour-item-container").animate({ marginLeft: "-"+(left)+"px" }, 500,'swing',function(){ $(".tour-note p").hide(); $(".tour-note p:eq("+counter+")").show(); $(".tour-note").animate({opacity:1},500); }); counter--; }); $(".tour-nav a").click(function(e){ $(".tour-note").css({opacity:0}); var index = $(".tour-nav a").index(this); counter = index; var go = (index*inc); var cur = $(".tour-nav li.active").removeClass("active"); $(this).parents("li").addClass("active"); $(".tour-item-container").animate({ marginLeft: "-"+(go)+"px" }, 500,function(){ $(".tour-note p").hide(); $(".tour-note p:eq("+index+")").show(); $(".tour-note").animate({opacity:1},500); } ); left = go; return false; }); }); //end document.ready
You need to login to post a comment.
