advanced.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * @fileoverview
  3. * toolbar의 접힌 부분을 열고닫는 '더보기' Icon을 위해 필요한 configuration과 Class Trex.Tool.Advanced 를 포함
  4. *
  5. */
  6. TrexConfig.addTool(
  7. "advanced",
  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.Advanced = Trex.Class.create({
  21. $const: {
  22. __Identity: 'advanced'
  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 self = this;
  33. var _toolbar = this.toolbar;
  34. var _elBasic = _toolbar.el;
  35. self.opened = _FALSE;
  36. var _elAdvanced = $tom.collect(_elBasic.parentNode, 'div.tx-toolbar-advanced');
  37. if(!_elAdvanced) {
  38. return;
  39. }
  40. _toolbar.observeJob(Trex.Ev.__CMD_ADVANCED_FOLD, function() {
  41. $tx.hide(_elAdvanced);
  42. $tx.removeClassName(_elBasic, 'tx-toolbar-basic-open');
  43. });
  44. _toolbar.observeJob(Trex.Ev.__CMD_ADVANCED_SPREAD, function() {
  45. $tx.show(_elAdvanced);
  46. $tx.addClassName(_elBasic, 'tx-toolbar-basic-open');
  47. });
  48. var _toolHandler = function() {
  49. if(self.opened) {
  50. _toolbar.fireJobs(Trex.Ev.__CMD_ADVANCED_FOLD);
  51. } else {
  52. _toolbar.fireJobs(Trex.Ev.__CMD_ADVANCED_SPREAD);
  53. }
  54. self.opened = !self.opened;
  55. };
  56. /* button & menu weave */
  57. this.weave.bind(this)(
  58. /* button */
  59. new Trex.Button(this.buttonCfg),
  60. /* menu */
  61. _NULL,
  62. /* handler */
  63. _toolHandler
  64. );
  65. if(config.opened == _TRUE) {
  66. this.forceOpen();
  67. }
  68. },
  69. forceOpen: function(){
  70. this.button.pushedState();
  71. this.toolbar.fireJobs(Trex.Ev.__CMD_ADVANCED_SPREAD);
  72. this.opened = _TRUE;
  73. }
  74. });