cellslinestyle.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. TrexMessage.addMsg({
  2. '@cellslinestyle.subtitle1': '테두리 없음',
  3. '@cellslinestyle.subtitle2': '실선',
  4. '@cellslinestyle.subtitle3': '점선',
  5. '@cellslinestyle.subtitle4': '작은 점선'
  6. });
  7. TrexConfig.addTool(
  8. "cellslinestyle",
  9. {
  10. sync: _FALSE,
  11. status: _TRUE,
  12. options: [
  13. { label: TXMSG('@cellslinestyle.subtitle1'), title: '테두리 없음', data: 'none', klass: 'tx-cellslinestyle-1' },
  14. { label: TXMSG('@cellslinestyle.subtitle2'), title: '실선', data: 'solid', klass: 'tx-cellslinestyle-2' },
  15. { label: TXMSG('@cellslinestyle.subtitle3'), title: '점선', data: 'dotted', klass: 'tx-cellslinestyle-3' },
  16. { label: TXMSG('@cellslinestyle.subtitle4'), title: '작은 점선', data: 'dashed', klass: 'tx-cellslinestyle-4' }
  17. ]
  18. }
  19. );
  20. Trex.Tool.Cellslinestyle = Trex.Class.create({
  21. $const: {
  22. __Identity: 'cellslinestyle'
  23. },
  24. $extend: Trex.Tool,
  25. oninitialized: function(config) {
  26. var self = this;
  27. self.createListStyleMap(config);
  28. self.weave(
  29. new Trex.Button.CellsLineStyledList(self.buttonCfg),
  30. new Trex.Menu.Select(self.menuCfg),
  31. self.handler
  32. );
  33. },
  34. createListStyleMap: function(config) {
  35. var listStyleMap = this.listStyleMap = {};
  36. config.options.each(function(option) {
  37. listStyleMap[option.data] = {
  38. type: option.type,
  39. klass: option.klass
  40. };
  41. });
  42. },
  43. handler: function(data) {
  44. var self = this;
  45. if (!self.listStyleMap[data]) {
  46. return;
  47. }
  48. // 실제 로직은 여기부분 입니다.
  49. self.canvas.query(function(processor){
  50. if (processor.table) {
  51. processor.table.setBorderType(data);
  52. }
  53. });
  54. },
  55. getDefaultProperty: function() {
  56. return 1;
  57. }
  58. });
  59. Trex.Button.CellsLineStyledList = Trex.Class.create({
  60. $extend: Trex.Button.Select
  61. });