(function(window,undefined){"use strict";var auiTab=function(params,callback){this.extend(this.params,params);this._init(callback);};var tabItems;auiTab.prototype={params:{element:false,index:0,repeatClick:false},_init:function(callback){var self=this;if(!self.params.element||self.params.element.nodeType!=1){return;}tabItems=self.params.element.children;if(tabItems){self.setActive();for(var i=0;i<tabItems.length;i++){tabItems[i].setAttribute("data-item-order",i);tabItems[i].onclick=function(e){if(!self.params.repeatClick){if(this.className.indexOf("aui-active")>-1)return;}if(callback){callback({index:parseInt(this.getAttribute("data-item-order")),dom:this})};this.parentNode.querySelector(".aui-active").classList.remove("aui-active");this.classList.add("aui-active");}}}},setRepeat:function(value){var self=this;self.params.repeatClick=value?value:false;},setActive:function(index){var self=this;index=index?index:self.params.index;var _tab=tabItems[index];if(_tab.parentNode.querySelector(".aui-active"))_tab.parentNode.querySelector(".aui-active").classList.remove("aui-active");_tab.classList.add("aui-active");},extend:function(a,b){for(var key in b){if(b.hasOwnProperty(key)){a[key]=b[key];}}return a;}};window.auiTab=auiTab;})(window);
