Html.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. _setNodeProperty: function(){
  62. if (this.form.moduleList.indexOf(this)==-1) this.form.moduleList.push(this);
  63. if (this.form.moduleNodeList.indexOf(this.node)==-1) this.form.moduleNodeList.push(this.node);
  64. if (this.form.moduleElementNodeList.indexOf(this.node)==-1) this.form.moduleElementNodeList.push(this.node);
  65. this.textarea.set("value", this.json.text);
  66. this.textarea.removeAttribute('disabled');
  67. if (this.property){
  68. var editNode = this.property.propertyNode.getElement(".MWF_editHtmlText");
  69. if (editNode) editNode.set("value", this.textarea.get("value"));
  70. }
  71. this._setTextareaHeight();
  72. },
  73. _createNode: function(){
  74. this.node = this.moveNode.clone(true, true);
  75. this.node.store("module", this);
  76. this.node.setStyles(this.css.moduleNode);
  77. this.textarea = this.node.getFirst("textarea");
  78. this.textarea.set("value", this.json.text);
  79. },
  80. _setTextareaHeight: function(){
  81. this.textarea.setStyle("height", "18px");
  82. var scroll = this.textarea.getScrollSize();
  83. var size = this.textarea.getSize();
  84. if (scroll.y>size.y){
  85. this.textarea.setStyle("height", ""+scroll.y+"px");
  86. }
  87. },
  88. _setOtherNodeEvent: function(){
  89. // this.textarea.focus();
  90. this.textarea.addEvents({
  91. "keydown": function(e){
  92. this._setTextareaHeight();
  93. e.stopPropagation();
  94. }.bind(this),
  95. "keyup": function(e){
  96. if (e.code==8 || e.code==46 || (e.control && e.code==88)){
  97. this._setTextareaHeight();
  98. }
  99. if (this.property){
  100. var editNode = this.property.propertyNode.getElement(".MWF_editHtmlText");
  101. if (editNode) editNode.set("value", this.textarea.get("value"));
  102. }
  103. // var editNode = $("editHtmlText");
  104. // if (editNode) editNode.set("value", this.textarea.get("value"));
  105. }.bind(this),
  106. "change": function(){
  107. this.checkPropertyHistory("text", this.json.text, this.textarea.get("value"));
  108. this.json.text = this.textarea.get("value");
  109. }.bind(this),
  110. "blur": function(){
  111. this.checkPropertyHistory("text", this.json.text, this.textarea.get("value"));
  112. this.json.text = this.textarea.get("value");
  113. }.bind(this)
  114. });
  115. // this.node.addEvents({
  116. // "mouseenter": function () {
  117. // this.textarea.disabled = false;
  118. // }.bind(this),
  119. // "mouseleave": function () {
  120. // this.textarea.disabled = true;
  121. // }.bind(this)
  122. // })
  123. },
  124. _setEditStyle_custom: function(name){
  125. if (name=="text"){
  126. this.textarea.set("value", this.json.text);
  127. this._setTextareaHeight();
  128. }
  129. }
  130. });