1 |
2
|
Manuela
|
(function(a){if(typeof module!=="undefined"&&typeof exports=="object"){if(typeof window!="undefined"){module.exports=a()}else{module.exports=a}}else{window.Tab=a()}})(function(){var d=function(g,h){h=h||{};this.isIE=(new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent)!=null)?parseFloat(RegExp.$1):false;this.tab=typeof g==="object"?g:document.querySelector(g);this.tabs=this.tab.parentNode.parentNode;this.dropdown=this.tabs.querySelector(".dropdown");if(/dropdown-menu/.test(this.tabs.className)){this.dropdown=this.tabs.parentNode;this.tabs=this.tabs.parentNode.parentNode}this.options=h;this.duration=150;this.options.duration=(this.isIE&&this.isIE<10)?0:(h.duration||this.duration);this.init()};d.prototype={init:function(){this.actions();this.tab.addEventListener("click",this.action,false)},actions:function(){var g=this;this.action=function(j){j=j||window.e;j.preventDefault();var l=j.target;var m=document.getElementById(l.getAttribute("href").replace("#",""));var k=new RegExp("(?:^|\\s)dropdown-menu(?!\\S)");var i=g.getActiveTab();var h=g.getActiveContent();if(!/active/.test(l.parentNode.className)){g.removeClass(i,"active");g.addClass(l.parentNode,"active");if(g.dropdown){if(!(k.test(g.tab.parentNode.parentNode.className))){if(/active/.test(g.dropdown.className)){g.removeClass(g.dropdown,"active")}}else{if(!/active/.test(g.dropdown.className)){g.addClass(g.dropdown,"active")}}}g.removeClass(h,"in");setTimeout(function(){g.removeClass(h,"active");g.addClass(m,"active")},g.options.duration);setTimeout(function(){g.addClass(m,"in")},g.options.duration*2)}},this.addClass=function(i,h){if(i.classList){i.classList.add(h)}else{i.className+=" "+h}},this.removeClass=function(i,h){if(i.classList){i.classList.remove(h)}else{i.className=i.className.replace(h,"").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},this.getActiveTab=function(){var h=this.tabs.querySelectorAll(".active");if(h.length===1&&!/dropdown/.test(h[0].className)){return h[0]}else{if(h.length>1){return h[h.length-1]}}},this.getActiveContent=function(){var h=this.getActiveTab().getElementsByTagName("A")[0].getAttribute("href").replace("#","");return h&&document.getElementById(h)}}};var e=document.querySelectorAll("[data-toggle='tab'], [data-toggle='pill']"),f=e.length,a=0;for(a;a<f;a++){var c=e[a],b={};b.duration=c.getAttribute("data-duration")&&c.getAttribute("data-duration")||false;new d(c,b)}return d});
|