LLWiki正在建设中,欢迎加入我们

“MediaWiki:Mobile.js”的版本间差异

来自LLWiki
跳转到导航 跳转到搜索
(// 使用Wikiplus小工具快速编辑)
标签移动版网页编辑 移动版编辑
 
(未显示2个用户的100个中间版本)
第1行: 第1行:
//<nowiki>
/* 这里的任何JavaScript将为使用移动版网站的用户加载 */
// 由ResourceLoader直接调用,不可使用ES6语法
/**
* @Description: 手机版全局JS
* @Author: 如无特殊说明,均为[[User:Bhsd]]
*/
"use strict";
/* global wgULS */
mw.hook( 'wikipage.content' ).add(function( $content ) {
// tabs-dropdown解析错误
$('.tabs-dropdown .tabs-content').append(function() { return $(this).next(); });
});


if (['Recentchanges', 'Watchlist'].includes( mw.config.get( 'wgCanonicalSpecialPageName' ) )) {
/* Add to MediaWiki:Mobile.js for custom Mobile Menu links
// 修改filter
for MW-1.34.2 with MobileFrontend and MinervaNeue
mw.hook( 'structuredChangeFilters.ui.initialized' ).add(function() {
Just replace span text and href to add links */
console.log('Hook: structuredChangeFilters.ui.initialized,开始修改filter');

mw.loader.using( ['mediawiki.Uri', 'ext.gadget.site-lib'] ).then(function() {
var recentchanges = '最近更改', sandbox = '沙盒', villagepump = '互助客栈', policy = '方针', help = '帮助';
var uri = new mw.Uri(),
switch(mw.config.get('wgUserLanguage')) {
invert = uri.query.invert || 0;
case 'zh-hant':
const node = $( '.mw-rcfilters-ui-itemMenuOptionWidget-view-namespaces' ).first().clone()
case 'zh-hk':
.insertAfter( $( '.mw-rcfilters-ui-filterMenuSectionOptionWidget' ).first() )
case 'zh-mo':
.attr('id', 'ooui-invert').removeClass( 'oo-ui-element-hidden' )
case 'zh-tw':
.on('click', function() {
recentchanges = '近期變更';
uri = new mw.Uri();
villagepump = '互助客棧';
invert = uri.query.invert || 0;
policy = '方針';
location.replace( uri.extend({ invert: 1 - invert }) );
help = '幫助';
break;
});
node.find( 'span.oo-ui-labelElement-label' ).text( wgULS("排除选项", "排除所選") );
node.find( 'input' ).prop('checked', invert > 0)
.next().addClass( 'oo-ui-image-invert' );
});
});
}
}
//</nowiki>
// [[category:作为模块的小工具]] [[category:不可关闭的小工具]] [[category:手机版小工具]]
var timer = setInterval(function() {
// {{DEFAULTSORT:*}}
if ($('.menu ul:first').length) {
console.log("mobile menu exists");
clearInterval(timer);
$('.menu ul:first').append('<li><a href="/zh/special:recentchanges" class="mw-ui-icon mw-ui-icon-before"><span>' + recentchanges + '</span></a></li><li><a href="/zh/project:沙盒" class="mw-ui-icon mw-ui-icon-before"><span>' + sandbox + '</span></a></li><li><a href="/zh/project:互助客栈" class="mw-ui-icon mw-ui-icon-before"><span>' + villagepump + '</span></a></li><li><a href="/zh/project:方针" class="mw-ui-icon mw-ui-icon-before"><span>' + policy + '</span></a></li><li><a href="/zh/help:帮助总览" class="mw-ui-icon mw-ui-icon-before"><span>' + help + '</span></a></li>');
}
}, 100); // check every 100ms

2023年3月17日 (五) 13:28的最新版本

//<nowiki>
// 由ResourceLoader直接调用,不可使用ES6语法
/**
 * @Description: 手机版全局JS
 * @Author: 如无特殊说明,均为[[User:Bhsd]]
 */
"use strict";
/* global wgULS */
mw.hook( 'wikipage.content' ).add(function( $content ) {
	// tabs-dropdown解析错误
	$('.tabs-dropdown .tabs-content').append(function() { return $(this).next(); });
});

if (['Recentchanges', 'Watchlist'].includes( mw.config.get( 'wgCanonicalSpecialPageName' ) )) {
	// 修改filter
	mw.hook( 'structuredChangeFilters.ui.initialized' ).add(function() {
		console.log('Hook: structuredChangeFilters.ui.initialized,开始修改filter');
		mw.loader.using( ['mediawiki.Uri', 'ext.gadget.site-lib'] ).then(function() {
			var uri = new mw.Uri(),
				invert = uri.query.invert || 0;
			const node = $( '.mw-rcfilters-ui-itemMenuOptionWidget-view-namespaces' ).first().clone()
				.insertAfter( $( '.mw-rcfilters-ui-filterMenuSectionOptionWidget' ).first() )
				.attr('id', 'ooui-invert').removeClass( 'oo-ui-element-hidden' )
				.on('click', function() {
				uri = new mw.Uri();
				invert = uri.query.invert || 0;
				location.replace( uri.extend({ invert: 1 - invert }) );
			});
			node.find( 'span.oo-ui-labelElement-label' ).text( wgULS("排除选项", "排除所選") );
			node.find( 'input' ).prop('checked', invert > 0)
				.next().addClass( 'oo-ui-image-invert' );
		});
	});
}
//</nowiki>
// [[category:作为模块的小工具]] [[category:不可关闭的小工具]] [[category:手机版小工具]]
// {{DEFAULTSORT:*}}