-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevTab.min.js
1 lines (1 loc) · 3.9 KB
/
devTab.min.js
1
(function(){var l,g,h,d,c,f,i,j,b,m,k,e,a;l=jQuery;l.fn.extend({devTab:function(n){var o;o={menuBot:false,click:false,nav:false,fx:null,resize:false,debug:false};o=l.extend(o,n);window.log=function(p){if(o.debug){return typeof console!=="undefined"&&console!==null?console.log(p):void 0}};return this.each(function(){var q,r,p,t,s;t=o;s=l(this);q=1;p=s.find(".tab").length;log("devTab init for: "+s.attr("id"));e(s,t.menuBot,t.nav);if(t.fx==="slideX"||t.fx==="slideY"){r=a(s,t.fx)}log("= this animation size = "+r);m(s,t.nav,t.fx);j(s);s.on((t.click?"click":"hover"),'li:not(".prev, .next, .active")',function(){var v,u;v=s.find("li.active").index();u=l(this).index();k(s,t.fx,v,u,r);return j(s)}).delay(800);s.on("click",'li.prev:not(".disabled")',function(){var u;u=s.find(".active").prev();b(s,u,t.fx,r);return j(s)});s.on("click",'li.next:not(".disabled")',function(){var u;u=s.find(".active").next();b(s,u,t.fx,r);return j(s)});if(t.resize){f()}return log("\n ========== END =========== \n ")})}});e=function(p,q,n){var o;log("+ build dom");log(" - build menu");if(q){p.append('<ul class="menu"/>')}else{p.prepend('<ul class="menu"/>')}log(" - populate li");o=p.find(".menu");p.find(".title").clone().appendTo(o).wrap("<li/>").end().end().remove();log(" - nav building");o.append('<li class="next">Next</li>');return o.prepend('<li class="prev">Prev</li>')};m=function(n,p,o){log("+ beginTab setup");i(n,1);if(!(o==="slideX")&!(o==="slideY")){g(n,0)}if(!p){n.find("li.prev").hide();return n.find("li.next").hide()}};k=function(p,q,r,n,o){var s;log("+ fxAction triggered");s=n;s-=1;switch(q){case"slideX":log(" - slide x is activated");p.find(".container").animate({"margin-left":h(d(r,n))+(o*Math.abs(d(r,n)))});return i(p,n);case"slideY":log(" - slide y is activated");p.find(".container").animate({"margin-top":h(d(r,n))+(o*Math.abs(d(r,n)))});return i(p,n);case null:log(" - no slide activated");i(p,n);return g(p,s)}};b=function(p,r,q,o){var t,s,n;log("+ nav triggered");s=p.find("li.active").index();t=n=r.index();t-=1;switch(q){case"slideX":log(" - nav: slideX");p.find(".container").animate({"margin-left":h(d(s,n))+(o*Math.abs(d(s,n)))});return i(p,n);case"slideY":log(" - nav: slideY");p.find(".container").animate({"margin-top":h(d(s,n))+(o*Math.abs(d(s,n)))});return i(p,n);case null:log(" - nav: defualt");i(p,n);return g(p,t)}};j=function(o,q){var n,p;log("+ nav.disabled when reaches limit");log(" - active index = "+(n=o.find("li.active").index()));log(" - total length = "+(p=o.find("li").index()));if(n===1){o.find("li.prev").addClass("disabled")}else{o.find("li.prev").removeClass("disabled")}if(n===p-1){return o.find("li.next").addClass("disabled")}else{return o.find("li.next").removeClass("disabled")}};i=function(n,o){log(" - set active li");return n.find("li").eq(o).addClass("active").siblings().removeClass("active")};g=function(n,o){log(" - show/hide tab");return n.find(".tab").eq(o).show().siblings(".tab").hide()};a=function(o,p){var n,q;log("+ build slider init");log(" - build container");o.find(".tab").wrapAll('<div class="wrap"><div class="container"></div></div>');log(" - width: "+(q=c(o,"x")));log(" - height: "+(n=c(o,"y")));log(" - set wrap.css");o.find(".wrap").css({overflow:"hidden"});if(p==="slideX"){o.find(".wrap, .container, .tab").css({width:q});o.find(".container").css({width:q*o.find(".tab").length});o.find(".tab").css({"float":"left"});return q}if(p==="slideY"){o.find(".wrap, .container, .tab").css({height:n});return n}};c=function(p,o){var n;log("+ getting tab size");p=p.find(".tab");n=0;switch(o){case"x":p.each(function(){return n=Math.max(n,l(this).width())});break;case"y":p.each(function(){return n=Math.max(n,l(this).height())})}return n};d=function(o,n){log("+ find difference");return o-n;return log(o-n)};h=function(n){log("+ detectDirection");if(n<0){return"-="}else{return"+="}};f=function(){return l(window).resize(function(){var n;n=unescape(window.location.pathname);return window.location.reload(n)})}}).call(this);