Html.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.Html = MWF.FCHtml = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "/x_component_process_FormDesigner/Module/Html/html.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "/x_component_process_FormDesigner/Module/Html/";
  13. this.cssPath = "/x_component_process_FormDesigner/Module/Html/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "html";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. this.moveNode = new Element("div", {
  23. "MWFType": "html",
  24. "id": this.json.id,
  25. "styles": this.css.moduleNodeMove,
  26. "text": ""
  27. }).inject(this.form.container);
  28. this.textarea = new Element("textarea", {
  29. "styles":{
  30. "background": "transparent",
  31. "border": "0px",
  32. "width": "100%",
  33. "overflow": "hidden",
  34. "cursor": "pointer",
  35. "webkit-user-select": "text",
  36. "moz-user-select": "text",
  37. "font-size": "12px",
  38. "color": "#193ee1",
  39. "height": "18px",
  40. "line-height": "18px"
  41. }
  42. }).inject(this.moveNode);
  43. },
  44. _loadNodeStyles: function(){
  45. this.textarea = this.node.getFirst("textarea");
  46. this.textarea.setStyles({
  47. "background": "transparent",
  48. "border": "0px",
  49. "width": "100%",
  50. "overflow": "hidden",
  51. "cursor": "pointer",
  52. "webkit-user-select": "text",
  53. "moz-user-select": "text",
  54. "font-size": "12px",
  55. "color": "#193ee1",
  56. "height": "18px",
  57. "line-height": "18px"
  58. });
  59. this.textarea.set("value", this.json.text);
  60. },
  61. _createNode: function(){
  62. this.node = this.moveNode.clone(true, true);
  63. this.node.setStyles(this.css.moduleNode);
  64. this.textarea = this.node.getFirst("textarea");
  65. this.textarea.set("value", this.json.text);
  66. },
  67. _setTextareaHeight: function(){
  68. this.textarea.setStyle("height", "18px");
  69. var scroll = this.textarea.getScrollSize();
  70. var size = this.textarea.getSize();
  71. if (scroll.y>size.y){
  72. this.textarea.setStyle("height", ""+scroll.y+"px");
  73. }
  74. },
  75. _setOtherNodeEvent: function(){
  76. this.textarea.focus();
  77. this.textarea.addEvents({
  78. "keydown": function(){
  79. this._setTextareaHeight();
  80. }.bind(this),
  81. "keyup": function(e){
  82. if (e.code==8 || e.code==46 || (e.control && e.code==88)){
  83. this._setTextareaHeight();
  84. }
  85. var editNode = $("editHtmlText");
  86. if (editNode) editNode.set("value", this.textarea.get("value"));
  87. }.bind(this),
  88. "change": function(){
  89. this.json.text = this.textarea.get("value");
  90. }.bind(this),
  91. "blur": function(){
  92. this.json.text = this.textarea.get("value");
  93. }.bind(this)
  94. });
  95. },
  96. _setEditStyle_custom: function(name){
  97. if (name=="text"){
  98. this.textarea.set("value", this.json.text);
  99. this._setTextareaHeight();
  100. }
  101. }
  102. });