PushPullTool.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * PushPullTool.js
  3. *
  4. * @author realor
  5. */
  6. import { Tool } from './Tool.js'
  7. import { I18N } from '../i18n/I18N.js'
  8. class PushPullTool extends Tool {
  9. constructor(application, options) {
  10. super(application)
  11. this.name = 'pushpull'
  12. this.label = 'tool.push.label'
  13. this.help = 'tool.push.help'
  14. this.className = 'pushpull'
  15. this.setOptions(options)
  16. this._onPointerUp = this.onPointerUp.bind(this)
  17. this.createPanel()
  18. }
  19. createPanel() {
  20. this.panel = this.application.createPanel(this.label, 'left')
  21. const helpElem = document.createElement('div')
  22. this.panel.bodyElem.appendChild(helpElem)
  23. this.posElem = document.createElement('div')
  24. this.posElem.style.textAlign = 'left'
  25. this.posElem.style.padding = '50px'
  26. this.panel.bodyElem.appendChild(this.posElem)
  27. I18N.set(this.panel.bodyElem, 'innerHTML', this.help)
  28. }
  29. activate() {
  30. this.panel.visible = true
  31. const application = this.application
  32. const container = application.container
  33. container.addEventListener('pointerup', this._onPointerUp, false)
  34. application.repaint()
  35. }
  36. deactivate() {
  37. this.panel.visible = false
  38. const application = this.application
  39. const container = application.container
  40. container.removeEventListener('pointerup', this._onPointerUp, false)
  41. }
  42. onPointerUp(event) {}
  43. }
  44. export { PushPullTool }