2013-09-06 00:10:06 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki UserInterface edit mode tool classes.
|
|
|
|
*
|
2017-01-03 16:58:33 +00:00
|
|
|
* @copyright 2011-2017 VisualEditor Team and others; see AUTHORS.txt
|
2013-09-06 00:10:06 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-01-13 15:18:06 +00:00
|
|
|
* MediaWiki UserInterface edit mode tool.
|
2013-09-06 00:10:06 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @abstract
|
|
|
|
*/
|
2017-02-24 14:29:21 +00:00
|
|
|
ve.ui.MWEditModeTool = function VeUiMWEditModeTool() {
|
2013-09-06 00:10:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2017-02-24 14:29:21 +00:00
|
|
|
OO.initClass( ve.ui.MWEditModeTool );
|
2013-09-06 00:10:06 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
2017-02-24 14:29:21 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc mw.libs.ve.MWEditModeTool
|
|
|
|
*/
|
|
|
|
ve.ui.MWEditModeTool.prototype.getMode = function () {
|
|
|
|
return this.toolbar.getSurface().getMode();
|
2016-04-04 16:31:39 +00:00
|
|
|
};
|
|
|
|
|
2017-02-24 14:29:21 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc mw.libs.ve.MWEditModeTool
|
|
|
|
*/
|
|
|
|
ve.ui.MWEditModeTool.prototype.isModeAvailable = function ( mode ) {
|
|
|
|
// Source mode is always available
|
|
|
|
return mode === 'source' || this.toolbar.getTarget().isModeAvailable( mode );
|
2013-09-06 00:10:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki UserInterface edit mode source tool.
|
|
|
|
*
|
|
|
|
* @class
|
2017-02-24 14:29:21 +00:00
|
|
|
* @extends mw.libs.ve.MWEditModeSourceTool
|
|
|
|
* @mixins ve.ui.MWEditModeTool
|
2013-09-06 00:10:06 +00:00
|
|
|
* @constructor
|
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
|
|
|
* @param {Object} [config] Config options
|
|
|
|
*/
|
2015-08-06 14:22:15 +00:00
|
|
|
ve.ui.MWEditModeSourceTool = function VeUiMWEditModeSourceTool() {
|
2016-08-22 21:44:59 +00:00
|
|
|
// Parent constructor
|
2015-08-06 14:22:15 +00:00
|
|
|
ve.ui.MWEditModeSourceTool.super.apply( this, arguments );
|
2017-02-24 14:29:21 +00:00
|
|
|
// Mixin constructor
|
|
|
|
ve.ui.MWEditModeTool.call( this );
|
2013-09-06 00:10:06 +00:00
|
|
|
};
|
2017-02-24 14:29:21 +00:00
|
|
|
OO.inheritClass( ve.ui.MWEditModeSourceTool, mw.libs.ve.MWEditModeSourceTool );
|
|
|
|
OO.mixinClass( ve.ui.MWEditModeSourceTool, ve.ui.MWEditModeTool );
|
2014-04-03 23:54:55 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2017-02-24 14:29:21 +00:00
|
|
|
ve.ui.MWEditModeSourceTool.prototype.switch = function () {
|
2014-04-03 23:54:55 +00:00
|
|
|
this.toolbar.getTarget().editSource();
|
|
|
|
};
|
2013-09-06 00:10:06 +00:00
|
|
|
ve.ui.toolFactory.register( ve.ui.MWEditModeSourceTool );
|
2016-11-14 16:07:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki UserInterface edit mode visual tool.
|
|
|
|
*
|
|
|
|
* @class
|
2017-02-24 14:29:21 +00:00
|
|
|
* @extends mw.libs.ve.MWEditModeVisualTool
|
|
|
|
* @mixins ve.ui.MWEditModeTool
|
2016-11-14 16:07:13 +00:00
|
|
|
* @constructor
|
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
|
|
|
* @param {Object} [config] Config options
|
|
|
|
*/
|
|
|
|
ve.ui.MWEditModeVisualTool = function VeUiMWEditModeVisualTool() {
|
|
|
|
// Parent constructor
|
|
|
|
ve.ui.MWEditModeVisualTool.super.apply( this, arguments );
|
2017-02-24 14:29:21 +00:00
|
|
|
// Mixin constructor
|
|
|
|
ve.ui.MWEditModeTool.call( this );
|
2016-11-14 16:07:13 +00:00
|
|
|
};
|
2017-02-24 14:29:21 +00:00
|
|
|
OO.inheritClass( ve.ui.MWEditModeVisualTool, mw.libs.ve.MWEditModeVisualTool );
|
|
|
|
OO.mixinClass( ve.ui.MWEditModeVisualTool, ve.ui.MWEditModeTool );
|
2016-11-14 16:07:13 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2017-02-24 14:29:21 +00:00
|
|
|
ve.ui.MWEditModeVisualTool.prototype.switch = function () {
|
2016-11-14 16:07:13 +00:00
|
|
|
this.toolbar.getTarget().switchToVisualEditor();
|
|
|
|
};
|
|
|
|
ve.ui.toolFactory.register( ve.ui.MWEditModeVisualTool );
|