📄 paneset.js
字号:
Zapatec.SRProp.prototype.restoreProps=function(propName){var result=[];for(var i=0;i<arguments.length;++i){if(this.restoreProp(arguments[i])){result.push(arguments[i]);}}return result;}Zapatec.SRProp.prototype.restoreAll=function(){var self=this;this.getSavedProps().hashEach(function(i){self.restoreProp(i);});}Zapatec.SRProp.prototype.getProp=function(propName){return this.getSavedProps()[propName];}Zapatec.SRProp.prototype.isEmpty=function(){return this.getSavedProps().hashIsEmpty();};Zapatec.SRProp.prototype.destroy=function(){this.getObject().restorer=null;for(var iProp in this){this[iProp]=null;}return null;};Zapatec.CommandEvent={};Zapatec.CommandEvent.fireEvent=function(strEvent){if(!this.events[strEvent]){return;}var arrListeners=this.events[strEvent].listeners.slice();this._setReturnedValue(null);this._setEventPropagation(true);for(var iListener=0;iListener<arrListeners.length;iListener++){var arrArgs=[].slice.call(arguments,1);arrListeners[iListener].apply(this,arrArgs);var result=this._getReturnedValue();if(!this._getEventPropagation()){return result;}if(result=="re-execute"){this.fireEvent(strEvent);break;}else if(result=="parent-re-execute"){return result;}}return this._getReturnedValue();};Zapatec.CommandEvent.returnValue=function(val){this._setReturnedValue(val);};Zapatec.CommandEvent._setReturnedValue=function(val){this.returnedValue=val;};Zapatec.CommandEvent._getReturnedValue=function(){return this.returnedValue;};Zapatec.CommandEvent.stopPropagation=function(){this._setEventPropagation(false);};Zapatec.CommandEvent._setEventPropagation=function(on){this.eventPropagation=on;};Zapatec.CommandEvent._getEventPropagation=function(){return this.eventPropagation;};Zapatec.GlobalEvents=new Zapatec.EventDriven();Zapatec.implement(Zapatec.GlobalEvents,"Zapatec.CommandEvent");Zapatec.GlobalEvents.init();Zapatec.Utils.getWidth=function(el){if(!Zapatec.isHtmlElement(el)){return false;}return el.offsetWidth};Zapatec.Utils.getHeight=function(el){if(!Zapatec.isHtmlElement(el)){return false;}return el.offsetHeight};Zapatec.Utils.setWidth=function(el,width){width=Math.round(width);if(!Zapatec.isHtmlElement(el)||width<=0){return false;}var oldWidth=el.style.width,newWidth;el.style.width=width+"px";if(Zapatec.Utils.getWidth(el)!=width){newWidth=width-(Zapatec.Utils.getWidth(el)-width);if(newWidth>0){el.style.width=newWidth+"px";if(Zapatec.Utils.getWidth(el)!=width){el.style.width=oldWidth;Zapatec.Log({description:"Can't set the width - "+width+"px!",type:"warning"});return false;}}else{el.style.width=oldWidth;Zapatec.Log({description:"Can't set the width - "+width+"px!",type:"warning"});return false;}}return true;};Zapatec.Utils.setHeight=function(el,height){height=Math.round(height);if(!Zapatec.isHtmlElement(el)||height<=0){return false;}var oldHeight=el.style.height,newHeight;el.style.height=height+"px";if(Zapatec.Utils.getHeight(el)!=height){newHeight=height-(Zapatec.Utils.getHeight(el)-height);if(newHeight>0){el.style.height=newHeight+"px";if(Zapatec.Utils.getHeight(el)!=height){el.style.height=oldHeight;Zapatec.Log({description:"Can't set the height - "+height+"px!",type:"warning"});return false;}}else{el.style.height=oldHeight;Zapatec.Log({description:"Can't set the height - "+height+"px!",type:"warning"});return false;}}return true;};Zapatec.Utils.fixateWidth=function(el){return Zapatec.Utils.setWidth(el,Zapatec.Utils.getWidth(el));};Zapatec.Utils.fixateHeight=function(el){return Zapatec.Utils.setHeight(el,Zapatec.Utils.getHeight(el));};Zapatec.Utils.makeSafelySizable=function(el,restorer){if(el.sizable){return true;}if(!Zapatec.isHtmlElement(el)){return false;}if(!restorer){restorer=el.restorer;}if(!restorer||!restorer.getObject||restorer.getObject()!=el){restorer=new Zapatec.SRProp(el);}restorer.saveProps("style.width","style.height","style.overflow");Zapatec.Utils.fixateWidth(el);Zapatec.Utils.fixateHeight(el);var overflow=Zapatec.Utils.getStyleProperty(el,"overflow");if(overflow==""||overflow=="visible"){Zapatec.Log({description:"There is the chance that this element with overflow visible will not be sized correctly!",type:"warning"});}el.sizable=true;return true;};Zapatec.Utils.restoreOfSizing=function(el){if(!el||!el.restorer||!el.sizable){return false;}el.restorer.restoreProps("style.width","style.height","style.overflow");if(el.restorer.isEmpty()){el.restorer.destroy();}el.sizable=false;return true;};Zapatec.Utils.makeSafelyMovable=function(el,within,restorer){if(!Zapatec.isHtmlElement(el)){return false;}if(!within){within=document.body;}if(el.within==within){return true;}if(!restorer){restorer=el.restorer;}if(!restorer||!restorer.getObject||restorer.getObject()!=el){restorer=new Zapatec.SRProp(el);}el.within=within;if(within!=document.body&&within.style.position!="absolute"){restorer.saveProp("within.style.position");within.style.position="relative";}if(within!=document.body){var pos1=Zapatec.Utils.getElementOffset(within);}else{var pos1={x:0,y:0};}var pos2=Zapatec.Utils.getElementOffset(el);var x=pos2.x-pos1.x;var y=pos2.y-pos1.y;restorer.saveProps("style.left","style.top");el.style.left=x+"px";el.style.top=y+"px";if(el.style.position!="absolute"){restorer.saveProp("style.position");el.style.position="absolute";}if(el.parentNode!=within){restorer.saveProps("parentNode","nextSibling");within.appendChild(el);}restorer.saveProp("style.margin");el.style.margin="0px";return true;};Zapatec.Utils.moveTo=function(el,x,y){if(!Zapatec.isHtmlElement(el)){return false;}var pos=null;if(Zapatec.FixateOnScreen.isRegistered(el)){pos=Zapatec.FixateOnScreen.correctCoordinates(x,y);if(Zapatec.is_ie&&!Zapatec.is_ie7){el.style.setExpression("left",pos.x);el.style.setExpression("top",pos.y);return true;}}else{pos={x:parseInt(x,10)+"px",y:parseInt(y,10)+"px"};}if(x||x===0){el.style.left=pos.x;}if(y||y===0){el.style.top=pos.y;}return true;};Zapatec.Utils.getPos=function(el){if(!Zapatec.isHtmlElement(el)){return false;}var pos=null;if(pos=Zapatec.FixateOnScreen.parseCoordinates(el)){return pos;}return{x:el.offsetLeft,y:el.offsetTop}};Zapatec.Utils.moveFor=function(el,offsetX,offsetY){var oldPos=Zapatec.Utils.getPos(el);if(oldPos){return Zapatec.Utils.moveTo(el,oldPos.x+offsetX,oldPos.y+offsetY);}else{return false;}};Zapatec.Utils.restoreOfMove=function(el){if(!el.within)return false;el.restorer.restoreProps("style.position","parentNode","style.margin","nextSibling","within.style.position","style.left","style.top");if(el.restorer.isEmpty()){el.restorer.destroy();}el.within=null;return true;};Zapatec.Utils.getElementsByAttribute=function(attribute,value,within,recursive,match){if(!attribute){return false;}within=Zapatec.Widget.getElementById(within);within||(within=document.body);var element=within.firstChild;result=[];while(element){if(element[attribute]){if(typeof value=="undefined"||element[attribute]==value){result.push(element);}else if(match&&typeof element[attribute]=="string"&&element[attribute].indexOf(value)!=-1){result.push(element);}};if(recursive&&element.hasChildNodes()){result=result.concat(Zapatec.Utils.getElementsByAttribute(attribute,value,element,recursive,match));}element=element.nextSibling};return Zapatec.Array(result);};Zapatec.Utils.applyToElements=function(constructor,elements,config,configOption){if(typeof constructor!="function"||!Zapatec.isArray(elements)){return false;}elements=Zapatec.Array(elements);if(!configOption){configOption="container";}if(!config||typeof config!="object"){config={};}var result=Zapatec.Array();elements.each(function(index,element){config[configOption]=element;result.push(new constructor(config));});return result;};Zapatec.Utils.img2div=function(el){if(!Zapatec.isHtmlElement(el)){return null;}if((/img/i).test(el.nodeName)){var div=document.createElement('div');var objImage=new Image();objImage.onload=function(){div.style.width=objImage.width+'px';div.style.height=objImage.height+'px';div.style.fontSize='0px';objImage.onload=null;};objImage.src=el.src;div.style.backgroundImage='url('+el.src+')';div.style.backgroundColor='transparent';var id=el.id;var className=el.className;el.parentNode.replaceChild(div,el);div.id=id;div.className=className;return div}else{return el}};Zapatec.Utils.getElementPath=function(element,parent){if(!Zapatec.isHtmlElement(element)||!Zapatec.isHtmlElement(parent)){return false;}var res=[];var el=element;while(el&&el!=parent){var number=1;while(el.previousSibling){++number;el=el.previousSibling;}res.unshift(number);el=el.parentNode;}return res.join("-");};Zapatec.Utils.cover=Zapatec.Utils.createElement("div");Zapatec.Utils.cover.style.overflow="hidden";Zapatec.Utils.cover.style.backgroundImage="url("+Zapatec.zapatecPath+"zpempty.gif)";Zapatec.Utils.cover.style.display="none";Zapatec.Utils.cover.id="zpCoverControl";Zapatec.Utils.cover.show=function(zIndex,cursor,mouseMoveHandler,mouseUpHandler){if(!this.parentNode){document.body.appendChild(this);}if(this.style.display!="none"){this.hide();}this.style.display="block";Zapatec.Utils.makeSafelyMovable(this,null,document.body);var x=0;var y=0;y+=Zapatec.Utils.getPageScrollY();x+=Zapatec.Utils.getPageScrollX();Zapatec.Utils.moveTo(this,x,y);var dim=Zapatec.Utils.getWindowSize();this.style.width=dim.width+"px";this.style.height=dim.height+"px";Zapatec.FixateOnScreen.register(this);this.style.zIndex=zIndex;this.style.cursor=cursor;if(typeof mouseMoveHandler=="function"){Zapatec.Utils.addEvent(this,'mousemove',mouseMoveHandler);}if(typeof mouseUpHandler=="function"){Zapatec.Utils.addEvent(this,'mouseup',mouseUpHandler);}this.mouseMoveHandler=mouseMoveHandler;this.mouseUpHandler=mouseUpHandler;};Zapatec.Utils.cover.hide=function(){Zapatec.FixateOnScreen.unregister(this);if(typeof this.mouseMoveHandler=="function"){Zapatec.Utils.removeEvent(this,'mousemove',this.mouseMoveHandler);}if(typeof this.mouseUpHandler=="function"){Zapatec.Utils.removeEvent(this,'mouseup',this.mouseUpHandler);}this.mouseMoveHandler=null;this.mouseUpHandler=null;this.style.zIndex="";this.style.cursor="";this.style.display="none";};Zapatec.Movable={};Zapatec.Movable.setPosition=function(x,y){if(!this.isMovableSafely()){Zapatec.Log({description:"The object with ID '"+this.id+"' was not prepared for moving! Use obj.makeMovable() to do so!",type:"warning"});return false;}var msgValue=null,moveConfig=this.getMoveConfig();if(x||x===0){msgValue=x;x=this._parseCoordinate(x,"x",moveConfig.moveLayer);if(!x&&x!==0){Zapatec.Log({description:"The X coordinate "+msgValue+" can not be set for object with ID '"+this.id+"'!",type:"warning"});return false;}}if(y||y===0){msgValue=y;y=this._parseCoordinate(y,"y",moveConfig.moveLayer);if(!y&&y!==0){Zapatec.Log({description:"The Y coordinate "+msgValue+" can not be set for object with ID '"+this.id+"'!",type:"warning"});return false;}}var elements=Zapatec.Array(this.getMovableElements());if(this.fireEvent("beforePositionChange",x,y)===false){return false;}if(Zapatec.GlobalEvents.fireEvent("beforePositionChange",x,y,this)===false){return false;}this._proceedElementsCoords(x,y,elements);if(this.isMoving()){this.fireEvent("onMove",x||this.getPosition().x,y||this.getPosition().y);Zapatec.GlobalEvents.fireEvent("onMove",x||this.getPosition().x,y||this.getPosition().y,this);}this.fireEvent("onPositionChange",x||this.getPosition().x,y||this.getPosition().y);Zapatec.GlobalEvents.fireEvent("onPositionChange",x||this.getPosition().x,y||this.getPosition().y,this);return true;};Zapatec.Movable.setOrientedPosition=function(x,y){switch(this.getMoveConfig().orientation){case"vertical":{return this.setPosition(y,x);}case"horizontal":{return this.setPosition(x,y);}}return false;};Zapatec.Movable.setPagePosition=function(x,y){var moveConfig=this.getMoveConfig();if(moveConfig.moveLayer==document.body){return this.setPosition(x,y);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -