No Description

ToolbarButton.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var tippy_js_1 = require("tippy.js");
  4. var uuid_1 = require("../utils/uuid");
  5. var ToolbarButton = (function () {
  6. function ToolbarButton(toolbarItem, clickHandler) {
  7. var _this = this;
  8. this.id = uuid_1.uuid();
  9. this.getElement = function () {
  10. if (_this.toolbarItem.onRender) {
  11. _this.container = _this.toolbarItem.onRender().cloneNode(true);
  12. return _this.container;
  13. }
  14. var div = document.createElement('div');
  15. if (_this.toolbarItem.name !== 'separator') {
  16. div.className = 'fc-whiteboard-toolbar-button';
  17. if (_this.clickHandler) {
  18. div.addEventListener('click', function (ev) {
  19. if (_this.clickHandler) {
  20. _this.clickHandler(ev, _this.toolbarItem);
  21. }
  22. });
  23. }
  24. if (_this.toolbarItem.icon) {
  25. div.title = _this.toolbarItem.tooltipText || '';
  26. div.innerHTML = _this.toolbarItem.icon;
  27. }
  28. else {
  29. div.innerText = _this.toolbarItem.tooltipText || '';
  30. }
  31. if (_this.toolbarItem.tooltipText) {
  32. tippy_js_1.default(div, {
  33. content: _this.toolbarItem.shortcut
  34. ? _this.toolbarItem.tooltipText + " " + _this.toolbarItem.shortcut
  35. : _this.toolbarItem.tooltipText
  36. });
  37. }
  38. }
  39. else {
  40. div.className = 'fc-whiteboard-toolbar-separator';
  41. }
  42. div.id = "fc-whiteboard-toolbar-" + _this.toolbarItem.name;
  43. _this.container = div;
  44. return div;
  45. };
  46. this.toolbarItem = toolbarItem;
  47. if (clickHandler) {
  48. this.clickHandler = clickHandler;
  49. }
  50. }
  51. return ToolbarButton;
  52. }());
  53. exports.ToolbarButton = ToolbarButton;