MediaWiki:Gadget-edit0.js:修订间差异
外观
删除的内容 添加的内容
创建页面,内容为“// en:MediaWiki:Gadget-edittop.js // ********************************************************************** // ** ***WARNING GLOBAL GADGET FILE*** ** // ** changes to this file affect many users. ** // ** please discuss on the talk page before editing ** // ** ** // ******************************************************…” |
小无编辑摘要 |
||
| 第1行: | 第1行: | ||
| ⚫ | |||
// ********************************************************************** |
// ********************************************************************** |
||
// ** ***WARNING GLOBAL GADGET FILE*** ** |
// ** ***WARNING GLOBAL GADGET FILE*** ** |
||
// ** changes to this file affect many users. ** |
// ** changes to this file affect many users. ** |
||
// ** please discuss on the talk page before editing ** |
// ** please discuss on the talk page before editing ** |
||
// ** ** |
// ** ** |
||
| ⚫ | |||
// 本地化改良:仅保留中英日三语种,新增按钮显示文字+自动编辑摘要,保留全部官方兼容修复 |
|||
// ********************************************************************** |
// ********************************************************************** |
||
// Imported from [[ |
// Imported from [[User:Alex Smotrov/edittop.js]], version as of: 2007-06-19T04:28:52 |
||
// Updated from [[ |
// Updated from [[User:TheDJ/Gadget-edittop.js]], version as of: 2009-04-28T11:54:22 |
||
// |
// Localized only for zh/zh-cn/zh-hans/zh-hant/en/ja, add lead edit summary |
||
if ($.inArray(mw.config.get('wgAction'), ['view', 'purge']) !== -1 && mw.config.get('wgNamespaceNumber') >= 0) { |
|||
| ⚫ | |||
| ⚫ | |||
'zh': '编辑首段', // 通用中文 |
|||
'zh-cn': '编辑首段', // 中国大陆简体 |
|||
'hans': '编辑首段', // 简体中文(通用,作为默认) |
|||
'hant': '編輯首段' // 繁体中文(通用) |
|||
}; |
|||
if ( |
|||
var our_content = $('#content, #mw_content').first(); |
|||
[ 'view', 'purge' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 && |
|||
| ⚫ | |||
mw.config.get( 'wgNamespaceNumber' ) >= 0 && |
|||
| ⚫ | |||
!mw.config.get( 'wgMFMode' ) // WMF官方修复:移动端Minerva禁用,避免重复按钮 |
|||
| ⚫ | |||
) { |
|||
| ⚫ | |||
| ⚫ | |||
'en': 'Edit lead section', |
|||
'ja': '導入部を編集', |
|||
'zh': '编辑首段', |
|||
'zh-cn': '编辑首段', |
|||
'zh-hans': '编辑首段', |
|||
'zh-hant': '編輯首段' |
|||
}; |
|||
var $content = $( '#content, #mw_content' ).first(); |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
return; |
|||
| ⚫ | |||
} |
|||
| ⚫ | |||
// WMF官方修复:移除CDX大按钮样式,适配Vector 2022 |
|||
$span0.removeClass( 'cdx-button--size-large' ); |
|||
$( '#mw_header h1, #content h1' ).first().append( $span0 ); |
|||
// 获取用户语言,优先匹配精确键,再匹配 hans/hant 前缀,默认使用 hans |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
(userLang.indexOf('hans') !== -1 ? localtitles.hans : '') || |
|||
// 匹配对应语言文案,兜底英文 |
|||
(userLang.indexOf('hant') !== -1 ? localtitles.hant : '') || |
|||
| ⚫ | |||
localtitles.hans; // 最终 fallback 到简体中文(hans) |
|||
// 悬浮提示 + 按钮显示文字 |
|||
a.text(linkText); |
|||
$a.attr( 'title', textLabel ); |
|||
$a.text( textLabel ); |
|||
| ⚫ | |||
if (!/&(ve|)section=T/.test(href)) { |
|||
// 上游原版分支逻辑完整保留 |
|||
a.attr('href', href.replace(/&(ve|)section=\d+/, '&$1section=0&summary=/*%20top%20*/%20')); |
|||
if ( !/&(ve|)section=T/.test( href ) ) { // 非嵌入页面 |
|||
$a.attr( 'href', href.replace( /&(ve|)section=\d+/, '&$1section=0&summary=/*%20top%20*/%20' ) ); |
|||
} else if ( /&vesection=/.test( href ) ) { // 嵌入页面 - VE可视化编辑器 |
|||
} else { |
|||
$a.attr( 'href', mw.util.getUrl( mw.config.get( 'wgPageName' ) ) + '?veaction=edit&vesection=0&summary=/*%20top%20*/%20' ); |
|||
} else { // 嵌入页面 - 传统编辑器 |
|||
} |
|||
$a.attr( 'href', mw.util.getUrl( mw.config.get( 'wgPageName' ) ) + '?action=edit§ion=0&summary=/*%20top%20*/%20' ); |
|||
}); |
|||
} |
|||
}); |
|||
} ); |
|||
} ); |
|||
} |
} |
||
2026年6月16日 (二) 20:02的最新版本
// **********************************************************************
// ** ***WARNING GLOBAL GADGET FILE*** **
// ** changes to this file affect many users. **
// ** please discuss on the talk page before editing **
// ** **
// 上游基准:enwiki MediaWiki:Gadget-edittop.js 2026-05-13 最新版
// 本地化改良:仅保留中英日三语种,新增按钮显示文字+自动编辑摘要,保留全部官方兼容修复
// **********************************************************************
// Imported from [[User:Alex Smotrov/edittop.js]], version as of: 2007-06-19T04:28:52
// Updated from [[User:TheDJ/Gadget-edittop.js]], version as of: 2009-04-28T11:54:22
// Localized only for zh/zh-cn/zh-hans/zh-hant/en/ja, add lead edit summary
if (
[ 'view', 'purge' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 &&
mw.config.get( 'wgNamespaceNumber' ) >= 0 &&
!mw.config.get( 'wgMFMode' ) // WMF官方修复:移动端Minerva禁用,避免重复按钮
) {
$( function edittopHook() {
var localtitles = {
'en': 'Edit lead section',
'ja': '導入部を編集',
'zh': '编辑首段',
'zh-cn': '编辑首段',
'zh-hans': '编辑首段',
'zh-hant': '編輯首段'
};
var $content = $( '#content, #mw_content' ).first();
var $span1 = $content.find( 'span.mw-editsection:not(.plainlinks)' ).first();
if ( !$span1.length ) {
return;
}
var $span0 = $span1.clone();
// WMF官方修复:移除CDX大按钮样式,适配Vector 2022
$span0.removeClass( 'cdx-button--size-large' );
$( '#mw_header h1, #content h1' ).first().append( $span0 );
$span0.find( 'a' ).each( function () {
var $a = $( this ), href;
var userLang = mw.config.get( 'wgUserLanguage' );
// 匹配对应语言文案,兜底英文
var textLabel = localtitles[ userLang ] || localtitles.en;
// 悬浮提示 + 按钮显示文字
$a.attr( 'title', textLabel );
$a.text( textLabel );
href = $a.attr( 'href' ) || '#';
// 上游原版分支逻辑完整保留
if ( !/&(ve|)section=T/.test( href ) ) { // 非嵌入页面
$a.attr( 'href', href.replace( /&(ve|)section=\d+/, '&$1section=0&summary=/*%20top%20*/%20' ) );
} else if ( /&vesection=/.test( href ) ) { // 嵌入页面 - VE可视化编辑器
$a.attr( 'href', mw.util.getUrl( mw.config.get( 'wgPageName' ) ) + '?veaction=edit&vesection=0&summary=/*%20top%20*/%20' );
} else { // 嵌入页面 - 传统编辑器
$a.attr( 'href', mw.util.getUrl( mw.config.get( 'wgPageName' ) ) + '?action=edit§ion=0&summary=/*%20top%20*/%20' );
}
} );
} );
}