⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 layout.js

📁 ZK 基础介绍 功能操作 模块 结合数据库操作
💻 JS
字号:
zk.Layout=Class.create();zk.Layout.prototype={initialize:function(_1){this.id=_1.id;this.el=_1;zkau.setMeta(_1,this);var _2=this;this.fnResize=function(){_2.render();};this._regions={};},addRegion:function(_3,_4){this._regions[_3]=_4;},removeRegion:function(_5){delete this._regions[_5];},getRegion:function(_6){return this._regions[_6];},_getAmbit:function(_7,_8){var xy=Position.positionedOffset(_7);var w=_7.style.width,h=_7.style.height;var _c=w.indexOf("%");var _d=h.indexOf("%");if(_c>0){_7._width=$int(w.substring(0,_c));}if(_d>0){_7._height=$int(h.substring(0,_d));}var _e={x:xy[0],y:xy[1],width:_7._width?Math.max(Math.floor(this.el.offsetWidth*_7._width/100),0):_7.offsetWidth,height:_7._height?Math.max(Math.floor(this.el.offsetHeight*_7._height/100),0):_7.offsetHeight};if(_8){switch(_8){case "north":_e.height+=_7.split.offsetHeight;break;case "south":_e.height+=_7.split.offsetHeight;_e.y-=_7.split.offsetHeight;break;case "west":_e.width+=_7.split.offsetWidth;break;case "east":_e.width+=_7.split.offsetWidth;_e.x-=_7.split.offsetWidth;break;}}return _e;},render:function(){if(!zk.isRealVisible(this.el)){return;}var _f=this.el.offsetWidth,_10=this.el.offsetHeight;var cW=_f,cH=_10,cY=0,cX=0;var n=this.getRegion("north"),s=this.getRegion("south"),w=this.getRegion("west"),e=this.getRegion("east"),c=this.getRegion("center");if(n&&zk.isRealVisible(n)){var _1a=this._getAmbit(n,"north");var _1b=this._paserMargin(getZKAttr(n,"mars")||"0,0,0,0");_1a.width=_f-(_1b.left+_1b.right);_1a.x=_1b.left;_1a.y=_1b.top;cY=_1a.height+_1a.y+_1b.bottom;cH-=cY;_1a=this._resizeSplit(n,_1a,"north");this._resize(n,_1a);}else{if(n){var _1a=this._getAmbit(n.split);_1a.width=_f;_1a.x=_1a.y=0;cY=_1a.height+_1a.y;cH-=cY;this._resizeSplit(n,_1a,"north");}}if(s&&zk.isRealVisible(s)){var _1a=this._getAmbit(s,"south");var _1b=this._paserMargin(getZKAttr(s,"mars")||"0,0,0,0");_1a.width=_f-(_1b.left+_1b.right);_1a.x=_1b.left;var _1c=(_1a.height+_1b.top+_1b.bottom);_1a.y=_10-_1c+_1b.top;cH-=_1c;_1a=this._resizeSplit(s,_1a,"south");this._resize(s,_1a);}else{if(s){var _1a=this._getAmbit(s.split);_1a.width=_f;_1a.x=0;_1a.y=_10-_1a.height;cH-=_1a.height;this._resizeSplit(s,_1a,"south");}}if(w&&zk.isRealVisible(w)){var _1a=this._getAmbit(w,"west");var _1b=this._paserMargin(getZKAttr(w,"mars")||"0,0,0,0");_1a.height=cH-(_1b.top+_1b.bottom);_1a.x=_1b.left;_1a.y=cY+_1b.top;var _1c=(_1a.width+_1b.left+_1b.right);cX+=_1c;cW-=_1c;_1a=this._resizeSplit(w,_1a,"west");this._resize(w,_1a);}else{if(w){var _1a=this._getAmbit(w.split);_1a.height=cH;_1a.x=0;_1a.y=cY;cX+=_1a.width;cW-=_1a.width;this._resizeSplit(w,_1a,"west");}}if(e&&zk.isRealVisible(e)){var _1a=this._getAmbit(e,"east");var _1b=this._paserMargin(getZKAttr(e,"mars")||"0,0,0,0");_1a.height=cH-(_1b.top+_1b.bottom);var _1c=(_1a.width+_1b.left+_1b.right);_1a.x=_f-_1c+_1b.left;_1a.y=cY+_1b.top;cW-=_1c;_1a=this._resizeSplit(e,_1a,"east");this._resize(e,_1a);}else{if(e){var _1a=this._getAmbit(e.split);_1a.height=cH;_1a.x=_f-_1a.width;_1a.y=cY;cW-=_1a.width;this._resizeSplit(e,_1a,"east");}}if(c){var _1b=this._paserMargin(getZKAttr(c,"mars")||"0,0,0,0");var _1a={x:cX+_1b.left,y:cY+_1b.top,width:cW-(_1b.left+_1b.right),height:cH-(_1b.top+_1b.bottom)};this._resize(c,_1a);}},_paserMargin:function(val){var ms=val.split(",");return {top:$int(ms[0]),left:$int(ms[1]),right:$int(ms[2]),bottom:$int(ms[3])};},_resize:function(cmp,_20){cmp.style.left=_20.x+"px";cmp.style.top=_20.y+"px";this._resizeBody(cmp,_20);},_resizeSplit:function(cmp,_22,_23){if(_23=="north"||_23=="south"){cmp.split.splitbtn.style.marginLeft=((_22.width-cmp.split.splitbtn.offsetWidth)/2)+"px";}else{cmp.split.splitbtn.style.marginTop=((_22.height-cmp.split.splitbtn.offsetHeight)/2)+"px";}var _24=this._getAmbit(cmp.split);switch(_23){case "north":_22.height-=_24.height;cmp.split.style.left=_22.x+"px";cmp.split.style.top=(_22.y+_22.height)+"px";cmp.split.style.width=_22.width+"px";break;case "south":_22.height-=_24.height;_22.y+=_24.height;cmp.split.style.left=_22.x+"px";cmp.split.style.top=(_22.y-_24.height)+"px";cmp.split.style.width=_22.width+"px";break;case "west":_22.width-=_24.width;cmp.split.style.left=(_22.x+_22.width)+"px";cmp.split.style.top=_22.y+"px";cmp.split.style.height=_22.height+"px";break;case "east":_22.width-=_24.width;cmp.split.style.left=_22.x+"px";cmp.split.style.top=_22.y+"px";cmp.split.style.height=_22.height+"px";_22.x+=_24.width;break;}return _22;},_resizeBody:function(cmp,_26){_26.width=Math.max(0,_26.width);_26.height=Math.max(0,_26.height);var _27;var cid=getZKAttr(cmp,"cid");if(getZKAttr(cmp,"flex")=="true"&&cid!="zk_n_a"){_27=$e(getZKAttr(cmp,"cid"));}else{_27=$e($uuid(cmp)+"!cave");}cmp.bodyEl=_27;if(!this.ignoreResize(_27,_26.width,_26.height)){_26.width=zk.revisedSize(cmp,_26.width);cmp.style.width=_26.width+"px";_26.width=zk.revisedSize(_27,_26.width);_27.style.width=_26.width+"px";_26.height=zk.revisedSize(cmp,_26.height,true);cmp.style.height=_26.height+"px";_26.height=zk.revisedSize(_27,_26.height,true);_27.style.height=_26.height+"px";if(getZKAttr(cmp,"autoscl")=="true"){_27.style.overflow="auto";_27.style.position="relative";}else{_27.style.overflow="hidden";_27.style.position="";}}},ignoreResize:function(cmp,w,h){if(cmp._lastSize&&cmp._lastSize.width==w&&cmp._lastSize.height==h){return true;}else{cmp._lastSize={width:w,height:h};return false;}},cleanup:function(){this.el=this._regions=null;zk.rmOnResize(this.fnResize);}};zk.Layout.getOwnerLayout=function(cmp,_2d){var bl=$parentByType(cmp,"BorderLayout");var _2f=zkau.getMeta(bl);if(_2f||_2d){return _2f;}else{return new zk.Layout(bl);}};zk.Layout.getRootLayout=function(el){for(;el;el=$parentByType($real(el),"BorderLayout")){var lr=$e($uuid(el.parentNode));if($type(lr)=="LayoutRegion"){el=lr;}else{return el;}}};zk.Layout.cumulativeOffset=function(_32,_33){var _34=0,_35=0;do{if(_33&&_32==_33){break;}if(Element.getStyle(_32,"position")=="fixed"){_34+=zk.innerY()+_32.offsetTop;_35+=zk.innerX()+_32.offsetLeft;break;}else{_34+=_32.offsetTop||0;_35+=_32.offsetLeft||0;_32=zk.gecko&&_32!=document.body?Position.offsetParent(_32):_32.offsetParent;}}while(_32);return [_35,_34];};zkBorderLayout={};zkLayoutRegion={};zkBorderLayout.init=function(cmp){var _37=zk.Layout.getOwnerLayout(cmp);zk.addInitLater(function(){_37.render();},true);zk.addOnResize(_37.fnResize,true);};zkBorderLayout.childchg=function(cmp){zk.onResize(0,cmp);};zkBorderLayout.setAttr=function(cmp,nm,val){switch(nm){case "z.resize":var _3c=zkau.getMeta(cmp);if(_3c){_3c.render();}return true;}return false;};zkLayoutRegion.init=function(cmp){var _3e=$e(cmp.id+"!split");cmp=$real(cmp);var pos=getZKAttr(cmp,"pos");if(_3e){cmp.split=_3e;cmp.split.pos=pos;cmp.split.splitbtn=$e($uuid(cmp)+"!splitbtn");zkLayoutRegionSplit.init(_3e);}var _40=zk.Layout.getOwnerLayout(cmp);if(_40){_40.addRegion(pos,cmp);}};zkLayoutRegion.cleanup=function(cmp){cmp=$real(cmp);var _42=zk.Layout.getOwnerLayout(cmp,true);if(cmp.split){if(_42){_42.removeRegion(cmp.split.pos);}var dg=zkLayoutRegionSplit._drags[cmp.split.id];if(dg){delete zkLayoutRegionSplit._drags[cmp.split.id];dg.drag.destroy();}cmp.split.splitbtn=null;cmp.split=null;}else{if(_42){_42.removeRegion(getZKAttr(cmp,"pos"));}}cmp.bodyEl=null;if(_42){zk.onResize(0,_42.el);}};zkLayoutRegion.setAttr=function(cmp,nm,val){cmp=$real(cmp);switch(nm){case "z.cid":setZKAttr(cmp,"cid",val);return true;case "z.mars":setZKAttr(cmp,"mars",val);var l=zk.Layout.getOwnerLayout(cmp);if(l){l.render();}return true;case "z.maxs":setZKAttr(cmp,"maxs",val);return true;case "z.mins":setZKAttr(cmp,"mins",val);return true;case "z.autoscl":setZKAttr(cmp,"autoscl",val);if(val=="true"){cmp.bodyEl.style.overflow="auto";cmp.bodyEl.style.position="relative";}else{cmp.bodyEl.style.overflow="hidden";cmp.bodyEl.style.position="";}return true;case "z.colps":setZKAttr(cmp,"colps",val);zkLayoutRegionSplit._fixbtn(cmp.split);zkLayoutRegionSplit._fixsplit(cmp.split);return true;case "z.splt":setZKAttr(cmp,"splt",val);var _48=cmp.split.pos=="west"||cmp.split.pos=="east"?false:true;if(getZKAttr(cmp,"open")!="false"&&val=="true"){cmp.split.style.cursor=_48?"s-resize":"e-resize";zk.rmClass(cmp.split,_48?"layout-split-v-ns":"layout-split-h-ns");zk.addClass(cmp.split,_48?"layout-split-v":"layout-split-h");}else{cmp.split.style.cursor="default";zk.addClass(cmp.split,_48?"layout-split-v-ns":"layout-split-h-ns");zk.rmClass(cmp.split,_48?"layout-split-v":"layout-split-h");}zkLayoutRegionSplit._fixsplit(cmp.split);return true;case "style.height":cmp.style["height"]=val;cmp._height=false;return true;case "style.width":cmp.style["width"]=val;cmp._width=false;return true;case "z.open":zkLayoutRegionSplit.open(cmp.split,val=="true",true,true);return true;}return false;};zkLayoutRegionSplit={};zkLayoutRegionSplit._drags={};zkLayoutRegionSplit.init=function(_49){var _4a=$real(_49);zkLayoutRegionSplit._fixsplit(_49);var _4b=function(x,y){return zkLayoutRegionSplit._snap(_49,x,y);};var _4e=_49.pos=="west"||_49.pos=="east"?false:true;var _4f=zkLayoutRegionSplit._drags[_49.id]={vert:_4e,drag:new Draggable(_49,{constraint:_4e?"vertical":"horizontal",ghosting:zkLayoutRegionSplit._ghostsizing,snap:_4b,ignoredrag:zkLayoutRegionSplit._ignoresizing,zindex:12000,endeffect:zkLayoutRegionSplit._endDrag})};zk.listen(_49.splitbtn,"click",function(){zkLayoutRegionSplit.open(_49,getZKAttr(_4a,"open")=="false");});if(zk.ie){zk.listen(_49.splitbtn,"mouseover",function(){_49.splitbtn.style.filter="alpha(opacity=100);";});zk.listen(_49.splitbtn,"mouseout",function(){_49.splitbtn.style.filter="alpha(opacity=50);";});}zkLayoutRegionSplit._fixbtn(_49);if(getZKAttr(_4a,"open")=="false"){zkLayoutRegionSplit.open(_49,false,true,true);}else{if(getZKAttr(_4a,"splt")=="true"){_49.style.cursor=_4e?"s-resize":"e-resize";}else{zk.addClass(_49,_4e?"layout-split-v-ns":"layout-split-h-ns");zk.rmClass(_49,_4e?"layout-split-v":"layout-split-h");_49.style.cursor="default";}}_49.splitbtn.style.cursor="pointer";};zkLayoutRegionSplit._fixsplit=function(_50){var _51=$real(_50);zk.show(_50.id,!(getZKAttr(_51,"splt")=="false"&&getZKAttr(_51,"colps")=="false"));};zkLayoutRegionSplit._fixbtn=function(_52){var _53=$real(_52);var _54=getZKAttr(_53,"colps");if(_54=="false"){_52.splitbtn.style.display="none";}else{var _55=_52.pos=="west"||_52.pos=="east"?false:true;var _56=_54=="true";if(_52.pos=="east"||_52.pos=="south"){_56=!_56;}if(getZKAttr(_53,"open")=="false"){_56=!_56;}_52.splitbtn.className=zk.renType(_52.splitbtn.className,_55?_56?"t":"b":_56?"l":"r");_52.splitbtn.style.display="";}};zkLayoutRegionSplit._ignoresizing=function(_57,_58){var dg=zkLayoutRegionSplit._drags[_57.id];if(dg){var _5a=$real(_57);if(_5a&&getZKAttr(_5a,"open")=="true"&&getZKAttr(_5a,"splt")=="true"){var _5b=$int(getZKAttr(_5a,"maxs"))||2000;var _5c=$int(getZKAttr(_5a,"mins"))||0;var ol=zk.Layout.getOwnerLayout(_5a);var _5e=ol._paserMargin(getZKAttr(_5a,"mars")||"0,0,0,0");var lr=zk.sumStyles(_5a,"lr",zk.borders)+zk.sumStyles(_5a,"lr",zk.paddings)+(_57.pos=="west"?_5e.left:_5e.right);var tb=zk.sumStyles(_5a,"tb",zk.borders)+zk.sumStyles(_5a,"tb",zk.paddings)+(_57.pos=="north"?_5e.top:_5e.bottom);var min=0;switch(_57.pos){case "north":case "south":var _62=$e($uuid(_5a));var _63=_57.pos=="north"?zk.nextSibling(_62,"DIV"):zk.previousSibling(_62,"DIV");if(_63){var rr=$real(_63);var pos=getZKAttr(rr,"pos");if(pos=="center"){_5b=Math.min(_5b,(_5a.offsetHeight+rr.offsetHeight)-min);}else{_5b=Math.min(_5b,ol.el.offsetHeight-rr.offsetHeight-rr.split.offsetHeight-_57.offsetHeight-min);}}else{_5b=ol.el.offsetHeight-_57.offsetHeight;}break;case "west":case "east":var _62=$e($uuid(_5a));var _63=_57.pos=="west"?zk.nextSibling(_62,"DIV"):zk.previousSibling(_62,"DIV");if(_63){var rr=$real(_63);var pos=getZKAttr(rr,"pos");if(pos=="center"){_5b=Math.min(_5b,(_5a.offsetWidth+rr.offsetWidth)-min);}else{_5b=Math.min(_5b,ol.el.offsetWidth-rr.offsetWidth-rr.split.offsetWidth-_57.offsetWidth-min);}}else{_5b=ol.el.offsetWidth-_57.offsetWidth;}break;}var ofs=Position.cumulativeOffset(_5a);dg.drag.z_rootlyt={maxs:_5b,mins:_5c,top:ofs[1],left:ofs[0],right:_5a.offsetWidth,bottom:_5a.offsetHeight};return false;}}return true;};zkLayoutRegionSplit._endDrag=function(_67,_68){var dg=zkLayoutRegionSplit._drags[_67.id];if(!dg){return;}var _6a=$real(_67);if(_67.pos=="west"||_67.pos=="east"){_6a.style["width"]=dg.drag.z_point[0]+"px";}else{_6a.style["height"]=dg.drag.z_point[1]+"px";}_6a._width=_6a._height=false;var _6b=zk.Layout.getOwnerLayout(_6a);_6b.render();zk.onResize(0,_6b.el);dg.drag.z_rootlyt=null;};zkLayoutRegionSplit._snap=function(_6c,x,y){var dd=zkLayoutRegionSplit._drags[_6c.id];if(dd){var b=dd.drag.z_rootlyt;var w,h;switch(_6c.pos){case "north":if(y>b.maxs+b.top){y=b.maxs+b.top;}if(y<b.mins+b.top){y=b.mins+b.top;}w=x;h=y-b.top;break;case "south":if(b.top+b.bottom-y-_6c.offsetHeight>b.maxs){y=b.top+b.bottom-b.maxs-_6c.offsetHeight;h=b.maxs;}else{if(b.top+b.bottom-b.mins-_6c.offsetHeight<=y){y=b.top+b.bottom-b.mins-_6c.offsetHeight;h=b.mins;}else{h=b.top-y+b.bottom-_6c.offsetHeight;}}w=x;break;case "west":if(x>b.maxs+b.left){x=b.maxs+b.left;}if(x<b.mins+b.left){x=b.mins+b.left;}w=x-b.left;h=y;break;case "east":if(b.left+b.right-x-_6c.offsetWidth>b.maxs){x=b.left+b.right-b.maxs-_6c.offsetWidth;w=b.maxs;}else{if(b.left+b.right-b.mins-_6c.offsetWidth<=x){x=b.left+b.right-b.mins-_6c.offsetWidth;w=b.mins;}else{w=b.left-x+b.right-_6c.offsetWidth;}}h=y;break;}dd.drag.z_point=[w,h];}return [x,y];};zkLayoutRegionSplit.open=function(_73,_74,_75,_76){var _77=$real(_73);if(!_76&&(getZKAttr(_77,"open")!="false")==_74){return;}var _78=getZKAttr(_77,"colps");if(_78=="false"){return;}setZKAttr(_77,"open",_74?"true":"false");var _79=_73.pos=="west"||_73.pos=="east"?false:true;if(_74&&getZKAttr(_77,"splt")=="true"){_73.style.cursor=_79?"s-resize":"e-resize";zk.rmClass(_73,_79?"layout-split-v-ns":"layout-split-h-ns");zk.addClass(_73,_79?"layout-split-v":"layout-split-h");}else{_73.style.cursor="default";zk.addClass(_73,_79?"layout-split-v-ns":"layout-split-h-ns");zk.rmClass(_73,_79?"layout-split-v":"layout-split-h");}zkLayoutRegionSplit._fixbtn(_73);var _7a=zk.Layout.getOwnerLayout(_73);zk.show(_77.id,_74);_7a.render();if(!_75){zkau.send({uuid:$uuid(_73),cmd:"onOpen",data:[_74]},zkau.asapTimeout(_77,"onOpen"));}zk.onResize(0,_7a.el);};zkLayoutRegionSplit._ghostsizing=function(dg,_7c,_7d){if(_7c){var _7d=zkau.beginGhostToDIV(dg);var _7e="<div id=\"zk_ddghost\" style=\"background:#AAA;position:absolute;top:"+_7d[1]+"px;left:"+_7d[0]+"px;width:"+zk.offsetWidth(dg.element)+"px;height:"+zk.offsetHeight(dg.element)+"px;\"><img src=\""+zk.getUpdateURI("/web/img/spacer.gif")+"\"/></div>";document.body.insertAdjacentHTML("afterbegin",_7e);dg.element=$e("zk_ddghost");}else{zkau.endGhostToDIV(dg);}};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -