Diferencia entre revisiones de «MediaWiki:Gadget-Versalitas.js»

De EIFA - Estudios Interdisciplinares de las Fuentes Avilistas
Etiqueta: Revertido
(Se ha deshecho la revisión 679 de Juancc (disc.))
Etiqueta: Deshacer
 
(No se muestran 36 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
/**
ve.ui.VersalitasCommand = function VeUiVersalitasCommand() {
* Adds direction mark tool to VE (for adding RLM)
ve.ui.VersalitasCommand.super.call( this, 'Versalitas' );
*/
};
(function () {
OO.inheritClass( ve.ui.VersalitasCommand, ve.ui.Command );
// localization for button name
if(!mw.messages.exists('DirectionTool-toolname')){
mw.messages.set('DirectionTool-toolname', 'תו כיווניות');
}
// localization for rlm template name
if(!mw.config.exists('rlmTemplateName')){
mw.config.set('rlmTemplateName', 'כ');
}
//end of localization


function DirectionTool( toolGroup, config ) {
ve.ui.VersalitasCommand.prototype.execute = function ( surface ) {
OO.ui.Tool.call( this, toolGroup, config );
var model = surface.getModel(),
}
fragment = model.getFragment(),
OO.inheritClass( DirectionTool, OO.ui.Tool );
doc = model.getDocument(),
range = fragment.getSelection().getRange();


DirectionTool.static.name = 'DirectionTool';
// Obtener el contenido seleccionado
DirectionTool.static.title = mw.msg('DirectionTool-toolname');
var selectedContent = doc.getData( range );
// Crear el contenido para {{versal}}
var versalStart = [
{
type: 'mwTransclusionInline',
attributes: {
mw: {
parts: [{
template: {
target: {
href: 'Template:Versal',
wt: 'versal'
},
params: {}
}
}]
}
}
},
{
type: '/mwTransclusionInline'
}
];


DirectionTool.prototype.onSelect = function () {
// Crear el contenido para {{fin}}
this.toolbar.getSurface().getModel().getFragment().collapseToEnd().insertContent([{
var versalEnd = [
'type': 'mwTransclusionInline',
{
'attributes': {
type: 'mwTransclusionInline',
'mw': {
attributes: {
parts: [ {
mw: {
template: {
parts: [{
target: {
template: {
href: mw.config.get('wgFormattedNamespaces')[10]+ ':'+ mw.config.get('rlmTemplateName'),
target: {
wt: mw.config.get('rlmTemplateName')
href: 'Template:Fin',
},
wt: 'fin'
params: {}
},
}
params: {}
}]
}
}]
}
}
}
},
{
type: '/mwTransclusionInline'
}
}
}]);
];
};
 
// Combinar todo: {{versal}} + contenido seleccionado + {{fin}}
var newContent = versalStart.concat( selectedContent ).concat( versalEnd );


DirectionTool.prototype.onUpdateState = function () {
// Reemplazar el contenido seleccionado
this.setActive( false );
fragment.insertContent( newContent );
};
};


ve.ui.toolFactory.register( DirectionTool );
ve.ui.commandRegistry.register( new ve.ui.VersalitasCommand() );


})();
ve.ui.VersalitasTool = function VeUiVersalitasTool() {
ve.ui.VersalitasTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.VersalitasTool, ve.ui.Tool );
ve.ui.VersalitasTool.static.name = 'Versalitas';
ve.ui.VersalitasTool.static.group = 'textStyle';
ve.ui.VersalitasTool.static.icon = 'largerText';
ve.ui.VersalitasTool.static.title = 'Versalitas';
ve.ui.VersalitasTool.static.commandName = 'Versalitas';
ve.ui.toolFactory.register( ve.ui.VersalitasTool );

Revisión actual - 19:29 29 jun 2025

ve.ui.VersalitasCommand = function VeUiVersalitasCommand() {
	ve.ui.VersalitasCommand.super.call(	this, 'Versalitas' );
};
OO.inheritClass( ve.ui.VersalitasCommand, ve.ui.Command );

ve.ui.VersalitasCommand.prototype.execute = function ( surface ) {
	var model = surface.getModel(),
		fragment = model.getFragment(),
		doc = model.getDocument(),
		range = fragment.getSelection().getRange();

	// Obtener el contenido seleccionado
	var selectedContent = doc.getData( range );
	
	// Crear el contenido para {{versal}}
	var versalStart = [
		{
			type: 'mwTransclusionInline',
			attributes: {
				mw: {
					parts: [{
						template: {
							target: {
								href: 'Template:Versal',
								wt: 'versal'
							},
							params: {}
						}
					}]
				}
			}
		},
		{
			type: '/mwTransclusionInline'
		}
	];

	// Crear el contenido para {{fin}}
	var versalEnd = [
		{
			type: 'mwTransclusionInline',
			attributes: {
				mw: {
					parts: [{
						template: {
							target: {
								href: 'Template:Fin',
								wt: 'fin'
							},
							params: {}
						}
					}]
				}
			}
		},
		{
			type: '/mwTransclusionInline'
		}
	];

	// Combinar todo: {{versal}} + contenido seleccionado + {{fin}}
	var newContent = versalStart.concat( selectedContent ).concat( versalEnd );

	// Reemplazar el contenido seleccionado
	fragment.insertContent( newContent );
};

ve.ui.commandRegistry.register( new ve.ui.VersalitasCommand() );

ve.ui.VersalitasTool = function VeUiVersalitasTool() {
	ve.ui.VersalitasTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.VersalitasTool, ve.ui.Tool );
ve.ui.VersalitasTool.static.name = 'Versalitas';
ve.ui.VersalitasTool.static.group = 'textStyle';
ve.ui.VersalitasTool.static.icon = 'largerText';
ve.ui.VersalitasTool.static.title = 'Versalitas';
ve.ui.VersalitasTool.static.commandName = 'Versalitas';
ve.ui.toolFactory.register( ve.ui.VersalitasTool );