tableedittool.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * @fileoverview
  3. * toolbar의 접힌 부분을 열고닫는 '더보기' Icon을 위해 필요한 configuration과 Class Trex.Tool.Advanced 를 포함
  4. *
  5. */
  6. TrexConfig.addTool(
  7. "tableedittool",
  8. {
  9. sync: _FALSE,
  10. status: _TRUE,
  11. opened: _FALSE
  12. }
  13. );
  14. /**
  15. * Trex.Tool.Advanced
  16. *
  17. * @class
  18. * @extends Trex.Tool
  19. */
  20. Trex.Tool.TableEditTool = Trex.Class.create({
  21. $const: {
  22. __Identity: 'tableedittool'
  23. },
  24. $extend: Trex.Tool,
  25. /**
  26. * instance가 생성될 때 실행되며 필요한 UI Component 및 Event handler를 생성한다.
  27. *
  28. * @memberOf Trex.Tool.Advanced.prototype
  29. * @param {Object} config
  30. */
  31. oninitialized: function(config) {
  32. var _toolbar = this.toolbar;
  33. var _elBasic = _toolbar.el;
  34. var _elAdvanced = $tom.collect(_elBasic.parentNode, 'div.tx-toolbar-advanced');
  35. if(!_elAdvanced) {
  36. return;
  37. }
  38. _toolbar.observeJob("toolbar.advanced.fold", function() {
  39. $tx.hide(_elAdvanced);
  40. $tx.removeClassName(_elBasic, 'tx-toolbar-basic-open');
  41. });
  42. _toolbar.observeJob("toolbar.advanced.spread", function() {
  43. $tx.show(_elAdvanced);
  44. $tx.addClassName(_elBasic, 'tx-toolbar-basic-open');
  45. });
  46. var _isOpened = _FALSE;
  47. var _toolHandler = function() {
  48. if(_isOpened) {
  49. _toolbar.fireJobs("toolbar.advanced.fold");
  50. } else {
  51. _toolbar.fireJobs("toolbar.advanced.spread");
  52. }
  53. _isOpened = !_isOpened;
  54. };
  55. /* button & menu weave */
  56. this.weave.bind(this)(
  57. /* button */
  58. new Trex.Button(this.buttonCfg),
  59. /* menu */
  60. _NULL,
  61. /* handler */
  62. _toolHandler
  63. );
  64. if(config.opened == _TRUE) {
  65. _elAdvanced.show();
  66. $tx.addClassName(_elBasic, 'tx-toolbar-basic-open');
  67. _isOpened = _TRUE;
  68. }
  69. }
  70. });