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

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

来自LLWiki
跳转到导航 跳转到搜索
标签移动版网页编辑 移动版编辑
(// 使用Wikiplus小工具快速编辑)
标签移动版网页编辑 移动版编辑
 
(未显示同一用户的14个中间版本)
第7行: 第7行:
"use strict";
"use strict";
/* global wgULS */
/* global wgULS */
// 用户贡献页面不可创建
$('.mw-usertoollinks-contribs.new').off( 'click' ).click(function(e) { e.stopImmediatePropagation(); });
mw.hook( 'wikipage.content' ).add(function( $content ) {
mw.hook( 'wikipage.content' ).add(function( $content ) {
// tabs-dropdown解析错误
const $collapsibleContent = $content.find( '.mw-collapsible:not(.mw-made-collapsible)' ),
$('.tabs-dropdown .tabs-content').append(function() { return $(this).next(); });
$sortableContent = $content.find( 'table.sortable' );
/**
* @Function: 折叠
* @Source: [[moegirl:Mediawiki:Mobile.js]]
*/
if ($collapsibleContent.length) {
console.log('Hook: wikipage.content,开始执行折叠');
mw.loader.using( 'jquery.makeCollapsible' ).then(function() { $collapsibleContent.makeCollapsible(); });
}
// 表格排序
if ($sortableContent.length) {
console.log('Hook: wikipage.content,开始执行表格排序');
mw.loader.using( 'jquery.tablesorter' ).then(function() { $sortableContent.tablesorter(); });
}
// tabs-dropdown解析错误
$('.tabs-dropdown .tabs-content').append(function() { return $(this).next(); });
});
});


if (['Recentchanges', 'Watchlist'].includes( mw.config.get( 'wgCanonicalSpecialPageName' ) )) {
$(function() {
// 修改filter
// 快速编辑工具
mw.hook( 'structuredChangeFilters.ui.initialized' ).add(function() {
if (['edit', 'submit'].includes( mw.config.get('wgAction') )) {
console.log('Hook: structuredChangeFilters.ui.initialized,开始修改filter');
$( '.mw-editTools' ).insertBefore( '#wpTextbox1' );
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()
if (mw.config.get( 'wgCanonicalSpecialPageName' ) == "Recentchanges") {
.insertAfter( $( '.mw-rcfilters-ui-filterMenuSectionOptionWidget' ).first() )
// 修改filter
.attr('id', 'ooui-invert').removeClass( 'oo-ui-element-hidden' )
mw.hook( 'structuredChangeFilters.ui.initialized' ).add(function() {
.on('click', function() {
console.log('Hook: structuredChangeFilters.ui.initialized,开始修改filter');
uri = new mw.Uri();
mw.loader.using( ['mediawiki.Uri', 'ext.gadget.site-lib'] ).then(function() {
invert = uri.query.invert || 0;
const uri = new mw.Uri(),
location.replace( uri.extend({ invert: 1 - invert }) );
invert = uri.query.invert || 0,
});
node = $( '.mw-rcfilters-ui-itemMenuOptionWidget-view-namespaces' ).first().clone()
node.find( 'span.oo-ui-labelElement-label' ).text( wgULS("排除选项", "排除所選") );
.insertAfter( $( '.mw-rcfilters-ui-filterMenuSectionOptionWidget' ).first() )
node.find( 'input' ).prop('checked', invert > 0)
.attr('id', 'ooui-invert').removeClass( 'oo-ui-element-hidden' )
.next().addClass( 'oo-ui-image-invert' );
.on('click', function() { window.location.href = 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' );
});
});
} else if (mw.config.get( 'wgCanonicalSpecialPageName' ) == 'MobileMenu') {
mw.hook( 'mobile.menu' ).fire( $('.menu') );
}

if (mw.config.get('skin') == 'minerva' && mw.config.get('wgAction') == 'view' && mw.config.get( 'wgIsArticle' ) &&
mw.config.get( 'wgPageContentModel' ) == 'wikitext') {
$('body').on('click', '.language-selector:not(.disabled)', function() {
console.log( 'setInterval: 等待内容语言选单加载完毕' );
const timerStart = mw.now(),
timer = setInterval(function() {
if ($( '.suggested-languages > li' ).length === 0) { return; }
clearInterval(timer);
console.log('End setInterval: 内容语言选单加载完毕,用时 ' +
(mw.now() - timerStart) + ' ms,开始移除不转换、简体和繁体选项');
$( '.suggested-languages' ).find('.zh, .zh-hans, .zh-hant').parent().remove();
}, 100);
});
}
}
//</nowiki>
//</nowiki>

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:*}}