“MediaWiki:Gadget-site-shared.js”的版本间差异

删除282字节 、​ 2021年6月22日 (二) 05:43
修正下载首页样式的判别
(修正下载首页样式的判别)
const pagename = mw.config.get( 'wgPageName' ),
action = mw.config.get( 'wgAction' ),
specialPage = mw.config.get( 'wgCanonicalSpecialPageName' );,
hook = mw.hook( 'wikipage.content' );
 
/**
// 这个事件不能重复添加,但#editform可能会重建
$('#bodyContent').on('click', 'span.mw-charinsert-item', function() {
$('#wpTextbox1').textSelection( 'encapsulateSelection', {pre: this.dataset.start, post: this.dataset.end} );
const $this = $(this);
$('#wpTextbox1').textSelection( 'encapsulateSelection', {
pre: $this.data( 'mw-charinsert-start' ) || $this.data( 'start' ), // undefined也没关系
post: $this.data( 'mw-charinsert-end' ) || $this.data( 'end' )
} );
});
* @Dependencies: mediawiki.Title
*/
mw.hook( 'wikipage.content' ).add(function($content) { // 必须立即解决,否则手机版会生成drawer
console.log('Hook: wikipage.content, 开始处理其他用户主页面的红链');
$content.find( '.new' ).attr('href', function(i_, val) {
const query = mw.util.getParamValue('title', val);
if (!query) { return; } // 特殊页面
* @Function: 正确显示[[特殊:前缀索引/LLWiki:首页/当年今日/]]
*/
// 非管理员不需要关心未创建的页面
if (pagename.startsWith( 'LLWiki:首页/当年今日/' ) && action == 'view') {&&
// 非管理员不需要关心未创建的页面
var downloaded = (mw.config.get( 'wgArticleId' ) ===> 0 &&|| !mw.config.get( 'wgUserGroups' ).includes( 'sysop' );)) {
mw.hook(const 'wikipage.content'download = ).add(function($content) {
if ($('#mainpage-style').length) { return; } // 避免不必要的下载
const $output = $content.children( '.mw-parser-output' ).addClass( 'mainpage-flex' );
// 避免不必要的下载。注意:contains选择器里不能有多余的空格。
if ($output.find( 'style:contains(mainpage)' ).length || downloaded) { return; }
console.log('Hook: wikipage.content, 开始下载主页样式表');
mw.loader.load( '//cdn.jsdelivr.net/gh/bhsd-harry/LLWiki@1.4/widget/mainpage.min.css', 'text/css' );
downloadedhook.remove( =download true);
});
hook.add( download )
const .add(function($outputcontent) ={ $content.children( '.mw-parser-output' ).addClass( 'mainpage-flex' ); });
}
 
*/
if (matchMedia( 'screen and (hover: none)' ).matches) {
mw.hook( 'wikipage.content' ).add(function($content) {
console.log('Hook: wikipage.content, 开始移除gallery的hover效果');
$content.find( '.mw-gallery-packed-hover ' ).toggleClass( 'mw-gallery-packed-hover mw-gallery-packed' );
16,874

个编辑