You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
18 KiB
Plaintext

11 months ago
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=$("<DIV></DIV>");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=$("<DIV></DIV>");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=$("<DIV></DIV>");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=$("<DIV></DIV>");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=$("<DIV></DIV>");this.tabpanel_move_content.addClass("tabpanel_move_content");this.tabpanel_move_content.appendTo(this.tabpanel_tab_content);this.tabpanel_mover=$("<UL></UL>");this.tabpanel_mover.addClass("tabpanel_mover");this.tabpanel_mover.appendTo(this.tabpanel_move_content);this.tabpanel_tab_spacer=$("<DIV></DIV>");this.tabpanel_tab_spacer.addClass("tabpanel_tab_spacer");this.tabpanel_tab_spacer.appendTo(this.tabpanel_tab_content);this.tabpanel_content=$("<DIV></DIV>");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<this.items.length;b++){this.items[b].notExecuteMoveSee=true;this.addTab(this.items[b])}if(this.active>=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.tabpan