Documenteditor.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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=="documentTempleteType"){
  44. if (this.json.documentTempleteType!=oldValue){
  45. this._resetContent();
  46. }
  47. }
  48. if (name=="documentTempleteUrl"){
  49. if (this.json.documentTempleteUrl!=oldValue){
  50. this._resetContent();
  51. }
  52. }
  53. if (name=="documentTempleteName"){
  54. if (this.json.documentTempleteName!=oldValue){
  55. this._resetContent();
  56. }
  57. }
  58. },
  59. // _setEditStyle_custom: function(name){
  60. // },
  61. _resetContent: function(){
  62. if (!this.json.documentTempleteType) this.json.documentTempleteType = "sys";
  63. if (!this.json.documentTempleteName) this.json.documentTempleteName = "standard";
  64. this.node.empty();
  65. var pageNode = new Element("div.doc_layout_page", {"styles": this.css.doc_page}).inject(this.node);
  66. var pageContentNode = new Element("div.doc_layout_page_content", {"styles": this.css.doc_layout_page_content}).inject(pageNode);
  67. if (this.json.documentTempleteType=="cus" && this.json.documentTempleteUrl){
  68. pageContentNode.loadHtml(o2.filterUrl(this.json.documentTempleteUrl), function(){
  69. // if (this.attachmentTemplete){
  70. // var attNode = pageContentNode.getElement(".doc_layout_attachment_content");
  71. // if (attNode) attNode.empty();
  72. // }
  73. // if (callback) callback(control);
  74. }.bind(this));
  75. }else{
  76. o2.getJSON(o2.filterUrl("../x_component_process_FormDesigner/Module/Documenteditor/templete/templete.json"), function(json){
  77. var o = json[this.json.documentTempleteName];
  78. if (o){
  79. pageContentNode.loadHtml(o2.filterUrl("../x_component_process_FormDesigner/Module/Documenteditor/templete/"+o.file), function(){
  80. // if (this.attachmentTemplete){
  81. // var attNode = pageContentNode.getElement(".doc_layout_attachment_content");
  82. // if (attNode) attNode.empty();
  83. // }
  84. // if (callback) callback(control);
  85. }.bind(this));
  86. }
  87. }.bind(this));
  88. }
  89. },
  90. _initModule: function(){
  91. this._resetContent();
  92. var templateJson = this.form.dataTemplate["Documenteditor"];
  93. if (!templateJson){
  94. var templateUrl = o2.filterUrl("../x_component_process_FormDesigner/Module/Documenteditor/template.json");
  95. templateJson = MWF.getJSON(templateUrl, null, false);
  96. }
  97. if (templateJson) this.json.defaultValue = Object.merge(templateJson.defaultValue, this.json.defaultValue);
  98. this._setNodeProperty();
  99. if (!this.form.isSubform) this._createIconAction() ;
  100. this._setNodeEvent();
  101. }
  102. });