2014-02-27 15:17:00 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki Reference dialog tool classes.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki UserInterface reference tool.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.DialogTool
|
|
|
|
* @constructor
|
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
|
|
|
ve.ui.MWReferenceDialogTool = function VeUiMWReferenceDialogTool( toolGroup, config ) {
|
|
|
|
ve.ui.DialogTool.call( this, toolGroup, config );
|
|
|
|
};
|
|
|
|
OO.inheritClass( ve.ui.MWReferenceDialogTool, ve.ui.DialogTool );
|
|
|
|
ve.ui.MWReferenceDialogTool.static.name = 'reference';
|
|
|
|
ve.ui.MWReferenceDialogTool.static.group = 'object';
|
|
|
|
ve.ui.MWReferenceDialogTool.static.icon = 'reference';
|
|
|
|
ve.ui.MWReferenceDialogTool.static.title =
|
|
|
|
OO.ui.deferMsg( 'visualeditor-dialogbutton-reference-tooltip' );
|
|
|
|
ve.ui.MWReferenceDialogTool.static.modelClasses = [ ve.dm.MWReferenceNode ];
|
2014-04-02 23:29:04 +00:00
|
|
|
ve.ui.MWReferenceDialogTool.static.commandName = 'reference';
|
2014-04-11 18:59:55 +00:00
|
|
|
ve.ui.MWReferenceDialogTool.static.requiresRange = true;
|
2014-02-27 15:17:00 +00:00
|
|
|
ve.ui.toolFactory.register( ve.ui.MWReferenceDialogTool );
|
|
|
|
|
2014-05-30 21:28:41 +00:00
|
|
|
/**
|
|
|
|
* MediaWiki UserInterface use existing reference tool.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.DialogTool
|
|
|
|
* @constructor
|
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
|
|
|
ve.ui.MWUseExistingReferenceDialogTool = function VeUiMWUseExistingReferenceDialogTool( toolGroup, config ) {
|
|
|
|
ve.ui.DialogTool.call( this, toolGroup, config );
|
|
|
|
};
|
|
|
|
OO.inheritClass( ve.ui.MWUseExistingReferenceDialogTool, ve.ui.DialogTool );
|
|
|
|
ve.ui.MWUseExistingReferenceDialogTool.static.name = 'reference/existing';
|
|
|
|
ve.ui.MWUseExistingReferenceDialogTool.static.group = 'object';
|
|
|
|
ve.ui.MWUseExistingReferenceDialogTool.static.icon = 'reference-existing';
|
|
|
|
ve.ui.MWUseExistingReferenceDialogTool.static.title =
|
2014-07-03 20:42:54 +00:00
|
|
|
OO.ui.deferMsg( 'visualeditor-dialog-reference-useexisting-tool' );
|
2014-05-30 21:28:41 +00:00
|
|
|
ve.ui.MWUseExistingReferenceDialogTool.static.modelClasses = [];
|
|
|
|
ve.ui.MWUseExistingReferenceDialogTool.static.commandName = 'reference/existing';
|
|
|
|
ve.ui.MWUseExistingReferenceDialogTool.static.requiresRange = true;
|
|
|
|
ve.ui.MWUseExistingReferenceDialogTool.static.autoAddToGroup = false;
|
|
|
|
ve.ui.MWUseExistingReferenceDialogTool.static.autoAddToCatchall = false;
|
2014-09-10 23:05:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWUseExistingReferenceDialogTool.prototype.onUpdateState = function ( fragment ) {
|
|
|
|
var groups = fragment.getDocument().getInternalList().getNodeGroups(), empty = true;
|
|
|
|
|
|
|
|
// Parent method
|
|
|
|
ve.ui.Tool.prototype.onUpdateState.apply( this, arguments );
|
|
|
|
|
|
|
|
$.each( groups, function ( groupName, group ) {
|
|
|
|
if ( groupName.lastIndexOf( 'mwReference/' ) !== 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( group.indexOrder.length ) {
|
|
|
|
empty = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} );
|
2014-09-15 23:16:21 +00:00
|
|
|
this.setDisabled( ( this.constructor.static.requiresRange && !fragment.getRange() ) || empty );
|
2014-09-10 23:05:32 +00:00
|
|
|
};
|
2014-05-30 21:28:41 +00:00
|
|
|
ve.ui.toolFactory.register( ve.ui.MWUseExistingReferenceDialogTool );
|
|
|
|
|
2014-02-27 15:17:00 +00:00
|
|
|
/**
|
2014-08-19 18:32:46 +00:00
|
|
|
* MediaWiki UserInterface references list tool.
|
2014-02-27 15:17:00 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.DialogTool
|
|
|
|
* @constructor
|
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
2014-08-19 18:32:46 +00:00
|
|
|
ve.ui.MWReferencesListDialogTool = function VeUiMWReferencesListDialogTool( toolGroup, config ) {
|
2014-02-27 15:17:00 +00:00
|
|
|
ve.ui.DialogTool.call( this, toolGroup, config );
|
|
|
|
};
|
2014-08-19 18:32:46 +00:00
|
|
|
OO.inheritClass( ve.ui.MWReferencesListDialogTool, ve.ui.DialogTool );
|
|
|
|
ve.ui.MWReferencesListDialogTool.static.name = 'referencesList';
|
|
|
|
ve.ui.MWReferencesListDialogTool.static.group = 'object';
|
|
|
|
ve.ui.MWReferencesListDialogTool.static.icon = 'references';
|
|
|
|
ve.ui.MWReferencesListDialogTool.static.title =
|
|
|
|
OO.ui.deferMsg( 'visualeditor-dialogbutton-referenceslist-tooltip' );
|
|
|
|
ve.ui.MWReferencesListDialogTool.static.modelClasses = [ ve.dm.MWReferencesListNode ];
|
|
|
|
ve.ui.MWReferencesListDialogTool.static.commandName = 'referencesList';
|
|
|
|
ve.ui.MWReferencesListDialogTool.static.requiresRange = true;
|
|
|
|
ve.ui.toolFactory.register( ve.ui.MWReferencesListDialogTool );
|