Documenteditor.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Element", null, false);
  3. MWF.xApplication.process.FormDesigner.Module.Documenteditor = MWF.FCDocumenteditor = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "/x_component_process_FormDesigner/Module/Documenteditor/documenteditor.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "/x_component_process_FormDesigner/Module/Documenteditor/";
  13. this.cssPath = "/x_component_process_FormDesigner/Module/Documenteditor/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "documenteditor";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. this.moveNode = new Element("div", {
  23. "MWFType": "documenteditor",
  24. "id": this.json.id,
  25. "styles": this.css.moduleNodeMove,
  26. "events": {
  27. "selectstart": function(){
  28. return false;
  29. }
  30. }
  31. }).inject(this.form.container);
  32. },
  33. _createNode: function(){
  34. this.node = this.moveNode.clone(true, true);
  35. this.node.setStyles(this.css.moduleNode);
  36. this.node.set("id", this.json.id);
  37. this.node.addEvent("selectstart", function(e){
  38. e.preventDefault();
  39. });
  40. },
  41. _setEditStyle_custom: function(name, obj, oldValue){
  42. debugger;
  43. if (name=="documentTempleteName"){
  44. if (this.json.documentTempleteName!=oldValue){
  45. this._resetContent();
  46. }
  47. }
  48. },
  49. // _setEditStyle_custom: function(name){
  50. // },
  51. _resetContent: function(){
  52. if (!this.json.documentTempleteType) this.json.documentTempleteType = "sys";
  53. if (!this.json.documentTempleteName) this.json.documentTempleteName = "standard";
  54. this.node.empty();
  55. var pageNode = new Element("div.doc_layout_page", {"styles": this.css.doc_page}).inject(this.node);
  56. var pageContentNode = new Element("div.doc_layout_page_content", {"styles": this.css.doc_layout_page_content}).inject(pageNode);
  57. o2.getJSON("/x_component_process_FormDesigner/Module/Documenteditor/templete/templete.json", function(json){
  58. var o = json[this.json.documentTempleteName];
  59. if (o){
  60. pageContentNode.loadHtml("/x_component_process_FormDesigner/Module/Documenteditor/templete/"+o.file, function(){
  61. // if (this.attachmentTemplete){
  62. // var attNode = pageContentNode.getElement(".doc_layout_attachment_content");
  63. // if (attNode) attNode.empty();
  64. // }
  65. // if (callback) callback(control);
  66. }.bind(this));
  67. }
  68. }.bind(this));
  69. },
  70. _initModule: function(){
  71. this._resetContent();
  72. debugger;
  73. var templateJson = this.form.dataTemplate["Documenteditor"];
  74. if (!templateJson){
  75. var templateUrl = "/x_component_process_FormDesigner/Module/Documenteditor/template.json";
  76. templateJson = MWF.getJSON(templateUrl, null, false);
  77. }
  78. if (templateJson) this.json.defaultValue = Object.merge(templateJson.defaultValue, this.json.defaultValue);
  79. this._setNodeProperty();
  80. if (!this.form.isSubform) this._createIconAction() ;
  81. this._setNodeEvent();
  82. }
  83. });