Usuario:Hasley/vector.js

De Wikipedia, la enciclopedia libre

Nota: Después de guardar, debes refrescar la caché de tu navegador para ver los cambios. Internet Explorer: mantén presionada Ctrl mientras pulsas Actualizar. Firefox: mientras presionas Mayús pulsas el botón Actualizar, (o presiona Ctrl-Shift-R). Los usuarios de Google Chrome y Safari pueden simplemente pulsar el botón Recargar. Para más detalles e instrucciones acerca de otros exploradores, véase Ayuda:Cómo limpiar la caché.

// De https://en.wikipedia.org/wiki/MediaWiki:Gadget-defaultsummaries.js **mensajes predefinidos de w:en
/* global mediaWiki, ve */

( function ( $, mw ) { // Wrap with anonymous function
	var $summaryBox = $( '#wpSummary' ),
		minorSummaries = [
			'corrigiendo gramática/ortografía',
			'corrigiendo estilo',
			'[[A:RV|revirtiendo]] posible [[WP:VAN|vandalismo]]',
			'[[A:RV|revirtiendo]] contenido sin fuentes fidedignas',
			'suprimiendo contenido que podría violar los [[WP:DA|derechos de autor]] de'
		],
		articleSummaries = [
			'expandiendo artículo',
			'añadiendo/cambiando referencia(s)',
			'añadiendo/cambiando categoría(s)',
			'añadiendo/suprimiendo enlace(s) externo(s)',
			'añadiendo/suprimiendo hiperenlace(s)',
			'suprimiendo contenido sin fuentes',
			'suprimiendo [[WP:SPAM|spam]] en [[WP:EE|enlaces externos]]',
			'puliendo',
			'copyedit'
		],
		nonArticleSummaries = [
			're',
			'comentario',
			'sugerencia',
			'aviso al usuario',
			'notificación de [[WP:BR|borrado rápido]]'
		],
		talkPageSummaries = [
			'asignando página al [[Wikipedia:Wikiproyectos|wikiproyecto]]',
			'evaluando calidad para el [[Wikipedia:Wikiproyectos|wikiproyecto]]'
		];

	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 insertSummaryOptions( $insertBeforeThis, dropdownWidth ) {
		// 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: 'Resúmenes de ediciones comunes — usar'
			} ),
			minorDropdown = new OO.ui.DropdownWidget( {
				label: 'Resúmenes de ediciones menores comunes — usar'
			} );

		dropdown.$element.css( 'width', dropdownWidth );
		dropdown.menu.on( 'select', onSummarySelect );

		minorDropdown.$element.css( 'width', dropdownWidth );
		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 );
			}
		}

		$insertBeforeThis.before( dropdown.$element );
		$insertBeforeThis.before( minorDropdown.$element );
	}
	// VisualEditor
	mw.hook( 've.saveDialog.stateChanged' ).add( function () {
		var target, $saveOptions;
		// .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;
		}
		insertSummaryOptions( $saveOptions );
	} );
	// WikiEditor
	$.when( mw.loader.using( 'oojs-ui-core' ), $.ready ).then( function () {
		var $editCheckboxes = $( '.editCheckboxes' );

		// If we failed to find the editCheckboxes class
		if ( !$editCheckboxes.length ) {
			return;
		}
		insertSummaryOptions( $editCheckboxes, '48%' );
	} );
}( jQuery, mediaWiki ) ); // End wrap with anonymous function

// AutoVEC
mw.loader.load('//es.wikipedia.org/w/index.php?title=Usuario:Ezarate/AutoVEC.js&action=raw&ctype=text/javascript');

// botonera
importScript('MediaWiki:Gadget-botonera.js');