mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-12 16:05:09 +00:00
6e73aaf86c
The main components are: - a menu of formula fragment buttons - an ace editor text input into which LaTeX commands are inserted on clicking the buttons - a preview of the formula The deviations from the draft design (full-width menu, smaller buttons, dialog is 'larger' instead of 'large') are so that more buttons can be seen at once. Depends on Ia0f46da2d4 in ve-mw Depends on Ib75fb7b087 in ve-mw Depends on I758f90abb9 in ve-mw Depends on Ibcd941d938 in CodeEditor Depends on Ie814f59086 in oojs-ui Depends on If540670bf2 in oojs-ui Depends on I5f70f133b7 in ve core Bug: T114163 Bug: T118617 Bug: T118618 Change-Id: I96d4b72f2e49ad3f43a2e5c71f0d348fdfb35503
80 lines
2.2 KiB
JavaScript
80 lines
2.2 KiB
JavaScript
/*!
|
|
* VisualEditor user interface MWMathPage class.
|
|
*
|
|
* @copyright 2015 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Math dialog symbols page
|
|
*
|
|
* @class
|
|
* @extends OO.ui.PageLayout
|
|
*
|
|
* @constructor
|
|
* @param {string} name Unique symbolic name of page
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ui.MWMathPage = function VeUiMWMathPage( name, config ) {
|
|
var i, ilen, j, jlen, insert, symbol, symbols, $symbols,
|
|
symbolNode, symbolsNode, tex, classes;
|
|
|
|
// Parent constructor
|
|
ve.ui.MWMathPage.super.call( this, name, config );
|
|
|
|
this.label = config.label;
|
|
|
|
symbols = config.symbols;
|
|
$symbols = $( '<div>' ).addClass( 've-ui-specialCharacterPage-characters' );
|
|
symbolsNode = $symbols[ 0 ];
|
|
|
|
// Avoiding jQuery wrappers as advised in ve.ui.SpecialCharacterPage
|
|
for ( i = 0, ilen = symbols.length; i < ilen; i++ ) {
|
|
symbol = symbols[ i ];
|
|
if ( !symbol.notWorking && !symbol.duplicate ) {
|
|
tex = symbol.tex;
|
|
insert = symbol.insert;
|
|
classes = [ 've-ui-mwMathPage-symbol' ];
|
|
classes.push(
|
|
've-ui-mwMathSymbol-' + tex.replace( /[^\w]/g, function ( c ) {
|
|
return '_' + c.charCodeAt( 0 ) + '_';
|
|
} )
|
|
);
|
|
if ( symbol.wide ) {
|
|
classes.push( 've-ui-mwMathPage-symbol-wide' );
|
|
}
|
|
if ( symbol.contain ) {
|
|
classes.push( 've-ui-mwMathPage-symbol-contain' );
|
|
}
|
|
if ( symbol.largeLayout ) {
|
|
classes.push( 've-ui-mwMathPage-symbol-largeLayout' );
|
|
}
|
|
symbolNode = document.createElement( 'div' );
|
|
for ( j = 0, jlen = classes.length; j < jlen; j++ ) {
|
|
symbolNode.classList.add( classes[ j ] );
|
|
}
|
|
$.data( symbolNode, 'symbol', symbol );
|
|
symbolsNode.appendChild( symbolNode );
|
|
}
|
|
}
|
|
|
|
this.$element
|
|
.addClass( 've-ui-mwMathPage' )
|
|
.append( $( '<h3>' ).text( name ), $symbols );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWMathPage, OO.ui.PageLayout );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWMathPage.prototype.setupOutlineItem = function ( outlineItem ) {
|
|
ve.ui.MWMathPage.super.prototype.setupOutlineItem.call( this, outlineItem );
|
|
this.outlineItem.setLabel( this.label );
|
|
this.outlineItem.$element.addClass( 've-ui-mwMathPage-outline' );
|
|
};
|