mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-18 18:40:39 +00:00
f382be8562
npm: * eslint-config-wikimedia: 0.25.1 → 0.26.0 * grunt-banana-checker: 0.11.0 → 0.11.1 * wdio-mediawiki: 2.1.0 → 2.5.0 * get-func-name: 2.0.0 → 2.0.2 * https://github.com/advisories/GHSA-4q6p-r6v2-jvc5 * postcss: 8.4.30 → 8.4.35 * https://github.com/advisories/GHSA-7fh5-64p2-3v2j Change-Id: I5b01fa01c11a57a180b50bf2f8b3275e69d75f1c
82 lines
2.3 KiB
JavaScript
82 lines
2.3 KiB
JavaScript
/*!
|
|
* VisualEditor user interface MWLatexPage class.
|
|
*
|
|
* @copyright 2015 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license MIT
|
|
*/
|
|
|
|
/**
|
|
* Latex dialog symbols page
|
|
*
|
|
* @class
|
|
* @extends OO.ui.PageLayout
|
|
*
|
|
* @constructor
|
|
* @param {string} name Unique symbolic name of page
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ui.MWLatexPage = function VeUiMWLatexPage( name, config ) {
|
|
// Parent constructor
|
|
ve.ui.MWLatexPage.super.call( this, name, config );
|
|
|
|
this.label = config.label;
|
|
|
|
const symbols = config.symbols;
|
|
const $symbols = $( '<div>' ).addClass( 've-ui-specialCharacterPage-characters' );
|
|
const symbolsNode = $symbols[ 0 ];
|
|
|
|
// Avoiding jQuery wrappers as advised in ve.ui.SpecialCharacterPage
|
|
symbols.forEach( function ( symbol ) {
|
|
if ( !symbol.notWorking && !symbol.duplicate ) {
|
|
const tex = symbol.tex || symbol.insert;
|
|
const classes = [ 've-ui-mwLatexPage-symbol' ];
|
|
classes.push(
|
|
've-ui-mwLatexSymbol-' + tex.replace( /[^\w]/g, function ( c ) {
|
|
return '_' + c.charCodeAt( 0 ) + '_';
|
|
} )
|
|
);
|
|
if ( symbol.width ) {
|
|
classes.push( 've-ui-mwLatexPage-symbol-' + symbol.width );
|
|
}
|
|
if ( symbol.contain ) {
|
|
classes.push( 've-ui-mwLatexPage-symbol-contain' );
|
|
}
|
|
if ( symbol.largeLayout ) {
|
|
classes.push( 've-ui-mwLatexPage-symbol-largeLayout' );
|
|
}
|
|
const symbolNode = document.createElement( 'div' );
|
|
classes.forEach( function ( className ) {
|
|
// The following classes are used here:
|
|
// * ve-ui-mwLatexPage-symbol
|
|
// * ve-ui-mwLatexPage-symbol-wide
|
|
// * ve-ui-mwLatexPage-symbol-wider
|
|
// * ve-ui-mwLatexPage-symbol-widest
|
|
// * ve-ui-mwLatexPage-symbol-contain
|
|
// * ve-ui-mwLatexPage-symbol-largeLayout
|
|
symbolNode.classList.add( className );
|
|
} );
|
|
$.data( symbolNode, 'symbol', symbol );
|
|
symbolsNode.appendChild( symbolNode );
|
|
}
|
|
} );
|
|
|
|
this.$element
|
|
.addClass( 've-ui-mwLatexPage' )
|
|
.append( $( '<h3>' ).text( name ), $symbols );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWLatexPage, OO.ui.PageLayout );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWLatexPage.prototype.setupOutlineItem = function ( outlineItem ) {
|
|
ve.ui.MWLatexPage.super.prototype.setupOutlineItem.call( this, outlineItem );
|
|
this.outlineItem.setLabel( this.label );
|
|
this.outlineItem.$element.addClass( 've-ui-mwLatexPage-outline' );
|
|
};
|