(callback)
| 64 | } |
| 65 | |
| 66 | bind(callback) { |
| 67 | if (this.isButton()) { |
| 68 | this.$el.on('click', (event) => { |
| 69 | // Stash the clicked button as the focus-restore target BEFORE we |
| 70 | // blur :focus — but only for dropdown-opening buttons. Non-dropdown |
| 71 | // commands (list toggles, bold, etc.) return focus to the ace editor |
| 72 | // and should not touch _lastTrigger (it would retain a stale |
| 73 | // reference and mess with later popup Esc-close focus handling). |
| 74 | const cmd = this.getCommand(); |
| 75 | // @ts-ignore — padeditbar is the exported singleton defined below |
| 76 | const isDropdownTrigger = exports.padeditbar.dropdowns.indexOf(cmd) !== -1; |
| 77 | if (isDropdownTrigger) { |
| 78 | const trigger = (this.$el.find('button')[0] as HTMLElement | undefined) || |
| 79 | (this.$el[0] as HTMLElement); |
| 80 | // @ts-ignore |
| 81 | if (trigger) exports.padeditbar._lastTrigger = trigger; |
| 82 | } |
| 83 | $(':focus').trigger('blur'); |
| 84 | callback(cmd, this); |
| 85 | event.preventDefault(); |
| 86 | }); |
| 87 | } else if (this.isSelect()) { |
| 88 | this.$el.find('select').on('change', () => { |
| 89 | callback(this.getCommand(), this); |
| 90 | }); |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | const syncAnimation = (() => { |
no test coverage detected