Textarea.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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.Textarea = MWF.FCTextarea = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "/x_component_process_FormDesigner/Module/Textarea/textarea.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "/x_component_process_FormDesigner/Module/Textarea/";
  13. this.cssPath = "/x_component_process_FormDesigner/Module/Textarea/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "textarea";
  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": "textarea",
  36. "styles": this.css.moduleNodeMove,
  37. "id": this.json.id,
  38. "readonly": true,
  39. "events": {
  40. "selectstart": function(){
  41. return false;
  42. }
  43. }
  44. }).inject(this.form.container);
  45. var icon = new Element("div", {
  46. "styles": this.css.textareaIcon
  47. }).inject(this.moveNode);
  48. var text = new Element("div", {
  49. "styles": this.css.moduleText,
  50. "text": this.json.id
  51. }).inject(this.moveNode);
  52. },
  53. _loadNodeStyles: function(){
  54. var icon = this.node.getFirst("div");
  55. var text = this.node.getLast("div");
  56. if (!icon) icon = new Element("div").inject(this.node, "top");
  57. if (!text) text = new Element("div").inject(this.node, "bottom");
  58. icon.setStyles(this.css.textareaIcon);
  59. text.setStyles(this.css.moduleText);
  60. },
  61. _getCopyNode: function(){
  62. if (!this.copyNode) this._createCopyNode();
  63. this.copyNode.setStyle("display", "inline-block");
  64. return this.copyNode;
  65. },
  66. _setEditStyle_custom: function(name){
  67. if (name=="id"){
  68. this.node.getLast().set("text", this.json.id);
  69. }
  70. },
  71. setPropertiesOrStyles: function(name){
  72. if (name=="styles"){
  73. if (this.parentContainer){
  74. if (this.parentContainer.moduleName == "datagrid$Data"){
  75. if (!this.json.styles.width) this.json.styles.width = "90%";
  76. }
  77. }
  78. try{
  79. this.setCustomStyles();
  80. }catch(e){}
  81. //this.setCustomStyles();
  82. }
  83. if (name=="inputStyles"){
  84. var text = this.node.getLast("div");
  85. text.clearStyles();
  86. text.setStyles(this.css.moduleText);
  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. });