TabPanel=function(a,b){this.i18n={closeTab:"关闭页签",refreshTab:"刷新页签",closeOther:"关闭其他",closeLeft:"关闭左侧",closeRight:"关闭右侧",};if(window.lang=="en"){this.i18n={closeTab:"Close",refreshTab:"Refresh",closeOther:"Close Other",closeLeft:"Close Left",closeRight:"Close Right"}}this.renderTo=a.renderTo||$(document.body);this.border=a.border||"none";this.render=typeof b!="undefined"?b:typeof this.renderTo=="string"?$("#"+this.renderTo):this.renderTo;this.widthResizable=a.widthResizable;this.heightResizable=a.heightResizable;this.autoResizable=a.autoResizable?true:false;this.width=a.width||"100%";this.height=a.height||"100%";this.items=a.items;this.active=a.active||0;this.tabs=[];this.scrolled=false;this.tabWidth=a.tabWidth||100;this.fixNum=2;this.scrollFinish=true;this.maxLength=a.maxLength||20;this.maxzindex=0;this.init()};TabPanel.prototype={init:function(){var d=this;if(this.autoResizable){this.widthResizable=this.heightResizable=true;this.render.css("overflow","hidden");$(window).resize(function(){window.setTimeout(function(){d.resize()},500)})}if(typeof this.width=="function"){this.render.width=this.width}else{this.render.width(this.width)}if(typeof this.height=="function"){this.render.height=this.height}else{this.render.height(this.height)}var e=this.border!="none"?2:0;this.tabpanel=$("
");this.tabpanel.addClass("tabpanel");this.tabpanel.width(this.render.width()-e);this.tabpanel.height(this.render.height()-e);this.render.append(this.tabpanel);this.tabpanel_tab_content=$("");this.tabpanel_tab_content.addClass("tabpanel_tab_content");if(this.maxLength==1){this.tabpanel_tab_content.addClass("hide")}this.tabpanel_tab_content.appendTo(this.tabpanel);this.tabpanel_left_scroll=$("");this.tabpanel_left_scroll.bind("click",function(){d.moveLeft()});this.tabpanel_left_scroll.addClass("tabpanel_left_scroll");this.tabpanel_left_scroll.addClass("display_none");this.tabpanel_left_scroll.bind("mouseover",function(){var f=$(this);f.addClass("tabpanel_scroll_over");f.bind("mouseout",function(){f.unbind("mouseout");f.removeClass("tabpanel_scroll_over")})});this.tabpanel_left_scroll.appendTo(this.tabpanel_tab_content);this.tabpanel_right_scroll=$("");this.tabpanel_right_scroll.bind("click",function(){d.moveRight()});this.tabpanel_right_scroll.addClass("tabpanel_right_scroll");this.tabpanel_right_scroll.addClass("display_none");this.tabpanel_right_scroll.bind("mouseover",function(){var f=$(this);f.addClass("tabpanel_scroll_over");f.bind("mouseout",function(){f.unbind("mouseout");f.removeClass("tabpanel_scroll_over")})});this.tabpanel_right_scroll.appendTo(this.tabpanel_tab_content);this.tabpanel_move_content=$("");this.tabpanel_move_content.addClass("tabpanel_move_content");this.tabpanel_move_content.appendTo(this.tabpanel_tab_content);this.tabpanel_mover=$("");this.tabpanel_mover.addClass("tabpanel_mover");this.tabpanel_mover.appendTo(this.tabpanel_move_content);this.tabpanel_tab_spacer=$("");this.tabpanel_tab_spacer.addClass("tabpanel_tab_spacer");this.tabpanel_tab_spacer.appendTo(this.tabpanel_tab_content);this.tabpanel_content=$("");this.tabpanel_content.addClass("tabpanel_content");this.tabpanel_content.appendTo(this.tabpanel);var a=this.tabpanel.width();var c=this.tabpanel.height();if(this.border=="none"){this.tabpanel.css("border","none")}this.tabpanel_tab_content.width(a);this.tabpanel_content.width(a);this.tabpanel_content.height(c-this.tabpanel_tab_content.get(0).offsetHeight);this.update();for(var b=0;b=0){this.show(this.active,false)}},moveLeft:function(){if(this.scrollFinish){this.disableScroll();this.scrollFinish=false;Fader.apply(this,new Array({element:this.tabpanel_mover,style:"marginLeft",num:this.tabWidth,maxMove:this.maxMove,onFinish:this.useableScroll}));this.run()}},moveRight:function(){if(this.scrollFinish){this.disableScroll();this.scrollFinish=false;Fader.apply(this,new Array({element:this.tabpanel_mover,style:"marginLeft",num:this.tabWidth*-1,maxMove:this.maxMove,onFinish:this.useableScroll}));this.run()}},moveToLeft:function(){if(this.scrolled&&this.scrollFinish){this.disableScroll();this.scrollFinish=false;var a=parseInt(this.tabpanel_mover.css("marginLeft"))*-1;Fader.apply(this,new Array({element:this.tabpanel_mover,style:"marginLeft",num:a,maxMove:this.maxMove,interval:20,step:(a/10)<10?10:a/10,onFinish:this.useableScroll}));this.run()}},moveToRight:function(){if(this.scrolled&&this.scrollFinish){this.disableScroll();this.scrollFinish=false;var d=parseInt(this.tabpanel_mover.css("marginLeft"))*-1;var c=this.tabpanel_mover.children().length*this.tabWidth;var a=this.tabpanel_move_content.width();var b=(c-a-d+this.fixNum)*-1;Fader.apply(this,new Array({element:this.tabpanel_mover,style:"marginLeft",num:b,maxMove:this.maxMove,step:(b*-1/10)<10?10:b*-1/10,onFinish:this.useableScroll}));this.run()}},moveToSee:function(a){if(this.scrolled){var c=this.tabWidth*a;var b=parseInt(this.tabpanel_mover.css("marginLeft"));var d;if(b<=0){d=(b+c)*-1;if(((d+b)*-1)>=this.maxMove){this.moveToRight()}else{this.disableScroll();this.scrollFinish=false;Fader.apply(this,new Array({element:this.tabpanel_mover,style:"marginLeft",num:d,maxMove:this.maxMove,step:(d/10)<10?10:d/10,onFinish:this.useableScroll}));this.run()}}else{d=(c-b)*-1;if((d*-1)>=this.maxMove){this.moveToRight()}else{this.disableScroll();this.scrollFinish=false;Fader.apply(this,new Array({element:this.tabpanel_mover,style:"marginLeft",num:d,maxMove:this.maxMove,onFinish:this.useableScroll}));this.run()}}}},disableScroll:function(){this.tabpanel_left_scroll.addClass("tabpanel_left_scroll_disabled");this.tabpanel_left_scroll.attr("disabled",true);this.tabpanel_right_scroll.addClass("tabpanel_right_scroll_disabled");this.tabpanel_right_scroll.attr("disabled",true)},useableScroll:function(){var a=this;if(this.scrolled){if(parseInt(a.tabpanel_mover.css("marginLeft"))==0){a.tabpanel_left_scroll.addClass("tabpanel_left_scroll_disabled");a.tabpanel_left_scroll.attr("disabled",true);a.tabpanel_right_scroll.removeClass("tabpanel_right_scroll_disabled");a.tabpanel_right_scroll.removeAttr("disabled")}else{if(parseInt(a.tabpanel_mover.css("marginLeft"))*-1==a.maxMove){a.tabpanel_left_scroll.removeClass("tabpanel_left_scroll_disabled");a.tabpanel_left_scroll.removeAttr("disabled",true);a.tabpanel_right_scroll.addClass("tabpanel_right_scroll_disabled");a.tabpanel_right_scroll.attr("disabled")}else{a.tabpanel_left_scroll.removeClass("tabpanel_left_scroll_disabled");a.tabpanel_left_scroll.removeAttr("disabled",true);a.tabpanel_right_scroll.removeClass("tabpanel_right_scroll_disabled");a.tabpanel_right_scroll.removeAttr("disabled")}}}a.scrollFinish=true},update:function(){var a=this.tabpanel_tab_content.width();if(this.scrolled){a-=(this.tabpanel_left_scroll.width()+this.tabpanel_right_scroll.width())}this.tabpanel_move_content.width(a);this.maxMove=(this.tabpanel_mover.children().length*this.tabWidth)-a+this.fixNum},showScroll:function(){var a=this.tabpanel_mover.children().length*this.tabWidth;var b=this.tabpanel_tab_content.width();if(a>b&&!this.scrolled){this.tabpanel_move_content.addClass("tabpanel_move_content_scroll");this.tabpanel_left_scroll.removeClass("display_none");this.tabpanel_right_scroll.removeClass("display_none");this.scrolled=true}else{if(a0){this.show(c.id,false);if(c.refresh==true){$("#"+c.id+" .refresher").click()}}else{if(this.scrollFinish){var e=this;if(this.maxLength!=-1&&this.maxLength<=this.tabs.length){for(var f=0;f");d.attr("id",c.id);d.attr("unselectable","on");d.attr("style","-moz-user-select:none;");d.attr("onselectstart","return false;");d.appendTo(this.tabpanel_mover);var j=$("");j.html(c.title);j.appendTo(d);var g=c.closable==false?0:5;if(c.icon){j.addClass("icon_title");j.css("background-image",'url("'+c.icon+'")');if(j.width()>(this.tabWidth-35-g)){j.width((this.tabWidth-57-g));j.attr("title",c.title);d.append("...
")}}else{j.addClass("title");if(j.width()>(this.tabWidth-19-g)){j.width((this.tabWidth-37-g));j.attr("title",c.title);d.append("...
")}}var b=$("");b.addClass("refresher");b.appendTo(d);var k=$("");k.addClass("closer");k.attr("title",this.i18n.close);k.appendTo(d);var h=$("");h.addClass("html_content");if(navigator.userAgent.match(/iPad|iPhone/i)){h.addClass("iframe-ios")}h.appendTo(this.tabpanel_content);var a=this.tabpanel_mover.children().index(this.tabpanel_mover.find(".active")[0]);if(a<0){a=0}if(this.tabs.length>a){c.preTabId=this.tabs[a].id}else{c.preTabId=""}c.tab=d;c.title=j;c.refresher=b;c.closer=k;c.content=h;c.disable=c.disable==undefined?false:c.disable;c.closable=c.closable==undefined?true:c.closable;if(c.closable==false){k.addClass("display_none")}if(c.disabled==true){d.attr("disabled",true);j.addClass("disabled")}this.tabs.push(c);d.bind("click",function(i){return function(){e.show(i,false)}}(this.tabs.length-1));b.bind("click",function(i){return function(){e.refresh(i)}}(this.tabs.length-1));k.bind("click",function(i){return function(){e.kill(i)}}(this.tabs.length-1));if(c.closable){d.bind("dblclick",function(i){return function(){e.kill(i)}}(this.tabs.length-1))}if(!c.lazyload){this.show(this.tabs.length-1,c.notExecuteMoveSee)}this.showScroll();this.update();if(!c.lazyload&&!c.notExecuteMoveSee){this.moveToRight()}$("#"+c.id).RightMenu(c.id+"-rightmenu",{menuList:[{menuName:this.i18n.refreshTab,menuClass:"",clickEvent:"$('#"+c.id+" .refresher').click();"},{menuName:this.i18n.closeOther,menuClass:"",clickEvent:"$('#"+c.id+"').click();$('#"+$(e.render).attr("id")+" .tabpanel_tab_content li:not(.active) .closer:not(.display_none)').click();"},{menuName:this.i18n.closeLeft,menuClass:"",clickEvent:"$('#"+c.id+"').click();$('#"+$(e.render).attr("id")+" .tabpanel_tab_content li:lt('+$('#"+$(e.render).attr("id")+" .tabpanel_tab_content li.active').index()+') .closer:not(.display_none)').click();"},{menuName:this.i18n.closeRight,menuClass:"",clickEvent:"$('#"+c.id+"').click();$('#"+$(e.render).attr("id")+" .tabpanel_tab_content li:gt('+$('#"+$(e.render).attr("id")+" .tabpanel_tab_content li.active').index()+') .closer:not(.display_none)').click();"}]})}}},getTabPosision:function(a){if(typeof a=="string"){for(var b=0;b0){for(var a=0;a0){for(var a=0;a=this.tabs.length){a=0}$(".html_content").css("visibility","hidden");this.tabs[a].content.css("visibility","visible");this.tabs[a].content.css("z-index",++this.maxzindex);if(this.tabs[a].tab.hasClass("active")){if(!b){this.moveToSee(a)}}else{if(this.tabs[a].content.html()==""){this.tabs[a].content.html(this.tabs[a].html)}this.tabpanel_mover.find(".active").removeClass("active");this.tabs[a].tab.addClass("active");if(!b){this.moveToSee(a)}}}},kill:function(a,d){var f=this;a=this.getTabPosision(a);if(typeof this.tabs[a].onPreClose=="function"){if(this.tabs[a].onPreClose(a)==false){return}}var c=this.tabs[a].preTabId;if($("#"+c).length<=0&&this.tabs[a-1]){c=this.tabs[a-1].id}this.tabs[a].closer.remove();this.tabs[a].title.remove();this.tabs[a].tab.remove();this.tabs[a].content.remove();$("#"+this.tabs[a].id+"-rightmenu").remove();this.tabs.splice(a,1);for(var e=0;ea){return this.tabs[a]}else{return null}},resize:function(){var a=this.border=="none"?0:2;if(this.widthResizable){this.width=this.render.width();this.tabpanel.width(this.width-a);this.tabpanel_tab_content.width(this.width-a);this.tabpanel_content.width(this.width-a)}if(this.heightResizable){this.height=this.render.height();this.tabpanel.height(this.height-a);this.tabpanel_content.height(this.height-this.tabpanel_tab_content.get(0).offsetHeight)}this.showScroll();this.useableScroll();this.update()},setRenderWH:function(a){if(a){if(a.width!=undefined){this.render.width(a.width)}if(a.height!=undefined){this.render.height(a.height)}this.resize()}}};Fader=function(a){this.element=a.element;this.elementID=a.elementID;this.style=a.style;this.num=a.num;this.maxMove=a.maxMove;this.finishNum="string";this.interval=a.interval||10;this.step=a.step||20;this.onFinish=a.onFinish;this.isFinish=false;this.timer=null;this.method=this.num>=0;this.c=this.elementID?$("#"+this.elementID):this.element;this.run=function(){clearInterval(this.timer);this.fade();if(this.isFinish){this.onFinish&&this.onFinish()}else{var b=this;this.timer=setInterval(function(){b.run()},this.interval)}};this.fade=function(){if(this.finishNum=="string"){this.finishNum=(parseInt(this.c.css(this.style))||0)+this.num}var b=parseInt(this.c.css(this.style))||0;if(this.finishNum>b&&this.method){b+=this.step;if(b>=0){this.finishNum=b=0}}else{if(this.finishNum=this.maxMove){this.finishNum=b=this.maxMove*-1}}}if(this.finishNum<=b&&this.method||this.finishNum>=b&&!this.method){this.c.css(this.style,this.finishNum+"px");this.isFinish=true;this.finishNum="string"}else{this.c.css(this.style,b+"px")}}};Math.uuid=(function(){var a="0123456789abcdefghijklmnopqrstuvwxyz".split("");return function(c,d){var h=a,e=[],g=Math.random;d=d||h.length;if(c){for(var i=0;i