Debian Codegraph @

extensions/Math/modules/ve-math/ve.ui.MWLatexContextItem.js

raw symbols SCIP
1 /*!
2 * VisualEditor MWLatexContextItem class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * Abstract context item for a node of a formula provided
9 * by the Math extension.
10 *
11 * @abstract
12 * @class
13 * @extends ve.ui.LinearContextItem
14 *
15 * @param {ve.ui.LinearContext} context Context the item is in
16 * @param {ve.dm.Model} model Model the item is related to
17 * @param {Object} config Configuration options
18 */
19 ve.ui.MWLatexContextItem = function VeUiMWLatexContextItem() {
20 // Parent constructor
21 ve.ui.MWLatexContextItem.super.apply( this, arguments );
22
23 this.quickEditButton = new OO.ui.ButtonWidget( {
24 label: ve.msg( 'math-visualeditor-mwlatexcontextitem-quickedit' ),
25 flags: [ 'progressive' ]
26 } );
27
28 // Don't show quick edit button in mobile as the primary action will be quick edit
29 if ( !this.context.isMobile() && !this.isReadOnly() ) {
30 this.actionButtons.addItems( [ this.quickEditButton ], 0 );
31 }
32
33 this.quickEditButton.connect( this, { click: 'onInlineEditButtonClick' } );
34
35 // Initialization
36 this.$element.addClass( 've-ui-mwLatexContextItem' );
37 };
38
39 /* Inheritance */
40
41 OO.inheritClass( ve.ui.MWLatexContextItem, ve.ui.LinearContextItem );
42
43 /* Static Properties */
44
45 ve.ui.MWLatexContextItem.static.embeddable = false;
46
47 ve.ui.MWLatexContextItem.static.inlineEditCommand = null;
48
49 /* Methods */
50
51 /**
52 * Handle inline edit button click events.
53 */
54 ve.ui.MWLatexContextItem.prototype.onInlineEditButtonClick = function () {
55 this.context.getSurface().executeCommand( this.constructor.static.inlineEditCommand );
56 };
57
58 /**
59 * @inheritdoc
60 */
61 ve.ui.MWLatexContextItem.prototype.getCommand = function () {
62 return this.context.getSurface().commandRegistry.lookup(
63 this.context.isMobile() ? this.constructor.static.inlineEditCommand : this.constructor.static.commandName
64 );
65 };
66
67 /**
68 * @inheritdoc
69 */
70 ve.ui.MWLatexContextItem.prototype.getDescription = function () {
71 return ve.ce.nodeFactory.getDescription( this.model );
72 };