رُکُن:Ratekreel/editSummary.js

وِکیٖپیٖڈیا پؠٹھٕ، اَکھ آزاد اِنسایکلوپیٖڈیا

نوٹ: شایع کَرنہٕ پَتہ یِم تبدیلی وُچِھنہٕ خٲطرٕ کٔرِو براؤزرُک کیش (cache) صاف۔

  • فائرفاکس/ سفاری: ییلہ Reload پؠٹھ کلِک کٔرِو تہٕ Shift تھٲوِو دَبٲیِتھ، یا Ctrl-F5 یا Ctrl-R دَبٲیِو (Mac پؠٹھ R-⌘)
  • گوٗگُل کروم: Ctrl-Shift-R دَبٲیِو (Mac پؠٹھ Shift-R-⌘)
  • اِنٹَرنیٹ ایکسپلورَر: ییلہ Refresh پؠٹھ کِلِک کٔرِو Ctrl یا Ctrl-F5 تھٲوِو دَبٲیِتھ
  • اوپیرا: Tools → Preferences مَنٛز گٔژھو تہٕ کیش (cache) کٔرِو صاف
/*
 * Imported as of 09/06/2011 from [[User:ErrantX/defaultsummaries.js]]
 * Edited version from [[User:MC10/defaultsummaries.js]]
 * Implements default edit summary dropdown boxes
 * Imported from English Wikipedia version https://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-defaultsummaries.js&oldid=1083753517
 */

/* global mw, ve */

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

( function () { // Wrap with anonymous function
	var $summaryBox = $( '#wpSummary' ),
		minorSummaries = [
			'گرٛامَر آو ٹھیٖک کَرنہٕ',
			'طَرٕز غَلطی آے ٹھیٖک کَرنہٕ',
			'[[Help:Reverting|Reverting]] [[Wikipedia:Vandalism|vandalism]] or test edit',
			'[[Help:Reverting|Reverting]] unexplained content removal',
			'صَفٲیی'
		],
		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: '1 - عآم اؠڈِٹ خُلاسہٕ'
			} ),
			minorDropdown = new OO.ui.DropdownWidget( {
				label: 'عام اؠڈِٹ خُلاسہٕ - 2'
			} );

		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 );
	} );
}() );