MCPcopy Create free account
hub / github.com/ether/etherpad / bind

Method bind

src/static/js/pad_editbar.ts:66–92  ·  view source on GitHub ↗
(callback)

Source from the content-addressed store, hash-verified

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
95const syncAnimation = (() => {

Callers 15

localizeControlsMethod · 0.45
pad_userlist.tsFile · 0.45
pad_editor.tsFile · 0.45
initMethod · 0.45
Ace2EditorFunction · 0.45
PadUtilsClass · 0.45
l10n.tsFile · 0.45
pad_impexp.tsFile · 0.45
helper.jsFile · 0.45
initFunction · 0.45
setFakeClockFunction · 0.45
webaccess.tsFile · 0.45

Calls 6

isButtonMethod · 0.95
getCommandMethod · 0.95
isSelectMethod · 0.95
findMethod · 0.80
triggerMethod · 0.80
callbackFunction · 0.70

Tested by

no test coverage detected