MediaWiki:Gadget-defaultsummaries.js:修订间差异

勤求古训,博采众方
删除的内容 添加的内容
创建页面,内容为“/* _____________________________________________________________________________ * | | * | === WARNING: GLOBAL GADGET FILE === | * | Changes to this page affect many users. | * | Please discuss changes on the talk page or on WT:Gadget before editing. | * |_______________________________________________…”
 
无编辑摘要
第22行: 第22行:
'回退破坏或测试编辑',
'回退破坏或测试编辑',
'回退无法解释的内容删除',
'回退无法解释的内容删除',
'修改(轻微)'
'修改(小编辑)'
],
],
articleSummaries = [
articleSummaries = [
'扩展文章',
'扩展文章',
'添加/改进参考资料',
'添加/改进参考资料',
'Adding/removing wikilink(s)',
'添加/删除维基链接',
'Clean up/copyedit',
'清理/修改',
'Adding/removing category/ies',
'添加/删除类别',
'添加/删除外部链接',
'Adding/removing external link(s)',
'删除无源内容'
'Removing unsourced content'
],
],
nonArticleSummaries = [
nonArticleSummaries = [
'Reply',
'回复',
'Comment',
'注释',
'Suggestion'
'建议'
],
],
talkPageSummaries = [
talkPageSummaries = [
第69行: 第69行:
var namespace = mw.config.get( 'wgNamespaceNumber' ),
var namespace = mw.config.get( 'wgNamespaceNumber' ),
dropdown = new OO.ui.DropdownWidget( {
dropdown = new OO.ui.DropdownWidget( {
label: 'Common edit summaries click to use'
label: '通用编辑摘要单击以使用'
} ),
} ),
minorDropdown = new OO.ui.DropdownWidget( {
minorDropdown = new OO.ui.DropdownWidget( {
label: 'Common minor edit summaries click to use'
label: '常见小编辑摘要单击使用'
} );
} );



2022年12月10日 (六) 17:47的版本

/*  _____________________________________________________________________________
 * |                                                                             |
 * |                    === WARNING: GLOBAL GADGET FILE ===                      |
 * |                  Changes to this page affect many users.                    |
 * | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. |
 * |_____________________________________________________________________________|
 *
 * Imported as of 09/06/2011 from [[User:ErrantX/defaultsummaries.js]]
 * Edited version from [[User:MC10/defaultsummaries.js]]
 * Implements default edit summary dropdown boxes
 */

/* global mw, ve */

/* eslint-disable no-jquery/no-global-selector */

( function () { // Wrap with anonymous function
	var $summaryBox = $( '#wpSummary' ),
		minorSummaries = [
			'拼写/语法/标点符号/排版更正',
			'修复样式/布局错误',
			'回退破坏或测试编辑',
			'回退无法解释的内容删除',
			'修改(小编辑)'
		],
		articleSummaries = [
			'扩展文章',
			'添加/改进参考资料',
			'添加/删除维基链接',
			'清理/修改',
			'添加/删除类别',
			'添加/删除外部链接',
			'删除无源内容'
		],
		nonArticleSummaries = [
			'回复',
			'注释',
			'建议'
		],
		talkPageSummaries = [
			'[[Wikipedia:WikiProject|WikiProject]] tagging',
			'[[Wikipedia:WikiProject|WikiProject]] assessment'
		];

	function addOptionsToDropdown( dropdown, optionTexts ) {
		dropdown.menu.addItems( optionTexts.map( function ( optionText ) {
			return new OO.ui.MenuOptionWidget( { label: optionText } );
		} ) );
	}

	function onSummarySelect( option ) {
		// Save the original value of the edit summary field
		var editsummOriginalSummary = $summaryBox.val(),
			canned = option.getLabel(),
			newSummary = editsummOriginalSummary;

		// Append old edit summary with space, if exists,
		// and last character != space
		if ( newSummary.length !== 0 && newSummary.charAt( newSummary.length - 1 ) !== ' ' ) {
			newSummary += ' ';
		}
		newSummary += canned;
		$summaryBox.val( newSummary ).trigger( 'change' );
	}

	function getSummaryDropdowns() {
		// For convenience, add a dropdown box with some canned edit
		// summaries to the form.
		var namespace = mw.config.get( 'wgNamespaceNumber' ),
			dropdown = new OO.ui.DropdownWidget( {
				label: '通用编辑摘要–单击以使用'
			} ),
			minorDropdown = new OO.ui.DropdownWidget( {
				label: '常见小编辑摘要–单击使用'
			} );

		dropdown.menu.on( 'select', onSummarySelect );
		minorDropdown.menu.on( 'select', onSummarySelect );

		addOptionsToDropdown( minorDropdown, minorSummaries );

		if ( namespace === 0 ) {
			addOptionsToDropdown( dropdown, articleSummaries );
		} else {
			addOptionsToDropdown( dropdown, nonArticleSummaries );
			if ( namespace % 2 !== 0 && namespace !== 3 ) {
				addOptionsToDropdown( dropdown, talkPageSummaries );
			} else if (namespace === 118 ) {
				addOptionsToDropdown( dropdown, articleSummaries );
			}
		}
		return dropdown.$element.add( minorDropdown.$element );
	}
	// VisualEditor
	mw.hook( 've.saveDialog.stateChanged' ).add( function () {
		var target, $saveOptions, $dropdowns;
		// .ve-init-mw-viewPageTarget-saveDialog-checkboxes
		if ( $( 'body' ).data( 'wppresent' ) ) {
			return;
		}
		$( 'body' ).data( 'wppresent', 'true' );

		target = ve.init.target;
		$saveOptions = target.saveDialog.$saveOptions;
		$summaryBox = target.saveDialog.editSummaryInput.$input;
		if ( !$saveOptions.length ) {
			return;
		}
		$dropdowns = getSummaryDropdowns();
		$saveOptions.before( $dropdowns );
	} );
	// WikiEditor
	$.when( mw.loader.using( 'oojs-ui-core' ), $.ready ).then( function () {
		var $dropdowns,
			$editCheckboxes = $( '.editCheckboxes' );

		// If we failed to find the editCheckboxes class
		if ( !$editCheckboxes.length ) {
			return;
		}
		$dropdowns = getSummaryDropdowns();
		$dropdowns.css( {
			width: '48%',
			'padding-bottom': '1em'
		} );
		$editCheckboxes.before( $dropdowns );
	} );
}() );