textareapanel.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * @fileOverview
  3. * 이 클래스는 BasedPanel 을 상속받는다.
  4. * 또한 TextPanel 과 HtmlPanel 가 이 클래스를 상속한다.
  5. */
  6. /**
  7. * TextareaPanel
  8. *
  9. * @class
  10. * @extends Trex.Canvas.BasedPanel
  11. * @param {Object} canvas
  12. * @param {Object} config - canvas의 config
  13. */
  14. Trex.Canvas.TextareaPanel = Trex.Class.create(/** @lends Trex.Canvas.TextareaPanel.prototype */{
  15. /** @ignore */
  16. $extend: Trex.Canvas.BasedPanel,
  17. /** @ignore */
  18. initialize: function(canvas, config) {
  19. this.$super.initialize(canvas, config);
  20. var _processor = new Trex.Canvas.TextAreaProcessor(this.el);
  21. /**
  22. * 생성된 Processor 객체를 리턴한다.
  23. * @function
  24. * @returns {Object} Processor 객체
  25. */
  26. this.getProcessor = function() {
  27. return _processor;
  28. };
  29. this.lastHeight = (this.lastHeight - 9*2).toPx();//"382px";
  30. if ( !!config.readonly ){
  31. this.setReadOnly();
  32. }
  33. },
  34. /**
  35. * panel을 보이게한다.
  36. * @function
  37. */
  38. show: function() {
  39. this.$super.show();
  40. var _elHolder = this.elHolder;
  41. var _processor = this.getProcessor();
  42. setTimeout(function(){
  43. try {
  44. _processor.focusOnTop(); //모드 변경시 focus 제일 위로 가게함..
  45. } catch (ignore) {}
  46. if ($tx.msie6) { //NOTE: #FTDUEDTR-174
  47. _elHolder.style.padding = "1px";
  48. setTimeout(function(){
  49. _elHolder.style.padding = "0px";
  50. }, 0);
  51. }
  52. }, 100);
  53. },
  54. /**
  55. * 컨텐츠 영역의 컨텐츠를 주어진 문자열로 수정한다.
  56. * @function
  57. * @param {String} content - 컨텐츠
  58. */
  59. setContent: function(content) {
  60. this.el.value = content;
  61. },
  62. /**
  63. * 컨텐츠 영역에 쓰여진 컨텐츠를 얻어온다.
  64. * @function
  65. * @returns {String} 컨텐츠 문자열
  66. */
  67. getContent: function() {
  68. return this.el.value;
  69. },
  70. /**
  71. * panel 영역의 높이를 얻어온다.
  72. * @function
  73. * @returns {String} textarea 영역의 높이 (px)
  74. */
  75. getPanelHeight: function() {
  76. return ($tom.getHeight(this.el).parsePx() + 2).toPx();
  77. },
  78. /**
  79. * panel 영역의 높이를 셋팅한다.
  80. * @function
  81. * @param {Number} width - textarea 영역의 넓이 (px)
  82. */
  83. setPanelHeight: function(height) {
  84. this.$super.setPanelHeight((height.parsePx() - 2).toPx());
  85. },
  86. /**
  87. * panel의 readonly를 속성을 setting함으로써 글쓰기를 제한한다.
  88. * @function
  89. */
  90. setReadOnly: function(){
  91. this.el.readOnly = _TRUE;
  92. }
  93. });