mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-30 00:55:00 +00:00
9be5c85db4
VisualEditor is usually not enabled in talk namespaces... but sometimes it is. And when users see the button to edit with VE, they're going to click it and expect to be able to sign their posts. This tool is only loaded on talk pages and pages in additional namespaces defined in $wgExtraSignatureNamespaces. Code adapted with small tweaks from my own gadget <https://meta.wikimedia.org/wiki/User:Matma_Rex/visualeditor-signature.js?oldid=13461327>, which is already available under the MIT license. Changes include: * The tool is now always visible if the wiki allows signatures in any VE namespaces, but disabled when not allowed in the current namespace. * Register '~~~~' sequence to insert the signature. * Code style tweaks for stricter lint checks in this repository. * Documentation corrections. Swedish translation provided by André Costa (already credited as a translator as Lokal_Profil). Depends on changes in VisualEditor core: * I89fe53890ab59d12260ea6b41de802c38c24e8b9 * I14cd7efac521687ea38580341ae08ddc522edeeb Bug: T53154 Change-Id: I6be5fb2118cf3eef5098d4c5320228aa81411ccb
71 lines
1.7 KiB
JavaScript
71 lines
1.7 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel MWSignatureNode class.
|
|
*
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* DataModel MediaWiki signature node. This defines the behavior of the data model for the
|
|
* signature, especially the fact that it needs to be converted into a wikitext signature on
|
|
* save.
|
|
*
|
|
* @class
|
|
* @extends ve.dm.MWTransclusionInlineNode
|
|
*
|
|
* @constructor
|
|
* @param {Object} [element] Reference to element in linear model
|
|
*/
|
|
ve.dm.MWSignatureNode = function VeDmMWSignatureNode( element ) {
|
|
// Parent constructor
|
|
ve.dm.MWTransclusionInlineNode.call( this, element );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.dm.MWSignatureNode, ve.dm.MWTransclusionInlineNode );
|
|
|
|
/* Static members */
|
|
|
|
ve.dm.MWSignatureNode.static.name = 'mwSignature';
|
|
|
|
ve.dm.MWSignatureNode.static.matchTagNames = null;
|
|
|
|
ve.dm.MWSignatureNode.static.matchRdfaTypes = [];
|
|
|
|
ve.dm.MWSignatureNode.static.matchFunction = function () {
|
|
return false;
|
|
};
|
|
|
|
ve.dm.MWSignatureNode.static.getHashObject = function ( dataElement ) {
|
|
return {
|
|
type: dataElement.type
|
|
};
|
|
};
|
|
|
|
ve.dm.MWSignatureNode.static.toDomElements = function ( dataElement, doc, converter ) {
|
|
dataElement = ve.dm.MWSignatureNode.static.toDataElement();
|
|
return ve.dm.MWSignatureNode.parent.static.toDomElements( dataElement, doc, converter );
|
|
};
|
|
|
|
ve.dm.MWSignatureNode.static.toDataElement = function () {
|
|
return {
|
|
type: 'mwTransclusionInline',
|
|
attributes: {
|
|
mw: {
|
|
parts: [ '~~~~' ]
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
ve.dm.MWSignatureNode.prototype.getPartsList = function () {
|
|
return [ { content: '~~~~' } ];
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.MWSignatureNode );
|