File: EditCheckContextItem.js

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (81 lines) | stat: -rw-r--r-- 2,055 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
/*!
 * VisualEditor EditCheckContextItem class.
 *
 * @copyright See AUTHORS.txt
 */

/**
 * Context item shown after a rich text paste.
 *
 * @class
 * @extends ve.ui.PersistentContextItem
 *
 * @constructor
 * @param {ve.ui.LinearContext} context Context the item is in
 * @param {ve.dm.Model} model Model the item is related to
 * @param {Object} [config]
 */
ve.ui.EditCheckContextItem = function VeUiEditCheckContextItem() {
	// Parent constructor
	ve.ui.EditCheckContextItem.super.apply( this, arguments );

	// Initialization
	this.$element.addClass( 've-ui-editCheckContextItem' );
};

/* Inheritance */

OO.inheritClass( ve.ui.EditCheckContextItem, ve.ui.PersistentContextItem );

/* Static Properties */

ve.ui.EditCheckContextItem.static.name = 'editCheckReferences';

ve.ui.EditCheckContextItem.static.icon = 'quotes';

ve.ui.EditCheckContextItem.static.label = OO.ui.deferMsg( 'editcheck-dialog-addref-title' );

/* Methods */

/**
 * @inheritdoc
 */
ve.ui.EditCheckContextItem.prototype.renderBody = function () {
	const $actions = $( '<div>' ).addClass( 've-ui-editCheckContextItem-actions' );

	this.data.action.getChoices().forEach( ( choice ) => {
		const button = new OO.ui.ButtonWidget( choice );
		button.connect( this, {
			click: () => {
				this.onChoiceClick( choice.action );
			}
		} );
		$actions.append( button.$element );
	} );

	// HACK: Suppress close button on mobile context
	if ( this.context.isMobile() ) {
		this.context.closeButton.toggle( false );
	}

	this.$body.append(
		$( '<p>' ).text( this.data.action.getDescription() ),
		$actions
	);
};

ve.ui.EditCheckContextItem.prototype.close = function ( data ) {
	// HACK: Un-suppress close button on mobile context
	if ( this.context.isMobile() ) {
		this.context.closeButton.toggle( true );
	}
	this.data.callback( data, this.data );
};

ve.ui.EditCheckContextItem.prototype.onChoiceClick = function ( choice ) {
	this.data.action.check.act( choice, this.data.action, this );
};

/* Registration */

ve.ui.contextItemFactory.register( ve.ui.EditCheckContextItem );