WritingBoard.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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.WritingBoard = MWF.FCWritingBoard = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/WritingBoard/writingBoard.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/WritingBoard/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/WritingBoard/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "writingBoard";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createNode: function(){
  22. this.node = this.moveNode.clone(true, true);
  23. this.node.setStyles(this.css.moduleNode);
  24. this.node.set("id", this.json.id);
  25. this.node.addEvent("selectstart", function(){
  26. return false;
  27. })
  28. },
  29. _createMoveNode: function(){
  30. this.moveNode = new Element("div", {
  31. "MWFType": "writingBoard",
  32. "id": this.json.id,
  33. "styles": this.css.moduleNodeMove,
  34. "events": {
  35. "selectstart": function(){
  36. return false;
  37. }
  38. }
  39. }).inject(this.form.container);
  40. var actionNode = new Element("div", {
  41. "styles": this.css.actionNode,
  42. "text": this.json.name || MWF.xApplication.process.FormDesigner.LP.handWriting
  43. }).inject(this.moveNode);
  44. var imageAreaNode = new Element("div", {
  45. "styles": this.css.imageNode
  46. }).inject(this.moveNode)
  47. },
  48. setAllStyles: function(){
  49. this.setPropertiesOrStyles("styles");
  50. this.setPropertiesOrStyles("actionStyles");
  51. this.setPropertiesOrStyles("imageStyles");
  52. this.setPropertiesOrStyles("properties");
  53. this.reloadMaplist();
  54. },
  55. _initModule: function(){
  56. if (!this.json.isSaved) this.setStyleTemplate();
  57. this._resetModuleDomNode();
  58. this.setPropertiesOrStyles("styles");
  59. this.setPropertiesOrStyles("actionStyles");
  60. this.setPropertiesOrStyles("imageStyles");
  61. this.setPropertiesOrStyles("properties");
  62. this._setNodeProperty();
  63. if (!this.form.isSubform) this._createIconAction();
  64. this._setNodeEvent();
  65. this.json.isSaved = true;
  66. },
  67. clearTemplateStyles: function(styles){
  68. if (styles){
  69. if (styles.styles) this.removeStyles(styles.styles, "styles");
  70. if (styles.actionStyles) this.removeStyles(styles.actionStyles, "actionStyles");
  71. if (styles.imageStyles) this.removeStyles(styles.imageStyles, "imageStyles");
  72. if (styles.properties) this.removeStyles(styles.properties, "properties");
  73. }
  74. },
  75. setTemplateStyles: function(styles){
  76. if (styles.styles) this.copyStyles(styles.styles, "styles");
  77. if (styles.actionStyles) this.copyStyles(styles.actionStyles, "actionStyles");
  78. if (styles.imageStyles) this.copyStyles(styles.imageStyles, "imageStyles");
  79. if (styles.properties) this.copyStyles(styles.properties, "properties");
  80. },
  81. setPropertiesOrStyles: function(name){
  82. if (name=="styles")this.setCustomStyles();
  83. if (name=="actionStyles"){
  84. this._recoveryModuleData();
  85. var actionNode = this.node.getFirst();
  86. if(actionNode){
  87. actionNode.clearStyles();
  88. this.parseStyles(actionNode, this.json.actionStyles, true);
  89. }
  90. }
  91. if (name=="imageStyles"){
  92. this._recoveryModuleData();
  93. var imageNode = this.node.getLast();
  94. if(imageNode){
  95. imageNode.clearStyles();
  96. this.parseStyles(imageNode, this.json.imageStyles, true);
  97. }
  98. }
  99. if (name=="properties"){
  100. try{
  101. this.setCustomProperties();
  102. }catch(e){}
  103. this.node.setProperties(this.json.properties);
  104. }
  105. },
  106. _setEditStyle_custom: function(name, obj, oldValue){
  107. if( ["styles","actionStyles","imageStyles","properties"].contains(name) ){
  108. this.setPropertiesOrStyles(name)
  109. }
  110. },
  111. setCustomStyles: function(){
  112. var border = this.node.getStyle("border");
  113. this._recoveryModuleData();
  114. this.node.clearStyles();
  115. this.node.setStyles(this.css.moduleNode);
  116. if (this.initialStyles) this.node.setStyles(this.initialStyles);
  117. this.node.setStyle("border", border);
  118. this.parseStyles(this.node, this.json.styles);
  119. },
  120. parseStyles: function (node, style, ignoreBorder) {
  121. if (style) Object.each(style, function(value, key){
  122. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  123. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  124. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  125. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  126. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  127. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  128. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  129. }
  130. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  131. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  132. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  133. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  134. }
  135. value = o2.filterUrl(value);
  136. }
  137. var reg = /^border\w*/ig;
  138. if (ignoreBorder || !key.test(reg)){
  139. if (key){
  140. if (key.toString().toLowerCase()==="display"){
  141. if (value.toString().toLowerCase()==="none"){
  142. node.setStyle("opacity", 0.3);
  143. }else{
  144. node.setStyle("opacity", 1);
  145. node.setStyle(key, value);
  146. }
  147. }else{
  148. node.setStyle(key, value);
  149. }
  150. }
  151. }
  152. }.bind(this));
  153. }
  154. });