/** * 底部工具栏左右控制js * @author:tangw 2010-11-07 */ var RL = {}; RL = { defCount:6, arWindow:[], startIndex: 0, endIndex:5, currShowW:"", up:function(){//向上 var len = this.arWindow.length; if( this.endIndex == (len-1) ){ this.setStyle("f_v_w_down", ""); } var sid = --this.startIndex; var eid = this.endIndex; if(sid==0){ this.setStyle("f_v_w_up", "none"); } var _eid = this.arWindow[eid]; this.setStyle("f_v_window_min_"+_eid, "none"); var _sid = this.arWindow[sid]; this.setStyle("f_v_window_min_"+_sid, "block"); this.endIndex--; }, down:function(){//向下 var len = this.arWindow.length; this.setStyle("f_v_w_up", "block"); var id = this.arWindow[this.startIndex]; this.setStyle("f_v_window_min_"+id, "none"); var count = ++this.endIndex; if( count == len-1 ){ this.setStyle("f_v_w_down","none"); } var eid = this.arWindow[count]; this.setStyle("f_v_window_min_"+eid,"block"); this.startIndex++; }, addW:function(id){ var count = this.arWindow.length; if( count > (this.defCount-1)){ this.setStyle("f_v_w_down","block"); } this.arWindow[count] = id; }, setStyle:function(id,str){ var o = this.getObj(id); if(o){ o.style.display = str; } }, getObj:function(id){ return document.getElementById(id); }, getArCount:function(id){ var c = 0; var len = this.getLen(); for(var i=0;i<len;i++){ if( id == this.arWindow[i]){ c= i; break; } } return c; }, getLen:function(){ return this.arWindow.length; }, removeAr:function(c){ var len = this.getLen(); this.arWindow = this.arWindow.slice(0,c).concat(this.arWindow.slice(c+1,len)); }, removeW:function(id){ var len = this.getLen(); var currIndex = this.getArCount(id);//当前位置 if( len >= (this.defCount+1) ){ if( currIndex<=this.startIndex ){//当前 <= 开始 if( currIndex<this.startIndex ){ //直接隐藏 this.setStyle("f_v_window_min_"+id, "none"); }else{ var e = this.endIndex+1; //隐藏 this.setStyle("f_v_window_min_"+id, "none"); //显示 var eid = this.arWindow[e]; this.setStyle("f_v_window_min_"+eid, "block"); } }else if( currIndex>=this.endIndex ){// 当前>=结束 if( currIndex==this.endIndex ){ var e = -1; if( currIndex==(len-1) ){ if(this.startIndex>0){ e = --this.startIndex; --this.endIndex; } }else{ e = this.endIndex+1; } if(e!=-1){ var eid = this.arWindow[e]; this.setStyle("f_v_window_min_"+eid, "block"); } }else{ //直接隐藏 this.setStyle("f_v_window_min_"+id, "none"); } }else if( this.startIndex < currIndex < this.endIndex){ //开始<当前<结束 var e = -1; if( this.startIndex == 0 ){ e = this.endIndex+1; }else{ if( this.endIndex == (len-1) ){ e = --this.startIndex; --this.endIndex; }else{ e = this.endIndex+1; } } this.setStyle("f_v_window_min_"+id, "none"); if( e!=-1){ var eid = this.arWindow[e]; this.setStyle("f_v_window_min_"+eid, "block"); } } //删除 this.removeAr(currIndex); //控制样式 this.setStyle("f_v_w_up",this.startIndex==0?"none":"block"); this.setStyle("f_v_w_down",this.endIndex == (this.getLen()-1)?"none":"block"); }else{ this.removeAr(currIndex); } } }
转载于:https://www.cnblogs.com/tw5566/archive/2010/11/23/2247878.html