Update float message handlers
This commit is contained in:
parent
a2263e5729
commit
5588643988
@ -48,12 +48,11 @@ class DisplayFloat extends Display {
|
||||
|
||||
onMessage(e) {
|
||||
const {action, params} = e.data;
|
||||
const handlers = DisplayFloat.messageHandlers;
|
||||
if (hasOwn(handlers, action)) {
|
||||
const handler = handlers[action];
|
||||
const handler = DisplayFloat._messageHandlers.get(action);
|
||||
if (typeof handler !== 'function') { return; }
|
||||
|
||||
handler(this, params);
|
||||
}
|
||||
}
|
||||
|
||||
onKeyDown(e) {
|
||||
const key = Display.getKeyFromEvent(e);
|
||||
@ -107,11 +106,11 @@ DisplayFloat.onKeyDownHandlers = {
|
||||
}
|
||||
};
|
||||
|
||||
DisplayFloat.messageHandlers = {
|
||||
setContent: (self, {type, details}) => self.setContent(type, details),
|
||||
clearAutoPlayTimer: (self) => self.clearAutoPlayTimer(),
|
||||
setCustomCss: (self, {css}) => self.setCustomCss(css),
|
||||
initialize: (self, {options, popupInfo, url, childrenSupported}) => self.initialize(options, popupInfo, url, childrenSupported)
|
||||
};
|
||||
DisplayFloat._messageHandlers = new Map([
|
||||
['setContent', (self, {type, details}) => self.setContent(type, details)],
|
||||
['clearAutoPlayTimer', (self) => self.clearAutoPlayTimer()],
|
||||
['setCustomCss', (self, {css}) => self.setCustomCss(css)],
|
||||
['initialize', (self, {options, popupInfo, url, childrenSupported}) => self.initialize(options, popupInfo, url, childrenSupported)]
|
||||
]);
|
||||
|
||||
window.yomichan_display = new DisplayFloat();
|
||||
|
Loading…
Reference in New Issue
Block a user