Açıklama Yok

Toolbar.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. var interactjs_1 = require("interactjs");
  17. var ToolbarButton_1 = require("./ToolbarButton");
  18. var uuid_1 = require("../utils/uuid");
  19. require("./index.less");
  20. var index_1 = require("../renderer/DomEventAware/index");
  21. var toolbar_items_1 = require("./toolbar-items");
  22. var Toolbar = (function (_super) {
  23. __extends(Toolbar, _super);
  24. function Toolbar(toolbarItems, clickHandler) {
  25. var _this = _super.call(this) || this;
  26. _this.id = uuid_1.uuid();
  27. _this.zIndex = 999;
  28. _this.toolbarButtons = [];
  29. _this.getUI = function (drawboard) {
  30. _this.toolbarUI = document.createElement('div');
  31. _this.toolbarUI.id = "fcw-toolbar-" + _this.id;
  32. _this.toolbarUI.className = 'fc-whiteboard-toolbar';
  33. for (var _i = 0, _a = _this.toolbarItems; _i < _a.length; _i++) {
  34. var toolbarItem = _a[_i];
  35. var toolbarButton = new ToolbarButton_1.ToolbarButton(toolbarItem, _this.clickHandler);
  36. toolbarButton.drawboard = drawboard;
  37. _this.toolbarUI.appendChild(toolbarButton.getElement());
  38. _this.toolbarButtons.push(toolbarButton);
  39. }
  40. _super.prototype.init.call(_this, _this.toolbarUI);
  41. interactjs_1.default('#drag-handler').draggable({
  42. onmove: _this.onDragMove
  43. });
  44. return _this.toolbarUI;
  45. };
  46. _this.onMouseDown = function (downEv) { };
  47. _this.onMouseUp = function (ev) { };
  48. _this.onMouseMove = function (ev) { };
  49. _this.onDragMove = function (event) {
  50. var target = _this.toolbarUI;
  51. var x = ((parseFloat(target.getAttribute('data-x')) || 0) + event.dx);
  52. var y = ((parseFloat(target.getAttribute('data-y')) || 0) + event.dy);
  53. target.style.webkitTransform = target.style.transform = 'translate(' + x + 'px, ' + y + 'px)';
  54. target.style.zIndex = "" + _this.zIndex;
  55. target.setAttribute('data-x', x);
  56. target.setAttribute('data-y', y);
  57. };
  58. _this.toolbarItems = [toolbar_items_1.dragToolbarItem].concat(toolbarItems);
  59. _this.clickHandler = clickHandler;
  60. return _this;
  61. }
  62. Object.defineProperty(Toolbar.prototype, "toolbarButtonMap", {
  63. get: function () {
  64. var buttonMap = {};
  65. this.toolbarButtons.forEach(function (b) {
  66. buttonMap[b.id] = b;
  67. });
  68. return buttonMap;
  69. },
  70. enumerable: true,
  71. configurable: true
  72. });
  73. Toolbar.prototype.hide = function () {
  74. this.toolbarUI.style.visibility = 'hidden';
  75. this.toolbarUI.style.zIndex = '-1';
  76. };
  77. Toolbar.prototype.show = function () {
  78. this.toolbarUI.style.visibility = 'visible';
  79. this.toolbarUI.style.zIndex = "" + this.zIndex;
  80. };
  81. return Toolbar;
  82. }(index_1.DomEventAware));
  83. exports.Toolbar = Toolbar;