$Input.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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.$Input = MWF.FC$Input = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "type": "textfield",
  9. "path": "../x_component_process_FormDesigner/Module/Textfield/",
  10. "propertyPath": "../x_component_process_FormDesigner/Module/Textfield/textfield.html"
  11. },
  12. initialize: function(form, options){
  13. this.setOptions(options);
  14. this.path = this.options.path;
  15. this.cssPath = this.path+this.options.style+"/css.wcss";
  16. this._loadCss();
  17. this.moduleType = "element";
  18. this.moduleName = this.options.type;
  19. this.form = form;
  20. this.container = null;
  21. this.containerNode = null;
  22. },
  23. clearTemplateStyles: function(styles){
  24. if (styles){
  25. if (styles.styles) this.removeStyles(styles.styles, "styles");
  26. if (styles.inputStyles) this.removeStyles(styles.inputStyles, "inputStyles");
  27. if (styles.properties) this.removeStyles(styles.properties, "properties");
  28. }
  29. },
  30. setTemplateStyles: function(styles){
  31. if (styles.styles) this.copyStyles(styles.styles, "styles");
  32. if (styles.inputStyles) this.copyStyles(styles.inputStyles, "inputStyles");
  33. if (styles.properties) this.copyStyles(styles.properties, "properties");
  34. },
  35. _resetModuleDomNode: function(){
  36. if (this.json.preprocessing){
  37. this.node.empty();
  38. var icon = new Element("div", {
  39. "styles": this.css.textfieldIcon
  40. }).inject(this.node);
  41. var text = new Element("div", {
  42. "styles": this.css.moduleText,
  43. "text": this.json.id
  44. }).inject(this.node);
  45. }
  46. },
  47. _createMoveNode: function(){
  48. this.moveNode = new Element("div", {
  49. "MWFType": "textfield",
  50. "id": this.json.id,
  51. "styles": this.css.moduleNodeMove,
  52. "events": {
  53. "selectstart": function(){
  54. return false;
  55. }
  56. }
  57. }).inject(this.form.container);
  58. var icon = new Element("div", {
  59. "styles": this.css.textfieldIcon
  60. }).inject(this.moveNode);
  61. var text = new Element("div", {
  62. "styles": this.css.moduleText,
  63. "text": this.json.id
  64. }).inject(this.moveNode);
  65. },
  66. setPropertiesOrStyles: function(name){
  67. if (name=="styles"){
  68. // if (this.parentContainer){
  69. // if (this.parentContainer.moduleName == "datagrid$Data"){
  70. // //if (!this.json.styles.width) this.json.styles.width = "90%";
  71. // }
  72. // }
  73. try{
  74. this.setCustomStyles();
  75. }catch(e){}
  76. //this.setCustomStyles();
  77. }
  78. if (name=="inputStyles"){
  79. try{
  80. this.setCustomInputStyles();
  81. }catch(e){}
  82. //
  83. // var text = this.node.getLast("div");
  84. // text.clearStyles();
  85. // text.setStyles(this.css.moduleText);
  86. //
  87. // Object.each(this.json.inputStyles, function(value, key){
  88. // var reg = /^border\w*/ig;
  89. // if (!key.test(reg)){
  90. // text.setStyle(key, value);
  91. // }
  92. // }.bind(this));
  93. }
  94. if (name=="properties"){
  95. this.node.setProperties(this.json.properties);
  96. }
  97. },
  98. _loadNodeStyles: function(){
  99. var icon = this.node.getFirst("div");
  100. var text = this.node.getLast("div");
  101. if (!icon) icon = new Element("div").inject(this.node, "top");
  102. if (!text) text = new Element("div").inject(this.node, "bottom");
  103. icon.setStyles(this.css.textfieldIcon);
  104. text.setStyles(this.css.moduleText);
  105. },
  106. _getCopyNode: function(){
  107. if (!this.copyNode) this._createCopyNode();
  108. this.copyNode.setStyle("display", "inline-block");
  109. return this.copyNode;
  110. },
  111. _setEditStyle_custom: function(name){
  112. if (name=="id"){
  113. this.node.getLast().set("text", this.json.id);
  114. }
  115. },
  116. _preprocessingModuleData: function(){
  117. debugger;
  118. this.node.clearStyles();
  119. this.recoveryIconNode = this.node.getFirst();
  120. this.recoveryIconNode.dispose();
  121. this.recoveryTextNode = this.node.getFirst();
  122. this.recoveryTextNode.dispose();
  123. var inputNode = new Element("input", {
  124. "styles": {
  125. "background": "transparent",
  126. "width": "100%",
  127. "border": "0px"
  128. }
  129. }).inject(this.node);
  130. this.node.setStyles({
  131. "overflow": "hidden",
  132. "position": "relative",
  133. "margin-right": "20px",
  134. "padding-right": "4px"
  135. });
  136. if (this.json.styles){
  137. this.json.recoveryStyles = Object.clone(this.json.styles);
  138. if (this.json.recoveryStyles) Object.each(this.json.recoveryStyles, function(value, key){
  139. if ((value.indexOf("x_processplatform_assemble_surface")==-1 && value.indexOf("x_portal_assemble_surface")==-1)){
  140. this.node.setStyle(key, value);
  141. delete this.json.styles[key];
  142. }
  143. }.bind(this));
  144. }
  145. if (this.json.inputStyles){
  146. this.json.recoveryInputStyles = Object.clone(this.json.inputStyles);
  147. var inputNode = this.node.getFirst();
  148. if (inputNode){
  149. if (this.json.recoveryInputStyles) Object.each(this.json.recoveryInputStyles, function(value, key){
  150. if ((value.indexOf("x_processplatform_assemble_surface")==-1 && value.indexOf("x_portal_assemble_surface")==-1)){
  151. inputNode.setStyle(key, value);
  152. delete this.json.inputStyles[key];
  153. }
  154. }.bind(this));
  155. }
  156. }
  157. this.json.preprocessing = "y";
  158. },
  159. _recoveryModuleData: function(){
  160. if (this.json.recoveryStyles) this.json.styles = this.json.recoveryStyles;
  161. if (this.json.recoveryInputStyles) this.json.inputStyles = this.json.recoveryInputStyles;
  162. if (this.recoveryTextNode) {
  163. this.node.empty();
  164. this.recoveryTextNode.inject(this.node, "top");
  165. }
  166. if (this.recoveryIconNode) {
  167. this.recoveryIconNode.inject(this.node, "top");
  168. }
  169. this.json.recoveryStyles = null;
  170. this.json.recoveryInputStyles = null;
  171. this.recoveryIconNode = null;
  172. this.recoveryTextNode = null;
  173. },
  174. setCustomStyles: function(){
  175. this._recoveryModuleData();
  176. //debugger;
  177. //var border = this.node.getStyle("border");
  178. this.node.clearStyles();
  179. this.node.setStyles(this.css.moduleNode);
  180. if (this.initialStyles) this.node.setStyles(this.initialStyles);
  181. //this.node.setStyle("border", border);
  182. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  183. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  184. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  185. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  186. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  187. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  188. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  189. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  190. }
  191. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  192. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  193. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  194. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  195. }
  196. }
  197. var reg = /^border\w*/ig;
  198. if (!key.test(reg)){
  199. if (key){
  200. if (key.toString().toLowerCase()==="display"){
  201. if (value.toString().toLowerCase()==="none"){
  202. this.node.setStyle("opacity", 0.3);
  203. }else{
  204. this.node.setStyle("opacity", 1);
  205. this.node.setStyle(key, value);
  206. }
  207. }else{
  208. this.node.setStyle(key, value);
  209. }
  210. }
  211. }
  212. }.bind(this));
  213. },
  214. setCustomInputStyles: function(){
  215. this._recoveryModuleData();
  216. var inputNode = this.node.getLast();
  217. if (inputNode){
  218. inputNode.clearStyles();
  219. inputNode.setStyles(this.css.moduleText);
  220. if (this.json.inputStyles) Object.each(this.json.inputStyles, function(value, key){
  221. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  222. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  223. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  224. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  225. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  226. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  227. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  228. }
  229. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  230. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  231. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  232. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  233. }
  234. }
  235. var reg = /^border\w*/ig;
  236. if (!key.test(reg)){
  237. if (key){
  238. if (key.toString().toLowerCase()==="display"){
  239. if (value.toString().toLowerCase()==="none"){
  240. inputNode.setStyle("opacity", 0.3);
  241. }else{
  242. inputNode.setStyle("opacity", 1);
  243. inputNode.setStyle(key, value);
  244. }
  245. }else{
  246. inputNode.setStyle(key, value);
  247. }
  248. }
  249. }
  250. }.bind(this));
  251. }
  252. }
  253. });