mediawiki-extensions-Cite/modules/ve-cite/ve.ui.MWCitationAction.js
Ed Sanders 89dd1faa11 Remove generated cite-dialogs stubs
We generate stub MWCitationDialog sub-classes for each citation
type, e.g. cite-web, cite-news. The only override these sub-classes
provide is for the dialog title, providing "Website" instead of
"Cite web", however because of code in MWTemplateDialog, this override
isn't even used.

1. Make the 'citation' dialog (now 'cite') concrete by registering
   it, and allow a 'title' argument to be passed it.
2. Actually override the title, using the passed in argument.
3. Remove the stub generated citation dialogs.

This will also fix our tracking data. Current we are getting
window-open actions with the argument being a localised citation
type name, e.g. cite-Literatur, cite-אתר.

These will now all be tracked as 'cite' as we use the parent dialog.

Bug: T216248
Depends-On: I355e7fe4c2ea965f2ca91f0ab0430cfb95e56e0a
Change-Id: I661707b5f9d3d810e9391ad63bef546d4fcb29e4
2019-02-15 22:44:17 +00:00

58 lines
1.3 KiB
JavaScript

/*!
* VisualEditor UserInterface MWCitationAction class.
*
* @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
* @license MIT
*/
/**
* Link action.
*
* Opens either MWLinkAnnotationInspector or MWLinkNodeInspector depending on what is selected.
*
* @class
* @extends ve.ui.Action
* @constructor
* @param {ve.ui.Surface} surface Surface to act on
*/
ve.ui.MWCitationAction = function VeUiMWCitationAction() {
// Parent constructor
ve.ui.MWCitationAction.super.apply( this, arguments );
};
/* Inheritance */
OO.inheritClass( ve.ui.MWCitationAction, ve.ui.Action );
/* Static Properties */
ve.ui.MWCitationAction.static.name = 'mwcite';
/**
* @inheritdoc
*/
ve.ui.MWCitationAction.static.methods = [ 'open' ];
/* Methods */
/**
* When opening a citation, send the dialog a property of the surface
* dialog name.
*
* @method
* @param {Object} windowData Data to send to the dialog
* @return {boolean} Action was executed
*/
ve.ui.MWCitationAction.prototype.open = function ( windowData ) {
windowData = $.extend( {
inDialog: this.surface.getInDialog()
}, windowData );
this.surface.execute( 'window', 'open', 'cite', windowData );
return true;
};
/* Registration */
ve.ui.actionFactory.register( ve.ui.MWCitationAction );