Textfield.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.Textfield = MWF.FCTextfield = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "/x_component_process_FormDesigner/Module/Textfield/textfield.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "/x_component_process_FormDesigner/Module/Textfield/";
  13. this.cssPath = "/x_component_process_FormDesigner/Module/Textfield/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "textfield";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. clearTemplateStyles: function(styles){
  22. if (styles){
  23. if (styles.styles) this.removeStyles(styles.styles, "styles");
  24. if (styles.inputStyles) this.removeStyles(styles.inputStyles, "inputStyles");
  25. if (styles.properties) this.removeStyles(styles.properties, "properties");
  26. }
  27. },
  28. setTemplateStyles: function(styles){
  29. if (styles.styles) this.copyStyles(styles.styles, "styles");
  30. if (styles.inputStyles) this.copyStyles(styles.inputStyles, "inputStyles");
  31. if (styles.properties) this.copyStyles(styles.properties, "properties");
  32. },
  33. _createMoveNode: function(){
  34. this.moveNode = new Element("div", {
  35. "MWFType": "textfield",
  36. "id": this.json.id,
  37. "styles": this.css.moduleNodeMove,
  38. "events": {
  39. "selectstart": function(){
  40. return false;
  41. }
  42. }
  43. }).inject(this.form.container);
  44. var icon = new Element("div", {
  45. "styles": this.css.textfieldIcon
  46. }).inject(this.moveNode);
  47. var text = new Element("div", {
  48. "styles": this.css.moduleText,
  49. "text": this.json.id
  50. }).inject(this.moveNode);
  51. },
  52. setPropertiesOrStyles: function(name){
  53. if (name=="styles"){
  54. if (this.parentContainer){
  55. //if (this.parentContainer.moduleName == "datagrid$Data"){
  56. // if (!this.json.styles.width) this.json.styles.width = "90%";
  57. //}
  58. }
  59. this.setCustomStyles();
  60. }
  61. if (name=="inputStyles"){
  62. debugger;
  63. var text = this.node.getLast("div");
  64. text.clearStyles();
  65. text.setStyles(this.css.moduleText);
  66. Object.each(this.json.inputStyles, function(value, key){
  67. var reg = /^border\w*/ig;
  68. if (!key.test(reg)){
  69. text.setStyle(key, value);
  70. }
  71. }.bind(this));
  72. }
  73. if (name=="properties"){
  74. this.node.setProperties(this.json.properties);
  75. }
  76. },
  77. _loadNodeStyles: function(){
  78. var icon = this.node.getFirst("div");
  79. var text = this.node.getLast("div");
  80. icon.setStyles(this.css.textfieldIcon);
  81. text.setStyles(this.css.moduleText);
  82. },
  83. _getCopyNode: function(){
  84. if (!this.copyNode) this._createCopyNode();
  85. this.copyNode.setStyle("display", "inline-block");
  86. return this.copyNode;
  87. },
  88. _setEditStyle_custom: function(name){
  89. if (name=="id"){
  90. this.node.getLast().set("text", this.json.id);
  91. }
  92. //if (name=="isTitle"){
  93. // if (this.json.isTitle){
  94. // this.form.moduleList.each(function(module){
  95. // if (module.moduleName=="textfield"){
  96. // if (module.json.id!=this.json.id){
  97. // module.json.isTitle = false;
  98. // if (module.property){
  99. // var td = module.property.propertyContent.getElementById(module.json.id+"isTitleArea");
  100. // if (td) td.getElements("input")[1].set("checked", true);
  101. // }
  102. // }
  103. // }
  104. // }.bind(this));
  105. // }
  106. //}
  107. }
  108. });