增加用户参数配置
parent
45b571cf29
commit
06bbc2c193
@ -1,4 +1,6 @@
|
||||
{
|
||||
"isekai-offcanvastoc-name": "Isekai Offcanvas TOC",
|
||||
"isekai-offcanvastoc-desc": "Show Offcanvas TOC on wiki"
|
||||
"isekai-offcanvastoc-desc": "Show Offcanvas TOC on wiki",
|
||||
"prefs-offcanvas-toc": "Offcanvas TOC",
|
||||
"offcanvas-toc-enabled": "Show offcanvas TOC"
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
{
|
||||
"isekai-offcanvastoc-name": "异世界百科 悬浮目录",
|
||||
"isekai-offcanvastoc-desc": "在页面上显示悬浮目录"
|
||||
"isekai-offcanvastoc-desc": "在页面上显示悬浮目录",
|
||||
"prefs-offcanvas-toc": "悬浮目录",
|
||||
"offcanvas-toc-enabled": "显示悬浮目录"
|
||||
}
|
@ -1,26 +1,43 @@
|
||||
<?php
|
||||
namespace Isekai\OffcanvasToc;
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Html;
|
||||
|
||||
class Hooks {
|
||||
public static function onLoad(\OutputPage $outputPage) {
|
||||
$outputPage->enableOOUI();
|
||||
$outputPage->addModules('ext.isekai.offcanvas-toc');
|
||||
$outputPage->addModules('oojs-ui.styles.icons-layout');
|
||||
$service = MediaWikiServices::getInstance();
|
||||
if (
|
||||
$outputPage->getTitle()->isContentPage() &&
|
||||
$service->getUserOptionsLookup()->getOption($outputPage->getUser(), 'offcanvas-toc-enabled')
|
||||
) {
|
||||
$outputPage->enableOOUI();
|
||||
$outputPage->addModules('ext.isekai.offcanvas-toc');
|
||||
$outputPage->addModules('oojs-ui.styles.icons-layout');
|
||||
|
||||
$outputPage->addHTML(Html::openElement('div', [
|
||||
'id' => 'isekai-offcanvas-toc',
|
||||
'class' => 'toc-offcanvas'
|
||||
]) . Html::element('ul') . Html::closeElement('div'));
|
||||
$outputPage->addHTML(Html::openElement('div', [
|
||||
'id' => 'isekai-offcanvas-toc',
|
||||
'class' => 'toc-offcanvas'
|
||||
]) . Html::element('ul') . Html::closeElement('div'));
|
||||
|
||||
$outputPage->addHTML(Html::openElement('button', [
|
||||
'id' => 'iseai-offcanvas-btn',
|
||||
'class' => 'toc-offcanvas-btn'
|
||||
]) . new \OOUI\IconWidget([
|
||||
'icon' => 'menu'
|
||||
]) . Html::closeElement('button'));
|
||||
$outputPage->addHTML(Html::openElement('button', [
|
||||
'id' => 'iseai-offcanvas-btn',
|
||||
'class' => 'toc-offcanvas-btn'
|
||||
]) . new \OOUI\IconWidget([
|
||||
'icon' => 'menu'
|
||||
]) . Html::closeElement('button'));
|
||||
|
||||
$outputPage->addElement('div', ['id' => 'isekai-offcanvas-cover', 'class' => 'toc-offcanvas-cover']);
|
||||
$outputPage->addElement('div', ['id' => 'isekai-offcanvas-cover', 'class' => 'toc-offcanvas-cover']);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onGetPreferences(\User $user, array &$preferences) {
|
||||
$preferences['offcanvas-toc-enabled'] = [
|
||||
'type' => 'toggle',
|
||||
'label-message' => 'offcanvas-toc-enabled',
|
||||
'section' => 'rendering/offcanvas-toc'
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue