mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-30 18:35:12 +00:00
848d762e24
The chemical and mathematical formula inspectors and dialogs have a lot of similar functionality, and the common parts are now moved to the common MWLatex class. MWMath* classes now inherit from MWLatex*, and so do the new MWChem* classes. Bug: T153365 Change-Id: I4452ceca55197fda5f1e1293a5741c6f5fb7c245
66 lines
1.8 KiB
JavaScript
66 lines
1.8 KiB
JavaScript
/*!
|
|
* VisualEditor MWLatexContextItem class.
|
|
*
|
|
* @copyright 2015 VisualEditor Team and others; see http://ve.mit-license.org
|
|
*/
|
|
|
|
/**
|
|
* Abstract context item for a node of a formula provided
|
|
* by the Math extension.
|
|
*
|
|
* @abstract
|
|
* @class
|
|
* @extends ve.ui.LinearContextItem
|
|
*
|
|
* @param {ve.ui.Context} context Context item is in
|
|
* @param {ve.dm.Model} model Model item is related to
|
|
* @param {Object} config Configuration options
|
|
*/
|
|
ve.ui.MWLatexContextItem = function VeUiMWLatexContextItem() {
|
|
// Parent constructor
|
|
ve.ui.MWLatexContextItem.super.apply( this, arguments );
|
|
|
|
this.quickEditButton = new OO.ui.ButtonWidget( {
|
|
label: ve.msg( 'math-visualeditor-mwlatexcontextitem-quickedit' ),
|
|
flags: [ 'progressive' ]
|
|
} );
|
|
|
|
// Don't show quick edit button in mobile as the primary action will be quick edit
|
|
if ( !this.context.isMobile() ) {
|
|
this.actionButtons.addItems( [ this.quickEditButton ], 0 );
|
|
}
|
|
|
|
this.quickEditButton.connect( this, { click: 'onInlineEditButtonClick' } );
|
|
|
|
// Initialization
|
|
this.$element.addClass( 've-ui-mwLatexContextItem' );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWLatexContextItem, ve.ui.LinearContextItem );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ui.MWLatexContextItem.static.embeddable = false;
|
|
|
|
ve.ui.MWLatexContextItem.static.inlineEditCommand = null;
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handle inline edit button click events.
|
|
*/
|
|
ve.ui.MWLatexContextItem.prototype.onInlineEditButtonClick = function () {
|
|
this.context.getSurface().executeCommand( this.constructor.static.inlineEditCommand );
|
|
};
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWLatexContextItem.prototype.getCommand = function () {
|
|
return this.context.getSurface().commandRegistry.lookup(
|
|
this.context.isMobile() ? this.constructor.static.inlineEditCommand : this.constructor.static.commandName
|
|
);
|
|
};
|