mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-10-14 06:51:58 +00:00
Improve support for interactive tooltips. Allow chat tokenizers to supply custom delays and interactive flags for their tooltips. Wrap text in <span> elements. Fix bug with stream uptime metadata. Fix bug with fine-router. Add method to EventEmitter that wraps emit in a try/catch. Add lilz to the socket server lineup.
This commit is contained in:
parent
c0320dd3ab
commit
a081247fdc
14 changed files with 168 additions and 40 deletions
|
@ -52,14 +52,14 @@ export default class FineRouter extends Module {
|
|||
this.log.debug('Matching Route', route, match);
|
||||
this.current = route;
|
||||
this.match = match;
|
||||
this.emit(':route', route, match);
|
||||
this.emit(`:route:${route.name}`, ...match);
|
||||
this.emitSafe(':route', route, match);
|
||||
this.emitSafe(`:route:${route.name}`, ...match);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.current = this.match = null;
|
||||
this.emit(':route', null, null);
|
||||
this.emitSafe(':route', null, null);
|
||||
}
|
||||
|
||||
route(name, path) {
|
||||
|
|
|
@ -9,7 +9,8 @@ export const WS_CLUSTERS = {
|
|||
Production: [
|
||||
['wss://catbag.frankerfacez.com/', 0.25],
|
||||
['wss://andknuckles.frankerfacez.com/', 1],
|
||||
['wss://tuturu.frankerfacez.com/', 1]
|
||||
['wss://tuturu.frankerfacez.com/', 1],
|
||||
['wss://lilz.frankerfacez.com/', 1]
|
||||
],
|
||||
|
||||
Development: [
|
||||
|
|
|
@ -160,6 +160,15 @@ export class EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
emitSafe(event, ...args) {
|
||||
try {
|
||||
return [this.emit(event, ...args), undefined];
|
||||
|
||||
} catch(err) {
|
||||
return [null, err];
|
||||
}
|
||||
}
|
||||
|
||||
emitAsync(event, ...args) {
|
||||
const list = this.__listeners[event];
|
||||
if ( ! list )
|
||||
|
|
|
@ -123,55 +123,60 @@ export class Tooltip {
|
|||
|
||||
|
||||
_enter(target) {
|
||||
let tip = target[this._accessor],
|
||||
delay = this.options.delayShow;
|
||||
|
||||
let tip = target[this._accessor];
|
||||
if ( ! tip )
|
||||
tip = target[this._accessor] = {target};
|
||||
|
||||
tip.state = true;
|
||||
|
||||
if ( tip._show_timer ) {
|
||||
clearTimeout(tip._show_timer);
|
||||
tip._show_timer = null;
|
||||
}
|
||||
|
||||
if ( tip.visible )
|
||||
return;
|
||||
|
||||
const delay = maybe_call(this.options.delayShow, null, target, tip);
|
||||
|
||||
if ( delay === 0 )
|
||||
this.show(tip);
|
||||
|
||||
else {
|
||||
if ( tip._show_timer )
|
||||
clearTimeout(tip._show_timer);
|
||||
|
||||
else
|
||||
tip._show_timer = setTimeout(() => {
|
||||
tip._show_timer = null;
|
||||
if ( tip.state )
|
||||
this.show(tip);
|
||||
}, delay);
|
||||
}
|
||||
}
|
||||
|
||||
_exit(target) {
|
||||
const tip = target[this._accessor];
|
||||
if ( ! tip || ! tip.visible )
|
||||
if ( ! tip )
|
||||
return;
|
||||
|
||||
const delay = this.options.delayHide;
|
||||
tip.state = false;
|
||||
|
||||
tip.state = false;
|
||||
if ( tip._show_timer ) {
|
||||
clearTimeout(tip._show_timer);
|
||||
tip._show_timer = null;
|
||||
}
|
||||
|
||||
if ( ! tip.visible )
|
||||
return;
|
||||
|
||||
const delay = maybe_call(this.options.delayHide, null, target, tip);
|
||||
|
||||
if ( delay === 0 )
|
||||
this.hide(tip);
|
||||
|
||||
else {
|
||||
if ( tip._show_timer )
|
||||
clearTimeout(tip._show_timer);
|
||||
|
||||
else
|
||||
tip._show_timer = setTimeout(() => {
|
||||
tip._show_timer = null;
|
||||
if ( ! tip.state )
|
||||
this.hide(tip);
|
||||
|
||||
}, delay);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -207,11 +212,20 @@ export class Tooltip {
|
|||
|
||||
arrow.setAttribute('x-arrow', true);
|
||||
|
||||
if ( maybe_call(opts.interactive, null, target, tip) ) {
|
||||
el.classList.add('interactive');
|
||||
el.addEventListener('mouseover', () => this._enter(target));
|
||||
el.addEventListener('mouseout', () => this._exit(target));
|
||||
}
|
||||
const interactive = maybe_call(opts.interactive, null, target, tip);
|
||||
el.classList.toggle('interactive', interactive || false);
|
||||
|
||||
el.addEventListener('mouseover', () => {
|
||||
if ( ! document.contains(target) )
|
||||
this.hide(tip);
|
||||
|
||||
else if ( maybe_call(opts.interactive, null, target, tip) )
|
||||
this._enter(target);
|
||||
else
|
||||
this._exit(target);
|
||||
});
|
||||
|
||||
el.addEventListener('mouseout', () => this._exit(target));
|
||||
|
||||
// Assign our content. If there's a Promise, we'll need
|
||||
// to do this weirdly.
|
||||
|
@ -219,7 +233,7 @@ export class Tooltip {
|
|||
setter = use_html ? 'innerHTML' : 'textContent';
|
||||
|
||||
const pop_opts = Object.assign({
|
||||
arrowElement: arrow,
|
||||
arrowElement: arrow
|
||||
}, opts.popper);
|
||||
|
||||
tip._update = () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue