MCPcopy
hub / github.com/iChochy/NCE / updateTranslationToggle

Method updateTranslationToggle

js/ReadingSystem.js:828–852  ·  view source on GitHub ↗

* 更新翻译切换 UI

()

Source from the content-addressed store, hash-verified

826 * 更新翻译切换 UI
827 */
828 updateTranslationToggle() {
829 if (!this.dom.toggleTranslationBtn) return;
830
831 const mode = this.state.translationMode;
832 toggleClass(document.body, 'hide-translation', mode === 'hide');
833 toggleClass(document.body, 'blur-translation', mode === 'blur');
834
835 let text = '中';
836 let pressed = 'true';
837 let label = '翻译显示';
838
839 if (mode === 'blur') {
840 text = '糊';
841 pressed = 'mixed';
842 label = '翻译模糊显示';
843 } else if (mode === 'hide') {
844 text = '英';
845 pressed = 'false';
846 label = '仅显示英文';
847 }
848
849 setText(this.dom.toggleTranslationBtn, text);
850 this.dom.toggleTranslationBtn.setAttribute('aria-pressed', pressed);
851 this.dom.toggleTranslationBtn.setAttribute('aria-label', label);
852 }
853
854 // =========================================================================
855 // 资源预加载

Callers 2

initMethod · 0.95
toggleTranslationModeMethod · 0.95

Calls 2

toggleClassFunction · 0.90
setTextFunction · 0.90

Tested by

no test coverage detected