Button.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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.Button = MWF.FCButton = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/Button/button.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/Button/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/Button/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "button";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. this.moveNode = new Element("div", {
  23. "MWFType": "button",
  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": this.json.name || this.json.id
  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", this.json.name);
  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", this.json.id);
  87. }
  88. }
  89. },
  90. _preprocessingModuleData: function(){
  91. var button = this.node.getElement("button");
  92. button.clearStyles();
  93. button.setStyles(this.css.buttonStyles);
  94. //if (this.initialStyles) this.node.setStyles(this.initialStyles);
  95. this.json.recoveryStyles = Object.clone(this.json.styles);
  96. if (this.json.recoveryStyles) Object.each(this.json.recoveryStyles, function(value, key){
  97. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  98. //需要运行时处理
  99. }else{
  100. button.setStyle(key, value);
  101. delete this.json.styles[key];
  102. }
  103. }.bind(this));
  104. this.json.preprocessing = "y";
  105. },
  106. _recoveryModuleData: function(){
  107. // var button = this.node.getElement("button");
  108. // button.clearStyles();
  109. // button.setStyles(this.css.buttonIcon);
  110. //
  111. if (this.json.recoveryStyles) this.json.styles = this.json.recoveryStyles;
  112. this.json.recoveryStyles = null;
  113. },
  114. setCustomStyles: function(){
  115. this._recoveryModuleData();
  116. var border = this.node.getStyle("border");
  117. this.node.clearStyles();
  118. this.node.setStyles(this.css.moduleNode);
  119. if (this.initialStyles) this.node.setStyles(this.initialStyles);
  120. this.node.setStyle("border", border);
  121. var button = this.node.getElement("button");
  122. button.clearStyles();
  123. button.setStyles(this.css.buttonIcon);
  124. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  125. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  126. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  127. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  128. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  129. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  130. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  131. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  132. }
  133. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  134. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  135. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  136. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  137. }
  138. value = o2.filterUrl(value);
  139. }
  140. var reg = /^border\w*/ig;
  141. if (!key.test(reg)){
  142. if (key){
  143. if (key.toString().toLowerCase()==="display"){
  144. if (value.toString().toLowerCase()==="none"){
  145. this.node.setStyle("opacity", 0.3);
  146. }else{
  147. this.node.setStyle("opacity", 1);
  148. this.node.setStyle(key, value);
  149. }
  150. }else{
  151. button.setStyle(key, value);
  152. }
  153. }
  154. }
  155. //this.node.setStyle(key, value);
  156. }.bind(this));
  157. // Object.each(this.json.styles, function(value, key){
  158. // var reg = /^border\w*/ig;
  159. // if (!key.test(reg)){
  160. // if (key){
  161. // if (key.toString().toLowerCase()==="display"){
  162. // if (value.toString().toLowerCase()==="none"){
  163. // this.node.setStyle("opacity", 0.3);
  164. // }else{
  165. // this.node.setStyle("opacity", 1);
  166. // }
  167. // }else{
  168. // this.node.setStyle(key, value);
  169. // }
  170. // }
  171. // }
  172. // }.bind(this));
  173. },
  174. });