| 1 |
- MWF.xDesktop.requireApp("process.Xform","$Module",null,false);MWF.xApplication.process.Xform.Htmleditor=MWF.APPHtmleditor=new Class({Extends:MWF.APP$Module,options:{moduleEvents:["load","postLoad","afterLoad"]},initialize:function(t,e,i,o){this.node=$(t);this.node.store("module",this);this.json=e;this.form=i;this.field=true},load:function(){if(this.fireEvent("queryLoad")){this._queryLoaded();this._loadUserInterface();this._loadStyles();this._afterLoaded();this.fireEvent("postLoad");this.fireEvent("load")}},_loadUserInterface:function(){this.node.empty();if(this.readonly){this.node.set("html",this._getBusinessData());this.node.setStyles({"-webkit-user-select":"text","-moz-user-select":"text"})}else{var t=Object.clone(this.json.editorProperties);if(this.json.config){if(this.json.config.code){var e=MWF.Macro.exec(this.json.config.code,this);Object.each(e,function(e,i){t[i]=e})}}this.loadCkeditor(t)}},loadCkeditor:function(t){COMMON.AjaxModule.loadDom("ckeditor",function(){var e=new Element("div").inject(this.node);var i=this._getBusinessData();if(i){e.set("html",i)}else if(this.json.templateCode){e.set("html",this.json.templateCode)}var o=this.node.getSize().y;var n=t||{};if(this.form.json.mode=="Mobile"){if(!n.toolbar&&!n.toolbarGroups){n.toolbar=[{name:"paragraph",items:["Bold","Italic","-","TextColor","BGColor","JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock","-","Undo","Redo"]},{name:"basicstyles",items:["Styles","FontSize"]}]}}this.editor=CKEDITOR.replace(e,n);this._loadEvents();debugger;this.editor.on("change",function(){this._setBusinessData(this.getData())}.bind(this))}.bind(this))},_loadEvents:function(t){Object.each(this.json.events,function(t,e){if(t.code){this.editor.on(e,function(e){return this.form.Macro.fire(t.code,this,e)}.bind(this),this)}}.bind(this))},_loadValue:function(){var t=this._getBusinessData()},resetData:function(){this.setData(this._getBusinessData())},getData:function(){return this.editor.getData()},setData:function(t){this._setBusinessData(t);if(this.editor)this.editor.setData(t)},createErrorNode:function(t){var e=new Element("div");var i=new Element("div",{styles:{width:"20px",height:"20px",float:"left",background:"url("+"/x_component_process_Xform/$Form/default/icon/error.png) center center no-repeat"}}).inject(e);var o=new Element("div",{styles:{"line-height":"20px","margin-left":"20px",color:"red"},text:t}).inject(e);return e},notValidationMode:function(t){if(!this.isNotValidationMode){this.isNotValidationMode=true;this.node.store("borderStyle",this.node.getStyles("border-left","border-right","border-top","border-bottom"));this.node.setStyle("border","1px solid red");this.errNode=this.createErrorNode(t).inject(this.node,"after");this.showNotValidationMode(this.node)}},showNotValidationMode:function(t){var e=t.getParent("div");if(e){if(e.get("MWFtype")=="tab$Content"){if(e.getParent("div").getStyle("display")=="none"){var i=e.getParent("div").getParent("div");var o=i.getPrevious("div");var n=i.getChildren().indexOf(e.getParent("div"));var s=o.getChildren()[n];s.click();e=o.getParent("div")}}this.showNotValidationMode(e)}},validationMode:function(){if(this.isNotValidationMode){this.isNotValidationMode=false;this.node.setStyles(this.node.retrieve("borderStyle"));if(this.errNode){this.errNode.destroy();this.errNode=null}}},validationConfigItem:function(t,e){var i=e.status=="all"?true:t==e.decision;if(i){var o=this.getData();var n=e.valueType=="value"?o:o.length;switch(e.operateor){case"isnull":if(!n){this.notValidationMode(e.prompt);return false}break;case"notnull":if(n){this.notValidationMode(e.prompt);return false}break;case"gt":if(n>e.value){this.notValidationMode(e.prompt);return false}break;case"lt":if(n<e.value){this.notValidationMode(e.prompt);return false}break;case"equal":if(n==e.value){this.notValidationMode(e.prompt);return false}break;case"neq":if(n!=e.value){this.notValidationMode(e.prompt);return false}break;case"contain":if(n.indexOf(e.value)!=-1){this.notValidationMode(e.prompt);return false}break;case"notcontain":if(n.indexOf(e.value)==-1){this.notValidationMode(e.prompt);return false}break}}return true},validationConfig:function(t,e){debugger;if(this.json.validationConfig){if(this.json.validationConfig.length){for(var i=0;i<this.json.validationConfig.length;i++){var o=this.json.validationConfig[i];if(!this.validationConfigItem(t,o))return false}}return true}return true},validation:function(t,e){if(!this.validationConfig(t,e))return false;if(!this.json.validation)return true;if(!this.json.validation.code)return true;var i=this.form.Macro.exec(this.json.validation.code,this);if(!i)i=MWF.xApplication.process.Xform.LP.notValidation;if(i.toString()!="true"){this.notValidationMode(i);return false}return true}});
|