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

📄 zpeditor.js

📁 zapatec suite 最新版 20070204,非常棒的ajax widgets 工具包
💻 JS
📖 第 1 页 / 共 5 页
字号:
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.MinimalEditor=function(objArgs){if(arguments.length==0){objArgs={};}Zapatec.MinimalEditor.SUPERconstructor.call(this,objArgs);}Zapatec.MinimalEditor.id='Zapatec.MinimalEditor';Zapatec.inherit(Zapatec.MinimalEditor,Zapatec.Widget);Zapatec.MinimalEditor.prototype.init=function(objArgs){Zapatec.MinimalEditor.SUPERclass.init.call(this,objArgs);this.createEditor();this.initEditor();}Zapatec.MinimalEditor.prototype.createEditor=function(){this.createProperty(this,'container',null);this.createProperty(this,'editorPanel',null);this.createProperty(this,'buttons',[]);this.createProperty(this,'wch',null);this.createProperty(this,'undo',new Zapatec.MinimalEditor.Undo(this));if(Zapatec.is_webkit){this.fillWebKitMap();}var fieldWidth=this.config.field.clientWidth;var fieldHeight=this.config.field.clientHeight;this.container=Zapatec.Utils.createElement("div");this.container.id='zpEditor'+this.id+'Container';Zapatec.Utils.insertAfter(this.config.field,this.container);if(!Zapatec.is_opera){this.container.style.cssText=this.config.field.style.cssText;}else{for(var i in this.config.field.style){try{this.container.style[i]=this.config.field.style[i];}catch(e){}}}this.config.field.style.position="static";this.config.field.style.left="";this.config.field.style.top="";this.config.field.style.margin="0";this.editorPanel=document.createElement("div");this.editorPanel.id='zpEditor'+this.id+'EditorPanel';this.container.appendChild(this.editorPanel);this.editorPanel.className=this.getClassName({prefix:"zpEditor",suffix:"EditorPanel"});this.config.field.parentNode.removeChild(this.config.field);this.editorPanel.appendChild(this.config.field);this.config.field.className=this.getClassName({prefix:"zpEditor",suffix:"Textarea"});this.wch=Zapatec.Utils.createWCH(this.editorPanel);if(this.wch){this.wch.style.zIndex=-1;}this.addButtons();var paneSize=this.getPaneSize(fieldWidth,fieldHeight);this.pane=new Zapatec.Pane({containerType:'iframe',width:paneSize.width,height:paneSize.height,showLoadingIndicator:false})this.pane.removeBorder();this.pane.getContainer().className=this.getClassName({prefix:"zpEditor",suffix:"Pane"});this.setSize(fieldWidth,fieldHeight);this.pane.getContainer().parentNode.removeChild(this.pane.getContainer());Zapatec.Utils.insertAfter(this.config.field,this.pane.getContainer());this.config.field.style.display="none";this.mode="WYSIWYG";this.toggleButtons(false);}Zapatec.MinimalEditor.prototype.configure=function(objArgs){this.defineConfigOption('field');this.defineConfigOption('asyncTheme',true);this.defineConfigOption('maximizedBorder',6);this.defineConfigOption('toolbarElements',['fontName','fontSize','newPanel','bold','italic','underline','newPanel','foreColor','backColor','insertLink','insertImage','insertTable','insertHorizontalRule','newRow','justifyLeft','justifyCenter','justifyRight','newPanel','insertOrderedList','insertUnorderedList','newPanel','selectall','copy','cut','paste','newPanel','outdent','indent','newPanel','undo','redo','newPanel','switcher','newPanel','about']);this.defineConfigOption('langId',Zapatec.MinimalEditor.id);this.defineConfigOption('lang',"eng");this.defineConfigOption('persistKey',null);this.defineConfigOption('persistPath',null);this.defineConfigOption('externalBrowserWidth',450);this.defineConfigOption('externalBrowserHeight',350);this.defineConfigOption('enableTooltips',false);this.defineConfigOption('dumpHtml',false);this.defineConfigOption('generateXhtml',false);this.defineConfigOption('customUndo',true);this.defineConfigOption('maxUndoTypes',25);this.defineConfigOption('maxUndoLevels',100);this.defineConfigOption('foreColor',"");this.defineConfigOption('backColor',"");this.defineConfigOption('preserveImgSrc',Zapatec.is_ie);this.defineConfigOption('preserveAnchorHref',Zapatec.is_ie);this.defineConfigOption('excludeToolbar',false);Zapatec.MinimalEditor.SUPERclass.configure.call(this,objArgs);for(var ii=0;ii<this.config.toolbarElements.length;ii++){this.config.toolbarElements[ii]=this.config.toolbarElements[ii].toLowerCase();}if(typeof(this.config.field)=="undefined"){Zapatec.Log({description:this.getMessage('noTextareaError')});return false;}if(typeof(this.config.field)=="string"){this.config.field=document.getElementById(this.config.field);}if(this.config.field==null||this.config.field.nodeType!=1||this.config.field.nodeName.toLowerCase()!="textarea"){Zapatec.Log({description:this.getMessage('fieldIsNotTextareaError')})return false;}if(typeof Zapatec.Tooltip=='undefined'){this.config.enableTooltips=false;}};Zapatec.MinimalEditor.prototype.initEditor=function(){var self=this;if(!this.pane.isReady()){setTimeout(function(){self.initEditor()},50);return null;}self.setSize();if(Zapatec.is_ie){this.pane.getContentElement().onbeforedeactivate=function(){var sel=self.pane.getContainer().contentWindow.document.selection;if(sel){try{var range=sel.createRange();self.oldSelectionRange=range;}catch(e){}}}}Zapatec.Utils.addEvent(this.pane.getIframeDocument(),"keydown",function(e){if(!e){e=self.pane.getIframeDocument().event;}self.undo.onKeyDown();switch(e.keyCode){case 13:if(Zapatec.is_ie&&!(e.ctrlKey||e.altKey||e.shiftKey)){var isHandled=self.onEnterPressed();if(isHandled){e.cancelBubble=true;e.returnValue=false;return false;}};break;}});Zapatec.Utils.addEvent(this.pane.getIframeDocument(),"keyup",function(){self.saveContentToField();self.invokeUpdateToolbar();});Zapatec.Utils.addEvent(this.pane.getIframeDocument(),"click",function(){self.invokeUpdateToolbar();});Zapatec.Utils.addEvent(this.pane.getIframeDocument(),"contextmenu",function(){self.invokeUpdateToolbar();});this.toggleDesignMode(true);this.loadContentFromField();this.undo.saveUndo();this.toggleButtons(true);this.fireEvent("onInit");}Zapatec.MinimalEditor.prototype.setSize=function(width,height){if(!width&&!height){width=parseInt(this.container.style.width);height=parseInt(this.container.style.height);}this.container.style.width=width+'px';this.container.style.height=height+'px';if(!this.config.excludeToolbar){this.toolbar.style.width=width+'px';}var paneSize=this.getPaneSize(width,height);var paneWidth=paneSize.width;var paneHeight=paneSize.height;var iframeWidth=paneWidth;var iframeHeight=paneHeight;if(!Zapatec.is_ie&&!Zapatec.is_khtml){iframeHeight-=4;if(!this.isMaximize){iframeWidth-=4;}}if(Zapatec.is_ie7){iframeWidth-=1;iframeHeight-=3;}this.pane.getContainer().style.width=iframeWidth+'px';this.pane.getContainer().style.height=iframeHeight+'px';var editorPanelHeight=paneHeight;var editorPanelWidth=width-2;if(!Zapatec.is_ie&&!Zapatec.is_khtml){editorPanelHeight-=4;}if(Zapatec.is_ie7){editorPanelHeight-=1;}this.editorPanel.style.width=editorPanelWidth+'px';this.editorPanel.style.height=editorPanelHeight+'px';Zapatec.Utils.setupWCH(this.wch,0,0,width,paneHeight);if(Zapatec.is_ie){paneWidth-=2;paneHeight-=2;if(Zapatec.is_ie7){paneWidth-=5;paneHeight-=6;}}else{if(!Zapatec.is_khtml){if(this.isMaximize){paneHeight-=5;}else{paneHeight-=5;paneWidth-=4;}}}

⌨️ 快捷键说明

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