cellsoutline.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * @fileoverview
  3. * '행,열 삽입' Icon Source,
  4. * Class Trex.Tool.celloutline configuration을 포함
  5. *
  6. */
  7. TrexConfig.addTool(
  8. "cellsoutline",
  9. {
  10. sync: _FALSE,
  11. status: _TRUE,
  12. options: [
  13. { label: '모든 테두리', title: '모든 테두리', data: 'all', klass: 'tx-cellsoutline-1' },
  14. { label: '바깥 테두리', title: '바깥 테두리', data: 'out', klass: 'tx-cellsoutline-2' },
  15. { label: '안쪽 테두리', title: '안쪽 테두리', data: 'in', klass: 'tx-cellsoutline-3' },
  16. { label: '위쪽 테두리', title: '위쪽 테두리', data: 'top' , klass: 'tx-cellsoutline-4' },
  17. { label: '아래쪽 테두리', title: '아래쪽 테두리', data: 'bottom', klass: 'tx-cellsoutline-5' },
  18. { label: '왼쪽 테두리', title: '왼쪽 테두리', data: 'left' , klass: 'tx-cellsoutline-6' },
  19. { label: '오른쪽 테두리', title: '오른쪽 테두리', data: 'right' , klass: 'tx-cellsoutline-7' },
  20. { label: '테두리 없음', title: '테두리 없음', data: 'none' , klass: 'tx-cellsoutline-8' }
  21. ]
  22. }
  23. );
  24. Trex.Tool.Cellsoutline = Trex.Class.create({
  25. $const: {
  26. __Identity: 'cellsoutline'
  27. },
  28. $extend: Trex.Tool,
  29. oninitialized: function(config) {
  30. var self = this;
  31. this.twinkleCount = 0;
  32. this.twinkleTimer = _NULL;
  33. self.createListStyleMap(config);
  34. self.weave(
  35. new Trex.Button.CellsoutlineList(self.buttonCfg),
  36. new Trex.Menu.Select(self.menuCfg),
  37. self.handler
  38. );
  39. this.toolbar.observeJob(Trex.Ev.__TOOL_CELL_LINE_CHANGE, function(data){
  40. if (data.fromInit != _TRUE) {
  41. self.twinkleButton();
  42. }
  43. });
  44. },
  45. createListStyleMap: function(config) {
  46. var listStyleMap = this.listStyleMap = {};
  47. config.options.each(function(option) {
  48. listStyleMap[option.data] = {
  49. type: option.type,
  50. klass: option.klass
  51. };
  52. });
  53. },
  54. handler: function(data) {
  55. var self = this;
  56. if (!self.listStyleMap[data]) {
  57. return;
  58. }
  59. // 실제 로직은 여기부분 입니다.
  60. self.canvas.query(function(processor){
  61. if (processor.table) {
  62. processor.table.setBorderRange(data);
  63. }
  64. });
  65. self.canvas.execute(function(processor) {
  66. if (processor.table) {
  67. if (data == 'none') {
  68. processor.table.setNoBorder();
  69. } else {
  70. processor.table.applyBorder();
  71. }
  72. }
  73. });
  74. },
  75. twinkleButton: function(){
  76. var self;
  77. self = this;
  78. if (this.twinkleTimer) {
  79. clearInterval(this.twinkleTimer);
  80. this.twinkleTimer = _NULL;
  81. }
  82. this.twinkleCount = 4;
  83. this.twinkleTimer = setInterval(function(){
  84. if (0 < self.twinkleCount) {
  85. self.twinkleCount -= 1;
  86. if (self.button.currentState() == "hovered") {
  87. self.button.normalState();
  88. } else {
  89. self.button.hoveredState()
  90. }
  91. } else {
  92. self.button.normalState();
  93. clearInterval(self.twinkleTimer);
  94. self.twinkleTimer = _NULL;
  95. }
  96. }, 500);
  97. }
  98. });
  99. Trex.Button.CellsoutlineList = Trex.Class.create({
  100. $extend: Trex.Button.Select
  101. });