summaryrefslogtreecommitdiff
blob: 5d2c396e56fe936d92b972ad5c9e2f3d94b6db3b (plain)
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
( function ( mw, OO, ve ) {

/**
 * Action to switch from VisualEditor to the Wikitext editing interface
 * within Flow.
 *
 * @class
 * @extends ve.ui.Action
 *
 * @constructor
 * @param {ve.ui.Surface} surface Surface to act on
 */
mw.flow.ve.ui.SwitchEditorAction = function MwFlowVeUiSwitchEditorAction( surface ) {
	// Parent constructor
	ve.ui.Action.call( this, surface );
};

/* Inheritance */

OO.inheritClass( mw.flow.ve.ui.SwitchEditorAction, ve.ui.Action );

/* Static Properties */

/**
 * Name of this action
 *
 * @static
 * @property
 */
mw.flow.ve.ui.SwitchEditorAction.static.name = 'flowSwitchEditor';

/**
 * List of allowed methods for the action.
 *
 * @static
 * @property
 */
mw.flow.ve.ui.SwitchEditorAction.static.methods = [ 'switch' ];

/* Methods */

/**
 * Switch to wikitext editing.
 *
 * @method
 */
mw.flow.ve.ui.SwitchEditorAction.prototype.switch = function () {
	var $node = this.surface.$element.closest( 'form' ).find( 'textarea' );

	mw.flow.editor.switchEditor( $node, 'none' );
};

ve.ui.actionFactory.register( mw.flow.ve.ui.SwitchEditorAction );

}( mediaWiki, OO, ve ) );