mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-06 14:20:56 +00:00
Add a button to the chat settings menu to open the FFZ menu. Fix the chat width setting and theater mode.
This commit is contained in:
parent
24aac91258
commit
23e2fadba3
2 changed files with 78 additions and 11 deletions
65
src/sites/twitch-twilight/modules/chat/settings_menu.js
Normal file
65
src/sites/twitch-twilight/modules/chat/settings_menu.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
'use strict';
|
||||
|
||||
// ============================================================================
|
||||
// Chat Settings Menu
|
||||
// ============================================================================
|
||||
|
||||
import {createElement as e} from 'utilities/dom';
|
||||
import Module from 'utilities/module';
|
||||
|
||||
export default class SettingsMenu extends Module {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
|
||||
this.inject('settings');
|
||||
this.inject('i18n');
|
||||
this.inject('chat');
|
||||
this.inject('site.fine');
|
||||
this.inject('site.web_munch');
|
||||
|
||||
this.SettingsMenu = this.fine.define(
|
||||
'chat-settings',
|
||||
n => n.renderUniversalOptions && n.renderModTools
|
||||
);
|
||||
}
|
||||
|
||||
onEnable() {
|
||||
this.on('i18n:update', () => this.SettingsMenu.forceUpdate());
|
||||
|
||||
const t = this,
|
||||
React = this.web_munch.getModule('react');
|
||||
if ( ! React )
|
||||
return;
|
||||
|
||||
const e = React.createElement;
|
||||
|
||||
this.SettingsMenu.ready((cls, instances) => {
|
||||
const old_universal = cls.prototype.renderUniversalOptions;
|
||||
|
||||
cls.prototype.renderUniversalOptions = function() {
|
||||
const val = old_universal.call(this);
|
||||
val.props.children.push(e('div', {
|
||||
className: 'mg-t-1'
|
||||
}, e('button', {
|
||||
onClick: () => t.click(this)
|
||||
}, t.i18n.t('site.menu_button', 'FrankerFaceZ Control Center'))
|
||||
));
|
||||
|
||||
window.menu = this;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
this.SettingsMenu.forceUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
click(inst) {
|
||||
const mb = this.resolve('site.menu_button');
|
||||
if ( mb )
|
||||
mb.emit(':clicked');
|
||||
|
||||
const parent = this.fine.searchParent(inst, n => n.toggleBalloonId);
|
||||
parent && parent.handleButtonClick();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue