Commend.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. MWF.xApplication.cms.FormDesigner.Module = MWF.xApplication.cms.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Element", null, false);
  3. MWF.xApplication.cms.FormDesigner.Module.Commend = MWF.CMSFCCommend = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_cms_FormDesigner/Module/Commend/commend.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_cms_FormDesigner/Module/Commend/";
  13. this.cssPath = "../x_component_cms_FormDesigner/Module/Commend/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "commend";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. this.moveNode = new Element("div", {
  23. "MWFType": "commend",
  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. var button = new Element("button", {
  33. "styles": this.css.buttonIcon,
  34. "text": ""
  35. }).inject(this.moveNode);
  36. },
  37. _loadNodeStyles: function(){
  38. var button = this.node.getFirst("button");
  39. if (!button) button = this.node.getFirst("input");
  40. if (button)button.setStyles(this.css.buttonIcon);
  41. },
  42. unSelected: function(){
  43. this.node.setStyles({
  44. "border-top": "1px solid #999",
  45. "border-left": "1px solid #999",
  46. "border-right": "1px solid #333",
  47. "border-bottom": "1px solid #333"
  48. });
  49. if (this.actionArea) this.actionArea.setStyle("display", "none");
  50. this.form.currentSelectedModule = null;
  51. this.hideProperty();
  52. },
  53. unOver: function(){
  54. if (!this.form.moveModule) if (this.form.currentSelectedModule!=this) this.node.setStyles({
  55. "border-top": "1px solid #999",
  56. "border-left": "1px solid #999",
  57. "border-right": "1px solid #333",
  58. "border-bottom": "1px solid #333"
  59. });
  60. },
  61. _createCopyNode: function(){
  62. this.copyNode = new Element("div", {
  63. "styles": this.css.moduleNodeShow
  64. });
  65. this.copyNode.addEvent("selectstart", function(){
  66. return false;
  67. });
  68. },
  69. _getCopyNode: function(){
  70. if (!this.copyNode) this._createCopyNode();
  71. this.copyNode.setStyle("display", "inline-block");
  72. return this.copyNode;
  73. },
  74. _setEditStyle_custom: function(name){
  75. if (name=="name"){
  76. if (this.json.name){
  77. var button = this.node.getElement("button");
  78. if (!button) button = this.node.getFirst("input");
  79. if (button) button.set("text", "");
  80. }
  81. }
  82. if (name=="id"){
  83. if (!this.json.name){
  84. var button = this.node.getElement("button");
  85. if (!button) button = this.node.getFirst("input");
  86. if (button) button.set("text", "");
  87. }
  88. }
  89. },
  90. _preprocessingModuleData: function(){
  91. var button = this.node.getElement("button");
  92. button.clearStyles();
  93. debugger;
  94. button.setStyles(this.css.buttonStyles);
  95. //if (this.initialStyles) this.node.setStyles(this.initialStyles);
  96. this.json.recoveryStyles = Object.clone(this.json.styles);
  97. if (this.json.recoveryStyles) Object.each(this.json.recoveryStyles, function(value, key){
  98. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  99. //需要运行时处理
  100. }else{
  101. button.setStyle(key, value);
  102. delete this.json.styles[key];
  103. }
  104. }.bind(this));
  105. this.json.preprocessing = "y";
  106. },
  107. _recoveryModuleData: function(){
  108. // var button = this.node.getElement("button");
  109. // button.clearStyles();
  110. // button.setStyles(this.css.buttonIcon);
  111. //
  112. if (this.json.recoveryStyles) this.json.styles = this.json.recoveryStyles;
  113. this.json.recoveryStyles = null;
  114. },
  115. setCustomStyles: function(){
  116. this._recoveryModuleData();
  117. //debugger;
  118. var border = this.node.getStyle("border");
  119. this.node.clearStyles();
  120. this.node.setStyles(this.css.moduleNode);
  121. if (this.initialStyles) this.node.setStyles(this.initialStyles);
  122. this.node.setStyle("border", border);
  123. var button = this.node.getElement("button");
  124. button.clearStyles();
  125. button.setStyles(this.css.buttonIcon);
  126. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  127. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  128. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  129. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  130. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  131. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  132. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  133. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  134. }
  135. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  136. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  137. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  138. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  139. }
  140. value = o2.filterUrl(value);
  141. }
  142. var reg = /^border\w*/ig;
  143. if (!key.test(reg)){
  144. if (key){
  145. if (key.toString().toLowerCase()==="display"){
  146. if (value.toString().toLowerCase()==="none"){
  147. this.node.setStyle("opacity", 0.3);
  148. }else{
  149. this.node.setStyle("opacity", 1);
  150. this.node.setStyle(key, value);
  151. }
  152. }else{
  153. button.setStyle(key, value);
  154. }
  155. }
  156. }
  157. //this.node.setStyle(key, value);
  158. }.bind(this));
  159. // Object.each(this.json.styles, function(value, key){
  160. // var reg = /^border\w*/ig;
  161. // if (!key.test(reg)){
  162. // if (key){
  163. // if (key.toString().toLowerCase()==="display"){
  164. // if (value.toString().toLowerCase()==="none"){
  165. // this.node.setStyle("opacity", 0.3);
  166. // }else{
  167. // this.node.setStyle("opacity", 1);
  168. // }
  169. // }else{
  170. // this.node.setStyle(key, value);
  171. // }
  172. // }
  173. // }
  174. // }.bind(this));
  175. },
  176. });