Textfield.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. try{
  60. this.setCustomStyles();
  61. }catch(e){}
  62. //this.setCustomStyles();
  63. }
  64. if (name=="inputStyles"){
  65. var text = this.node.getLast("div");
  66. text.clearStyles();
  67. text.setStyles(this.css.moduleText);
  68. Object.each(this.json.inputStyles, function(value, key){
  69. var reg = /^border\w*/ig;
  70. if (!key.test(reg)){
  71. text.setStyle(key, value);
  72. }
  73. }.bind(this));
  74. }
  75. if (name=="properties"){
  76. this.node.setProperties(this.json.properties);
  77. }
  78. },
  79. _loadNodeStyles: function(){
  80. var icon = this.node.getFirst("div");
  81. var text = this.node.getLast("div");
  82. if (!icon) icon = new Element("div").inject(this.node, "top");
  83. if (!text) text = new Element("div").inject(this.node, "bottom");
  84. icon.setStyles(this.css.textfieldIcon);
  85. text.setStyles(this.css.moduleText);
  86. },
  87. _getCopyNode: function(){
  88. if (!this.copyNode) this._createCopyNode();
  89. this.copyNode.setStyle("display", "inline-block");
  90. return this.copyNode;
  91. },
  92. _setEditStyle_custom: function(name){
  93. if (name=="id"){
  94. this.node.getLast().set("text", this.json.id);
  95. }
  96. //if (name=="isTitle"){
  97. // if (this.json.isTitle){
  98. // this.form.moduleList.each(function(module){
  99. // if (module.moduleName=="textfield"){
  100. // if (module.json.id!=this.json.id){
  101. // module.json.isTitle = false;
  102. // if (module.property){
  103. // var td = module.property.propertyContent.getElementById(module.json.id+"isTitleArea");
  104. // if (td) td.getElements("input")[1].set("checked", true);
  105. // }
  106. // }
  107. // }
  108. // }.bind(this));
  109. // }
  110. //}
  111. }
  112. });