File: ve.ui.MWEditModeTool.js

package info (click to toggle)
mediawiki 1%3A1.39.13-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 320,416 kB
  • sloc: php: 815,516; javascript: 601,264; sql: 11,218; python: 4,863; xml: 3,080; sh: 990; ruby: 82; makefile: 78
file content (91 lines) | stat: -rw-r--r-- 2,438 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*!
 * VisualEditor MediaWiki UserInterface edit mode tool classes.
 *
 * @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
 * @license The MIT License (MIT); see LICENSE.txt
 */

/**
 * MediaWiki UserInterface edit mode tool.
 *
 * @class
 * @abstract
 */
ve.ui.MWEditModeTool = function VeUiMWEditModeTool() {
};

/* Inheritance */

OO.initClass( ve.ui.MWEditModeTool );

/* Methods */

/**
 * @inheritdoc mw.libs.ve.MWEditModeTool
 */
ve.ui.MWEditModeTool.prototype.getMode = function () {
	if ( !this.toolbar.getSurface() ) {
		return 'source';
	}
	return this.toolbar.getSurface().getMode();
};

/**
 * @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 );
};

/**
 * MediaWiki UserInterface edit mode source tool.
 *
 * @class
 * @extends mw.libs.ve.MWEditModeSourceTool
 * @mixins ve.ui.MWEditModeTool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Config options
 */
ve.ui.MWEditModeSourceTool = function VeUiMWEditModeSourceTool() {
	// Parent constructor
	ve.ui.MWEditModeSourceTool.super.apply( this, arguments );
	// Mixin constructor
	ve.ui.MWEditModeTool.call( this );
};
OO.inheritClass( ve.ui.MWEditModeSourceTool, mw.libs.ve.MWEditModeSourceTool );
OO.mixinClass( ve.ui.MWEditModeSourceTool, ve.ui.MWEditModeTool );
/**
 * @inheritdoc
 */
ve.ui.MWEditModeSourceTool.prototype.switch = function () {
	this.toolbar.getTarget().editSource();
};
ve.ui.toolFactory.register( ve.ui.MWEditModeSourceTool );

/**
 * MediaWiki UserInterface edit mode visual tool.
 *
 * @class
 * @extends mw.libs.ve.MWEditModeVisualTool
 * @mixins ve.ui.MWEditModeTool
 * @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 );
	// Mixin constructor
	ve.ui.MWEditModeTool.call( this );
};
OO.inheritClass( ve.ui.MWEditModeVisualTool, mw.libs.ve.MWEditModeVisualTool );
OO.mixinClass( ve.ui.MWEditModeVisualTool, ve.ui.MWEditModeTool );
/**
 * @inheritdoc
 */
ve.ui.MWEditModeVisualTool.prototype.switch = function () {
	this.toolbar.getTarget().switchToVisualEditor();
};
ve.ui.toolFactory.register( ve.ui.MWEditModeVisualTool );