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

📄 paneset.js

📁 zapatec suite 最新版 20070204,非常棒的ajax widgets 工具包
💻 JS
📖 第 1 页 / 共 5 页
字号:
this.indicator.innerHTML=message;this.show();};Zapatec.Indicator.prototype.stop=function(){this.active=false;this.hide(true);};Zapatec.Indicator.prototype.isActive=function(){return this.active;};Zapatec.Pane=function(objArgs){this.config={};if(arguments.length==0){objArgs={};}this.widgetType="pane";this.ready=false;this.loading=false;this.prepared=false;Zapatec.Utils.createProperty(this,"container",null);Zapatec.Utils.createProperty(this,"contentElement",null);Zapatec.Utils.createProperty(this,"iframeDocument",null);Zapatec.Pane.SUPERconstructor.call(this,objArgs);}Zapatec.Pane.id="Zapatec.Pane";Zapatec.inherit(Zapatec.Pane,Zapatec.Widget);Zapatec.Pane.prototype.init=function(objArgs){Zapatec.Utils.createProperty(this.config,"parent",document.body);this.config.theme=null;this.config.width=null;this.config.height=null;this.config.containerType="div";this.config.sourceType=null;this.config.source=null;this.config.autoContentWidth=false;this.config.autoContentHeight=false;this.config.onlyInit=false;this.config.showLoadingIndicator=false;this.config.overflow="auto";this.config.id=null;Zapatec.Pane.SUPERclass.init.call(this,objArgs);if(this.config.containerType==null){this.config.containerType="div";}if(!this.config.onlyInit){this.create(this.config.width,this.config.height);}var self=this;function update(){if(self.loader){self.loader.update();}}this.addEventListener("fetchSourceStart",update);this.addEventListener("fetchSourceEnd",update);}Zapatec.Pane.prototype.prepareHtml=function(){if(this.config.containerType.toLowerCase()=='iframe'){var iframe=document.createElement("iframe");iframe.src=Zapatec.zapatecPath+"pane_files/blank.html#"+this.id;this.container=iframe;iframe=null;}else if(this.config.containerType.toLowerCase()=='div'){this.container=document.createElement("div");if(this.config.id){this.container.id=this.config.id;}this.contentElement=this.container;}else if(this.config.parent&&this.config.parent.nodeType==1){this.container=this.config.parent;this.contentElement=this.container;}this.prepared=true;};Zapatec.Pane.prototype.create=function(width,height){if(!this.prepared){this.prepareHtml();}if(!(this.config.parent=Zapatec.Widget.getElementById(this.config.parent))){Zapatec.Log({description:"No reference to parent element."});return null;}if(this.config.parent.requestParentFor&&!(this.config.parent=this.config.parent.requestParentFor(this))){Zapatec.Log({description:"No reference to parent element after request to the Parent Widget!"});return null;}if(this.config.containerType.toLowerCase()=='div'||this.config.containerType.toLowerCase()=='iframe'){this.ready=false;this.config.parent.appendChild(this.container);if(this.config.containerType.toLowerCase()!='iframe'){this.initPane();}}else if(this.config.containerType.toLowerCase()=='current'){this.container=this.config.parent;this.contentElement=this.container;this.initPane();}else{Zapatec.Log({description:"Unknown container type: "+this.config.containerType+". Possible values: iframe|div"})}Zapatec.Utils.addClass(this.container,this.getClassName({prefix:"zpPane"}));if(width||this.config.width){this.setWidth(width||this.config.width);}if(height||this.config.height){this.setHeight(height||this.config.height);}this.getContainer().style.display="block";this.setPaneContent();};Zapatec.Pane.prototype.initPane=function(){if(this.config.containerType.toLowerCase()=='iframe'){var doc=null;var sameDomain=true;var url=this.getContainer().src;var anchorEl=document.createElement("a");var protocolSeparatorPos=url.indexOf("://");if(protocolSeparatorPos!=-1){var domainSeparatorPos=url.indexOf("/",protocolSeparatorPos+3);var domain=url.substring((protocolSeparatorPos>0?protocolSeparatorPos+3:0),(domainSeparatorPos>0?domainSeparatorPos:url.length));if(domain!=window.location.host){sameDomain=false;}}if(sameDomain){if(this.container.contentDocument!=null){doc=this.container.contentDocument;}else if(this.container.contentWindow&&this.container.contentWindow.document!=null){doc=this.container.contentWindow.document;}var self=this;anchorEl.href=url;url=anchorEl.href;if(doc==null||doc.body==null||(Zapatec.is_gecko&&url!=this.container.contentWindow.location.href)){setTimeout(function(){self.initPane()},50);return false;}this.iframeDocument=doc;this.contentElement=doc.body;if(typeof this.container.contentWindow.Zapatec!="object"&&typeof this.container.contentWindow.Zapatec!="function"){this.container.contentWindow.Zapatec={};this.container.contentWindow.Zapatec.windowLoaded=typeof(doc.readyState)!='undefined'?(doc.readyState=='loaded'||doc.readyState=='complete'):doc.getElementsByTagName!=null&&typeof(doc.getElementsByTagName('body')[0])!='undefined';Zapatec.Utils.addEvent(this.container.contentWindow,"load",function(){self.container.contentWindow.Zapatec.windowLoaded=true;});}if(!this.container.contentWindow.Zapatec||!this.container.contentWindow.Zapatec.windowLoaded){setTimeout(function(){self.initPane()},50);return false;}doc=null;}}if(this.config.overflow){this.getContainer().style.overflow=this.config.overflow;}this.ready=true;this.fireEvent("onReady",this);this.hideIndicator();this.loading=false;this.removeEvent("onReady");}Zapatec.Pane.prototype.getContainer=function(){return this.container;}Zapatec.Pane.prototype.getIframeDocument=function(){return this.iframeDocument;}Zapatec.Pane.prototype.getContentElement=function(){return this.contentElement;}Zapatec.Pane.prototype.isReady=function(){return this.ready;}Zapatec.Pane.prototype.loadDataJson=function(objSource){return objSource!=null?this.setContent(objSource.content):null;}Zapatec.Pane.prototype.setContent=function(content){if(!this.isReady()){var self=this;setTimeout(function(){self.setContent(content)},50);return null;}this.loading=false;if(!this.getContentElement()){this.hideIndicator();return false;}if(content===null){this.hideIndicator();return null;}else{if(this.config.containerType.toLowerCase()!="iframe"){var oldOverflow=this.getContainer().style.overflow;if(this.config.autoContentWidth){this.getContainer().style.overflow="visible";this.getContainer().style.width="auto";}if(this.config.autoContentHeight){this.getContainer().style.overflow="visible";this.getContainer().style.height="auto";}}if(typeof(content)=='string'){Zapatec.Transport.setInnerHtml({container:this.getContentElement(),html:content});}else{try{if((Zapatec.is_ie||Zapatec.is_opera)&&this.config.containerType.toLowerCase()=="iframe"){Zapatec.Transport.setInnerHtml({container:this.getContentElement(),html:content.outerHTML});}else{if(content.parentNode!=this.getContentElement()){this.getContentElement().innerHTML="";this.getContentElement().appendChild(content);}}}catch(ex){this.hideIndicator();return null;}}if(this.config.containerType.toLowerCase()!="iframe"){var newWidth=this.getWidth();var newHeight=this.getHeight();}else{var newWidth=this.getContentElement().scrollWidth+5;var newHeight=this.getContentElement().scrollHeight+5;}if(typeof oldOverflow!="undefined")this.getContainer().style.overflow=oldOverflow;if(this.config.autoContentWidth){this.setWidth(newWidth);}if(this.config.autoContentHeight){this.setHeight(newHeight);}}this.fireEvent("contentLoaded",this);this.hideIndicator();return true;}Zapatec.Pane.prototype.loadDataHtml=Zapatec.Pane.prototype.loadDataXml=Zapatec.Pane.prototype.setContent;Zapatec.Pane.prototype.loadDataHtmlText=function(content){this.setContent(content);};Zapatec.Pane.prototype.setWidth=function(width){var self=this;this.fireWhenReady(function(){self.getContainer().style.width=width+"px";if(self.getContainer().offsetWidth!=width){var newWidth=width-(self.getContainer().offsetWidth-width);if(newWidth<0)newWidth=0;self.getContainer().style.width=newWidth+"px";}});}Zapatec.Pane.prototype.getWidth=function(){return this.getContainer().offsetWidth;}Zapatec.Pane.prototype.setHeight=function(height){var self=this;this.fireWhenReady(function(){self.getContainer().style.height=height+"px";if(self.getContainer().offsetHeight!=height){var newHeight=height-(self.getContainer().offsetHeight-height);if(newHeight<0)newHeight=0;self.getContainer().style.height=newHeight+"px";}});}Zapatec.Pane.prototype.getHeight=function(){return this.getContainer().offsetHeight;}Zapatec.Pane.prototype.removeBorder=function(){if(this.config.containerType.toLowerCase()!="iframe"){return false;}var self=this;this.fireWhenReady(function(){if(!Zapatec.is_ie){self.getContainer().style.border="none";}else{if(self.getContentElement()){self.getContentElement().style.border="none";}}});};Zapatec.Pane.prototype.setPaneContent=function(content,type){if(!content&&content!==""){content=this.config.source;}if(!type){type=this.config.sourceType;}this.config.source=content;this.config.sourceType=type;var self=this;if(this.config.showLoadingIndicator){this.showIndicator();this.loading=true;}if(this.config.containerType.toLowerCase()=="iframe"&&type=="html/url"){this.ready=false;this.fireWhenReady(function(){if(self.getContentElement()){try{var newWidth=self.getContentElement().scrollWidth;var newHeight=self.getContentElement().scrollHeight;if(self.config.autoContentWidth){self.setWidth(newWidth);}if(self.config.autoContentHeight){self.setHeight(newHeight);}}catch(e){}}self.fireEvent("contentLoaded",self);if(self.events["contentLoaded"]){self.events["contentLoaded"].listeners=[];}});this.getContainer().src=content;setTimeout(function(){self.initPane()},50);return true;}if(this.config.containerType.toLowerCase()=="iframe"&&this.getContainer().src.indexOf((Zapatec.zapatecPath+"pane_files/blank.html#"+this.id).replace(/\.\.\//g,""))<0){this.ready=false;this.getContainer().src=Zapatec.zapatecPath+"pane_files/blank.html#"+this.id;}this.loadData();return true;};Zapatec.Pane.prototype.show=function(){this.getContainer().style.display="";if(this.loading){this.showIndicator();}};Zapatec.Pane.prototype.hide=function(){this.getContainer().style.display="none";if(this.loading){this.hideIndicator();}};Zapatec.Pane.prototype.showIndicator=function(message){if(Zapatec.Indicator){this.hideIndicator();if(!this.loader){this.loader=new Zapatec.Indicator({container:this.container,themePath:Zapatec.zapatecPath+"../zpextra/themes/indicator/"});}this.loader.start(message||'loading');}};Zapatec.Pane.prototype.hideIndicator=function(){if(this.loader&&this.loader.isActive()){this.loader.stop();}};Zapatec.Pane.prototype.fireWhenReady=function(func){if(!this.isReady()){this.addEventListener("onReady",func);}else{func.call(this,this);}}Zapatec.Pane.prototype.destroy=function(){this.hideIndicator();this.config.parent=null;this.contentElement=null;this.iframeDocument=null;if(Zapatec.is_ie&&this.config.containerType.toLowerCase()=='iframe'){this.container.src="javascript:void(0)";}if(this.container.outerHTML){this.container.outerHTML="";}else{Zapatec.Utils.destroy(this.container);}this.container=null;this.ready=false;this.prepared=false;}Zapatec.PaneSet=function(config){this.widgetType="paneset";this.widgetState="created";this.priorities={count:8,destroyed:0,created:1,inited:2,prepared:3,loaded:4,ready:5,hidden:6,shown:7};this.panes=[];this.dividers=[];this.systemEventsOn=false;this.state={};Zapatec.PaneSet.SUPERconstructor.call(this,config);};Zapatec.PaneSet.id="Zapatec.PaneSet";Zapatec.inherit(Zapatec.PaneSet,Zapatec.Widget);Zapatec.PaneSet.prototype.init=function(config){Zapatec.PaneSet.SUPERclass.init.call(this,config);this.loadData({object:this,action:"loadTemplate"});var self=this;Zapatec.PaneSet.loadPanesObject({from:this.config.panes,type:this.config.dataType,paneSet:this,onSuccess:function(data){self.config.panes=data;self.config.dataType="json";self.initChildPanes();},onFailure:function(){Zapatec.Log({description:"Can't load the data for PaneSet with ID - '"+this.id+"'!"});}});};Zapatec.PaneSet.prototype.configure=function(config){this.defineConfigOption("orientation","horizontal");this.defineConfigOption("panes",null);this.defineConfigOption("dataType","json");this.defineConfigOption("breadth",null);this.defineConfigOption("parent",null);this.defineConfigOption("id",null);this.defineConfigOption("reuseContainer",null);this.defineConfigOption("length",null);this.defineConfigOption("prefix","zpPaneSet");this.defineConfigOption("resizable",false);this.defineConfigOption("template",Zapatec.PaneSet.path+"h-divider.html");this.defineConfigOption("callbackSource",function(args){var paneSet=args.object;if(!paneSet||paneSet.widgetType!="paneset"){return null;}switch(args.action){case"loadTemplate":{return{source:paneSet.getConfiguration().template,sourceType:"html/url"};}}return null;});Zapatec.PaneSet.SUPERclass.configure.call(this,config);if(this.config.orientation!="horizontal"){this.config.template=Zapatec.PaneSet.path+"v-divider.html";}};Zapatec.PaneSet.prototype.reconfigure=function(config){Zapatec.PaneSet.SUPERclass.reconfigure.call(this,config);};Zapatec.PaneSet.prototype.initChildPanes=function(){if(!this.config.panes){Zapatec.Log({description:"No Pane objects passed!"});return null;}else if(this.config.panes.length<2){Zapatec.Log({description:"There must be at least two Panes! You should use Pane in such case."});return null;}var item,i,pWidth,pHeight;for(i=0;i<this.config.panes.length;++i){item=this.config.panes[i];if(item.panes){item.orientation=this.config.orientation=="vertical"?"horizontal":"vertical";item.parent=this;item.length=this.config.breadth;item.resizable=this.config.resizable;item.eventListeners=this.config.eventListeners;this.panes.push(new this.constructor(item));}else{if(item.containerType!="current"){item.el=null;}if(this.config.orientation=="vertical"){pWidth=this.config.breadth;pHeight=item.breadth;}else{pHeight=this.config.breadth;pWidth=item.breadth;}var 

⌨️ 快捷键说明

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