Htmleditor.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. MWF.xApplication.cms.FormDesigner.Module = MWF.xApplication.cms.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.Htmleditor", null, false);
  3. MWF.xApplication.cms.FormDesigner.Module.Htmleditor = MWF.CMSFCHtmleditor = new Class({
  4. Extends: MWF.FCHtmleditor,
  5. Implements : [MWF.CMSFCMI],
  6. _initModule: function(){
  7. this.node.empty();
  8. var config = Object.clone(this.json.editorProperties);
  9. if (this.json.config){
  10. if (this.json.config.code){
  11. MWF.require("MWF.xScript.CMSMacro", null, false);
  12. var obj = MWF.CMSMacro.exec(this.json.config.code, this);
  13. Object.each(obj, function(v, k){
  14. config[k] = v;
  15. });
  16. }
  17. }
  18. this.loadCkeditor(config);
  19. this._setNodeProperty();
  20. if (!this.form.isSubform) this._createIconAction() ;
  21. this._setNodeEvent();
  22. },
  23. loadCkeditor: function(config){
  24. COMMON.AjaxModule.load("ckeditor", function(){
  25. CKEDITOR.disableAutoInline = true;
  26. var editorDiv = new Element("div").inject(this.node);
  27. if (this.json.templateCode) editorDiv.set("html", this.json.templateCode);
  28. var height = this.node.getSize().y;
  29. var editorConfig = config || {};
  30. if (this.form.options.mode=="Mobile"){
  31. // if (!editorConfig.toolbar && !editorConfig.toolbarGroups){
  32. editorConfig.toolbar = [
  33. //{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
  34. //{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] },
  35. //{ name: 'links' },
  36. //{ name: 'insert' },
  37. //{ name: 'forms' },
  38. //{ name: 'tools' },
  39. //{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
  40. //{ name: 'others' },
  41. //'/',
  42. { name: 'paragraph', items: [ 'Bold', 'Italic', "-" , 'TextColor', "BGColor", 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', "-", 'Undo', 'Redo' ] },
  43. { name: 'basicstyles', items: [ 'Styles', 'FontSize']}
  44. //{ name: 'colors' },
  45. //{ name: 'about' }
  46. ];
  47. // }
  48. }
  49. // CKEDITOR.basePath = COMMON.contentPath+"/res/framework/htmleditor/ckeditor/";
  50. if( editorConfig.skin )editorConfig.skin = "moono-lisa";
  51. this.editor = CKEDITOR.replace(editorDiv, editorConfig);
  52. this.editor.on("dataReady", function(){
  53. this.editor.setReadOnly(true);
  54. }, this);
  55. }.bind(this));
  56. }
  57. });