text: var lavaTabs={tabIndex:0,timer:null,initDom:function(t){var a=this,e=$(t);e.addClass("lava-tabs");var s=($(t).data("tabs").options,$("<div class='lava-tabs-toolbar'></div>").appendTo(e)),l=$("<div class='lava-tabs-pre'><a href='javascript:;' class='lava-tabs-btn-pre'><span class='glyphicon glyphicon-backward'></span></a></div>").appendTo(s),o=$("<div class='lava-tabs-btn-wrapper'></div>").appendTo(s),n=($("<div class='lava-tabs-next'><a href='javascript:;' class='lava-tabs-btn-next'><span class='glyphicon glyphicon-forward'></span></a></div>").appendTo(s),$("<div class='lava-tabs-btns'></div>").appendTo(o),l.width());o.css({"margin-left":n}),a.bindEvent(t),a.setOption(t)},addTab:function(t,a){var e=lavaTabs,s=$(t),l=s.children(".lava-tabs-toolbar").find(".lava-tabs-btns"),o=(s.data("tabs").options,a.hideType?a.hideType:"hide"),n=s.children(".lava-tabs-toolbar").find(".lava-tabs-btn-next");l.find(".lava-tabs-btn-selected").removeClass("lava-tabs-btn-selected");var f=$("<a href='javascript:;' class='lava-tabs-btn lava-tabs-btn-selected' data-for='lava-tabs-"+ ++e.tabIndex+"' data-hidetype='"+o+"'>"+a.title+" </a>").appendTo(l);a.closable!==!1&&$("<span class='glyphicon glyphicon-remove-sign'></span>").appendTo(f),e.hideAll(t);$("<div class='lava-tabs-tab' id='lava-tabs-"+e.tabIndex+"' data-hidetype='"+o+"'>"+a.content+"</div>").appendTo(s);f.offset().left+f.outerWidth()>n.offset().left&&n.click()},select:function(t,a){for(var e=null,s=$(t).children(".lava-tabs-toolbar"),l=s.find(".lava-tabs-btn"),o=0;o<l.length;o++)if(a==o||a==l.eq(o).text()){e=l.eq(o);break}if(e){e.click();var n=s.children(".lava-tabs-btn-wrapper"),f=n.children(),i=s.find(".lava-tabs-btn-next"),r=f.css("left").replace("px","");r=r?parseInt(r):0,e.offset().left<n.offset().left?(r+=n.offset().left-e.offset().left,f.animate({left:r},"fast")):e.offset().left+e.outerWidth()>i.offset().left&&(r-=e.offset().left+e.outerWidth()-i.offset().left,f.animate({left:r},"fast"))}},setOption:function(t,a){var e=$(t),s=e.data("tabs").options;a&&$.extend(s,a);var l=e.find(".lava-tabs-toolbar"),o=["<style>"];s.bgColor&&o.push(".lava-tabs-toolbar,.lava-tabs-btn-pre,.lava-tabs-btn-next{background-color:"+s.bgColor+";}"),s.color&&o.push(".lava-tabs-btn,.lava-tabs-btn-pre,.lava-tabs-btn-next{color:"+s.color+";}"),s.borderColor&&(o.push(".lava-tabs-btn-pre,.lava-tabs-btn-next,.lava-tabs-btn{border-color:"+s.borderColor+";}"),l.css({"border-bottom-color":s.borderColor})),s.activeColor&&(o.push(".lava-tabs-btn-pre:hover,.lava-tabs-btn-next:hover,.lava-tabs-btn:hover,.lava-tabs-btn-selected,.lava-tabs-btn:focus {background-color:"+s.activeColor+";"),o.push(s.color?"color:"+s.color+";}":"}")),o.push("</style>"),e.data("tabs").style&&e.data("tabs").style.remove();var n=$(o.join("\n")).insertAfter(e);e.data("tabs").style=n},bindEvent:function(t){var a=this,e=$(t),s=e.data("tabs").options,l=e.children(".lava-tabs-toolbar"),o=l.children(".lava-tabs-btn-wrapper"),n=o.children(),f=l.find(".lava-tabs-btn-pre"),i=l.find(".lava-tabs-btn-next");l.delegate(".lava-tabs-btn","click",function(){if(!$(this).hasClass("lava-tabs-btn-selected")){l.find(".lava-tabs-btn").removeClass("lava-tabs-btn-selected"),$(this).addClass("lava-tabs-btn-selected"),a.hideAll(t);var e=$(this).attr("data-for");"position"==$(this).attr("data-hidetype")?$("#"+e).css({position:"relative",left:0}):$("#"+e).removeClass("lava-tabs-tab-close"),s.onSelect&&s.onSelect($.trim($(this).text()))}}),l.delegate(".glyphicon-remove-sign","click",function(){var t=$(this).parent().attr("data-for"),a=$(this).parent();return a.hasClass("lava-tabs-btn-selected")&&(a.next().length>0?a.next().click():a.prev().length>0&&a.prev().click()),s.onClose&&s.onClose($.trim(a.text())),a.remove(),$("#"+t).remove(),!1}),f.on("click",function(){var t=n.children(),a=t.first();if(a.offset().left<o.offset().left)for(var e=0;e<t.length;e++){var s=t.eq(e);if(s.offset().left+s.outerWidth()>=o.offset().left){var l=n.css("left").replace("px","");l=l?parseInt(l):0,s.offset().left-n.offset().left<=i.offset().left-t.eq(e+1).offset().left?l=0:l+=i.offset().left-t.eq(e+1).offset().left,n.animate({left:l},"fast");break}}}),i.on("click",function(){var t=n.children();if(t.last().offset().left+t.last().width()>i.offset().left)for(var a=0;a<t.length;a++){var e=t.eq(a);if(e.offset().left+e.width()>i.offset().left){var s=n.css("left").replace("px","");s=s?parseInt(s):0,t.last().offset().left+t.last().outerWidth()-e.offset().left<o.width()-i.outerWidth()?s-=t.last().offset().left+t.last().outerWidth()-i.offset().left:e.offset().left<=i.offset().left?s-=e.offset().left-o.offset().left:e.prev().length>0&&(s-=e.prev().offset().left-o.offset().left),n.animate({left:s},"fast");break}}}),window.onresize=function(){/msie 8/.test(navigator.userAgent.toLowerCase())&&(a.timer&&clearTimeout(a.timer),a.timer=setTimeout(function(){a.resizeDom(t)},10))}},hideAll:function(t){for(var a=$(t),e=a.children(".lava-tabs-tab"),s=0;s<e.length;s++){var l=e.eq(s);"position"==l.attr("data-hidetype")?l.css({position:"absolute",left:-1e4}):l.addClass("lava-tabs-tab-close")}},resizeDom:function(t){var a=$(t),e=a.children(".lava-tabs-toolbar"),s=a.children(".lava-tabs-tab").not(".lava-tabs-tab-close"),l=a.height()-e.height()-2;s.css({height:l})}};$.fn.lavaTabs=function(t,a){return"string"==typeof t?$.fn.lavaTabs.methods[t](this,a):this.each(function(){var a={};$.extend(a,$.fn.lavaTabs.defaults),$(this).data("tabs",{options:a}),$.extend($(this).data("tabs").options,t),lavaTabs.initDom(this)})},$.fn.lavaTabs.defaults={fit:!0,bgColor:"",color:"",borderColor:"",activeColor:"",onClose:null,onSelect:null},$.fn.lavaTabs.methods={add:function(t,a){lavaTabs.addTab(t,a)},select:function(t,a){lavaTabs.select(t,a)},setOption:function(t,a){lavaTabs.setOption(t,a)}};