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

📄 window.js

📁 zapatec suite 最新版 20070204,非常棒的ajax widgets 工具包
💻 JS
📖 第 1 页 / 共 5 页
字号:
movable.parentNode.insertBefore(newNode,movable);newNode.style.visibility="visible";copies.push(newNode);if(movable==self.getMovableMeasurement()){measurement=newNode;}}else if(Zapatec.isMovableObj(movable)){var elems=Zapatec.Array(movable.getMovableElements());elems.each(arguments.calee);}});toggleEvents("add",hooks,listenersObj);if(!measurement){measurement=this.getMovableMeasurement();}restorer.saveProp("getMovableElements");restorer.saveProp("isMovableSafely()");this._setMovableSafely(false);this.getMovableElements=function(resetArray){var arr=copies;copies=resetArray?null:copies;return arr;};restorer.saveProp("getMovableMeasurement");this.getMovableMeasurement=function(){return measurement;};}else if(dragState=="dragEnd"){var elements=Zapatec.Array(this.getMovableElements(true));elements.each(function(index,movable){if(config.method=="dummy"){movable.parentNode.removeChild(movable);}movable.dragObj=null;if(config.eventCapture){Zapatec.Utils.removeEvent(movable,'mousemove',listenersObj.mousemove);Zapatec.Utils.removeEvent(movable,'mouseup',listenersObj.mouseup);}});this.restoreOfMove();restorer.restoreProp("getMovableElements");this._setMovableSafely(restorer.getProp("isMovableSafely()"));restorer.restoreProp("isMovableSafely()");restorer.restoreProp("getMovableMeasurement");}break;}default:{break;}}};Zapatec.Draggable._proceedDragStyles=function(movable,dragState){var config=this.getDragConfig();if(config.overwriteCSS){if(dragState=="dragStart"){movable.restorer.saveProp("className");movable.className=config.overwriteCSS;}else if(dragState=="dragEnd"){movable.restorer.restoreProp("className");}}if(config.dragCSS){if(dragState=="dragStart"){Zapatec.Utils.addClass(movable,config.dragCSS);}else if(dragState=="dragEnd"){Zapatec.Utils.removeClass(movable,config.dragCSS);}}};Zapatec.Draggable._setMovingPoint=function(x,y){var movingPoint=this._getMovingPointObject();if(x===null||y===null){movingPoint.x=null;movingPoint.y=null;movingPoint.offsetX=null;movingPoint.offsetY=null;return;}if(movingPoint.x===null||movingPoint.y===null){var pos=this.getPagePosition();movingPoint.x=x;movingPoint.y=y;movingPoint.offsetX=x-pos.x;movingPoint.offsetY=y-pos.y;}else{var pos=this.getPagePosition();movingPoint.x=pos.x+movingPoint.offsetX;movingPoint.y=pos.y+movingPoint.offsetY;}return;};Zapatec.Draggable.getMovingPoint=function(){var movingPoint=this._getMovingPointObject();return{x:movingPoint.x,y:movingPoint.y};};Zapatec.Draggable._getMovingPointObject=function(){if(!this.movingPoint||typeof this.movingPoint!="object"){this.movingPoint={x:null,y:null,offsetX:null,offsetY:null};}return this.movingPoint;};Zapatec.Utils.Draggable=function(config){if(arguments.length>1){var args=arguments[1];args.container=config;config=args;}if(typeof config.left!="undefined"||typeof config.right!="undefined"||typeof config.top!="undefined"||typeof config.bottom!="undefined"){config.limit={minX:config.left,maxX:config.right,minY:config.top,maxY:config.bottom};}if(config.dragLayer){config.moveLayer=config.dragLayer;}if(!config.eventListeners){config.eventListeners={};}if(config.beforeDragInit){config.eventListeners.beforeDragInit=config.beforeDragInit;}if(config.beforeDragMove){config.eventListeners.beforeDragMove=config.beforeDragMove;}if(config.beforeDragEnd){config.eventListeners.beforeDragEnd=config.beforeDragEnd;}if(config.onDragInit){config.eventListeners.onDragInit=config.onDragInit;}if(config.onDragMove){config.eventListeners.onDragMove=config.onDragMove;}if(config.onDragEnd){config.eventListeners.onDragEnd=config.onDragEnd;}if(config.stopEv){config.stopEvent=config.stopEv;}config=Zapatec.Hash.remove(config,"left","top","right","bottom","dragLayer","beforeDragInit","beforeDragMove","beforeDragEnd","onDragInit","onDragMove","onDragEnd","stopEv");Zapatec.Utils.Draggable.SUPERconstructor.call(this,config);};Zapatec.Utils.Draggable.id="Zapatec.Utils.Draggable";Zapatec.inherit(Zapatec.Utils.Draggable,Zapatec.Utils.Movable);Zapatec.implement(Zapatec.Utils.Draggable,"Zapatec.Draggable");Zapatec.Utils.Draggable.prototype.init=function(config){Zapatec.Utils.Draggable.SUPERclass.init.call(this,config);this.makeDraggable();};Zapatec.Utils.Draggable.prototype.configure=function(config){this.defineConfigOption("method","cut");this.defineConfigOption("stopEvent",true);this.defineConfigOption("eventCapture",false);this.defineConfigOption("handler",null);this.defineConfigOption("dragCSS",null);this.defineConfigOption("overwriteCSS",null);this.defineConfigOption("copyChilds",true);this.defineConfigOption("makeMovable",false);Zapatec.Utils.Draggable.SUPERclass.configure.call(this,config);config=this.getConfiguration();if(Zapatec.is_opera){config.eventCapture=true;}config.handler=Zapatec.Widget.getElementById(config.handler);config.handler=Zapatec.Utils.img2div(config.handler);if(!Zapatec.isHtmlElement(config.handler)){config.handler=config.container;}};Zapatec.Utils.Draggable.prototype.reconfigure=function(config){Zapatec.Utils.Draggable.SUPERclass.reconfigure.call(this,config);};Zapatec.Utils.Draggable.prototype.getDraggableElements=function(){return this.movableElements;};Zapatec.Utils.Draggable.prototype._getDraggableHooks=function(){return this.getConfiguration().handler;};Zapatec.Utils.initDragObjects=function(className,el,recursive,config){if(!className)return;var elements=Zapatec.Utils.getElementsByAttribute('className',className,el,recursive,true);return Zapatec.Utils.applyToElements(Zapatec.Utils.Draggable,elements,config);}Zapatec.Sizable={};Zapatec.Sizable.setWidth=function(width){return this._setDimension(width,"width");};Zapatec.Sizable.setHeight=function(height){return this._setDimension(height,"height");};Zapatec.Sizable.setOrientedWidth=function(width){if(!this.getOrientation){return false;}switch(this.getOrientation()){case"vertical":return this._setDimension(width,"height");case"horizontal":return this._setDimension(width,"width");}};Zapatec.Sizable.setOrientedHeight=function(height){if(!this.getOrientation){return false;}switch(this.getOrientation()){case"vertical":return this._setDimension(height,"width");case"horizontal":return this._setDimension(height,"height");}};Zapatec.Sizable._setDimension=function(val,dimension){var evDim=dimension.charAt(0).toUpperCase()+dimension.slice(1);if(!this.isSizableSafely(dimension)){Zapatec.Log({description:"The object "+dimension+" ID '"+this.id+"' was not prepared for sizing! Use obj.makeSizable() to do so!",type:"warning"});return false;}var msgValue=val+"";val=this._parseSize(val,dimension);if(!val){Zapatec.Log({description:"The "+dimension+" "+msgValue+" can not be set for object with ID '"+this.id+"'!",type:"warning"});return false;}var elements=Zapatec.Array(this.getSizableElements(dimension));var toRestore=[],self=this;if(this.fireEvent("before"+evDim+"Change",val)===false){return false;}if(Zapatec.GlobalEvents.fireEvent("before"+evDim+"Change",val,this)===false){return false;}if(!this._proceedElementsSizes(val,dimension,elements,toRestore)){this._rollBackSizing(toRestore,dimension);this.fireEvent(dimension+"ChangeFailure",val)Zapatec.GlobalEvents.fireEvent(dimension+"ChangeFailure",val,this)Zapatec.Log({description:"Impossible to set the "+dimension+" "+msgValue+" for the object with ID '"+this.id+"'!",type:"warning"});return false;}else{if(this.isSizing()){if(dimension=="width"){this.fireEvent("onSizing",val,this.getHeight());Zapatec.GlobalEvents.fireEvent("onSizing",val,this.getHeight(),this);}else{this.fireEvent("onSizing",this.getWidth(),val);Zapatec.GlobalEvents.fireEvent("onSizing",this.getWidth(),val,this);}}this.fireEvent("on"+evDim+"Change",val);Zapatec.GlobalEvents.fireEvent("on"+evDim+"Change",val,this);}return true;};Zapatec.Sizable.startSizing=function(){if(!this.isSizableSafely()){Zapatec.Log({description:"The object with ID '"+this.id+"' was not prepared for sizing! Use obj.makeSizable() to do so!",type:"warning"});return false;}this.fireEvent("sizingStart");Zapatec.GlobalEvents.fireEvent("sizingStart",this);this._setSizingState(true);return true;};Zapatec.Sizable.endSizing=function(){if(!this.isSizing()){Zapatec.Log({description:"The sizing for object with ID '"+this.id+"' was not started!",type:"warning"});return false;}this.fireEvent("sizingEnd");Zapatec.GlobalEvents.fireEvent("sizingEnd",this);this._setSizingState(false);return true;};Zapatec.Sizable.isSizing=function(){return this.sizingState;};Zapatec.Sizable._setSizingState=function(on){this.sizingState=on;};Zapatec.Sizable.getWidth=function(){var el=this.getSizableMeasurement("width");if(Zapatec.isHtmlElement(el)||typeof el=="number"){return Zapatec.Utils.getWidth(el)||el;}Zapatec.Log({description:"Can't calculate width for object with ID '"+this.id+"'!",type:"warning"});return false;};Zapatec.Sizable.getHeight=function(){var el=this.getSizableMeasurement("height");if(Zapatec.isHtmlElement(el)||typeof el=="number"){return Zapatec.Utils.getHeight(el)||el;}Zapatec.Log({description:"Can't calculate height for object with ID '"+this.id+"'!",type:"warning"});return false;};Zapatec.Sizable.isSizableSafely=function(dimension){return this.safelySizable;};Zapatec.Sizable.makeSizable=function(){if(!this.hasInterface("Zapatec.CommandEvent")){Zapatec.Log({description:"The object with ID '"+this.id+"' has no Zapatec.CommandEvent interface!"});return false;}if(this.isSizableSafely()){return true;}var elements=Zapatec.Array(this.getSizableElements()),success=true,self=this;elements.each(function(index,sizable){sizable=Zapatec.Array(sizable);sizable.each(function(index,sizable){if(Zapatec.isHtmlElement(sizable)){if(!Zapatec.Utils.makeSafelySizable(sizable)){success=false;return"break";}self.createProperty(sizable,"sizingObj",self);}else if(Zapatec.isSizableObj(sizable)){if(!sizable.makeSizable()){success=false;return"break";}}});});if(!success){this.restoreOfSizing();Zapatec.Log({description:"Can not make the object with ID '"+this.id+"' sizable!"});return false;}this._setSizableSafely(true);return true;};Zapatec.Sizable.restoreOfSizing=function(){if(!this.isSizableSafely()){return true;}var elements=Zapatec.Array(this.getSizableElements());elements.each(function(index,sizable){sizable=Zapatec.Array(sizable);sizable.each(function(index,sizable){if(Zapatec.isHtmlElement(sizable)){Zapatec.Utils.restoreOfSizing(sizable);sizable.sizingObj=null;}else if(Zapatec.isSizableObj(sizable)){sizable.restoreOfSizing();}});});this._setSizableSafely(false);return true;};Zapatec.Sizable.replaceWithSizable=function(element,withEl){if(!Zapatec.isHtmlElement(element)||!Zapatec.isHtmlElement(withEl)){return false;}var width=Zapatec.Utils.getWidth(element);var height=Zapatec.Utils.getHeight(element);element.parentNode.insertBefore(withEl,element.nextSibling);element.parentNode.removeChild(element);if(!Zapatec.Utils.makeSafelySizable(withEl)){return false;}if(Zapatec.Utils.setWidth(withEl,width)&&Zapatec.Utils.setHeight(withEl,height)){return true;}return false;};Zapatec.Sizable._setSizableSafely=function(on){this.safelySizable=on;};Zapatec.Sizable._parseSize=function(size,dimension){switch(true){case(size=="auto"):{size=this._parseAutoSize(dimension);break;}case((/^\d+px$/).test(String(size))):{size=parseInt(size,10);break;}case((/^\d+%$/).test(String(size))):{size=this._parsePercentSize(size,dimension);break;}case(typeof size=="number"):{break;}}return this._canSetSize(size,dimension);};Zapatec.Sizable._parseAutoSize=function(dimension){var measurement=this.getSizableMeasurement(dimension);var autoSizable=this._getAutoSizableElement(dimension);if(!Zapatec.isHtmlElement(autoSizable)){return null;}var dim=dimension.charAt(0).toUpperCase()+dimension.slice(1).toLowerCase();var diff=0;if(Zapatec.isHtmlElement(measurement)||typeof measurement=="number"){diff=(Zapatec.Utils["get"+dim](measurement)||measurement)-Zapatec.Utils["get"+dim](autoSizable);}var el=autoSizable;if(el.tagName.toLowerCase()=="iframe"){try{if(el.contentDocument!=null){el=el.contentDocument.body;}else if(el.contentWindow.document!=null){el=el.contentWindow.document.body;}if(!Zapatec.isHtmlElement(el)){throw"No element to calculate auto size!";}}catch(e){Zapatec.Log({description:"Can't calculate auto size for the IFRAME in the object with ID '"+this.id+"'!",type:"warning"});return null;}}return el["scroll"+dim]+diff;};Zapatec.Sizable._parsePercentSize=function(value,dimension){var sizableParent=this._getSizableParent(dimension);if(!Zapatec.isHtmlElement(sizableParent)){return null;}var dim=dimension.charAt(0).toUpperCase()+dimension.slice(1).toLowerCase();value=parseInt(value,10);return Math.round((value/100)*Zapatec.Utils["get"+dim](sizableParent));};Zapatec.Sizable._canSetSize=function(value,dimension){if(typeof value!="number"){return false;}var dim=dimension.charAt(0).toUpperCase()+dimension.slice(1).toLowerCase();var sizingConfig=this.getSizingConfig();var limit=sizingConfig.limit;var direction=sizingConfig.direction;if(dim=="Width"&&direction=="vertical"){return this._handleSizeOverflow(this.getWidth());}if(dim=="Height"&&direction=="horizontal"){return this._handleSizeOverflow(this.getHeight());}if(typeof limit["min"+dim]=="number"&&value<limit["min"+dim]){return this._handleSizeOverflow(limit["min"+dim]);}if(typeof limit["max"+dim]=="number"&&value>limit["max"+dim]){return this._handleSizeOverflow(limit["max"+dim]);}return value;};Zapatec.Sizable._handleSizeOverflow=function(limit,dimension){return false;};Zapatec.Sizable.getSizingConfig=function(){return this.getConfiguration();};Zapatec.Sizable.setSizingConfig=function(config){this.reconfigure(config);};Zapatec.Sizable._getAutoSizableElement=function(dimension){return this.getContainer();};Zapatec.Sizable._getSizableParent=function(dimension){return this.getContainer().parentNode;};Zapatec.Sizable.getSizableMeasurement=fun

⌨️ 快捷键说明

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