diff --git a/Math.hooks.php b/Math.hooks.php index fea33d4..7d5f71c 100644 --- a/Math.hooks.php +++ b/Math.hooks.php @@ -270,4 +270,14 @@ class MathHooks { return true; } + + /** + * + * @global type $wgOut + * @param type $toolbar + */ + static function onEditPageBeforeEditToolbar( &$toolbar ) { + global $wgOut; + $wgOut->addModules( array( 'ext.math.editbutton.enabler' ) ); + } } diff --git a/Math.php b/Math.php index f5a3669..0f333d8 100644 --- a/Math.php +++ b/Math.php @@ -163,6 +163,7 @@ $wgHooks['LoadExtensionSchemaUpdates'][] = 'MathHooks::onLoadExtensionSchemaUpda $wgHooks['ParserTestTables'][] = 'MathHooks::onParserTestTables'; $wgHooks['UnitTestsList'][] = 'MathHooks::onRegisterUnitTests'; $wgHooks['PageRenderingHash'][] = 'MathHooks::onPageRenderingHash'; +$wgHooks['EditPageBeforeEditToolbar'][] = 'MathHooks::onEditPageBeforeEditToolbar'; $dir = __DIR__ . '/'; $wgAutoloadClasses['MathHooks'] = $dir . 'Math.hooks.php'; @@ -419,6 +420,14 @@ $moduleTemplate = array( 'remoteExtPath' => 'Math/modules', ); +$wgResourceModules['ext.math.editbutton.enabler'] = array( + 'scripts' => 'ext.math.editbutton.js', + 'messages' => array( + 'math_tip', + 'math_sample', + ), +) + $moduleTemplate; + $wgResourceModules['ext.math.visualEditor'] = array( 'scripts' => array( 'VisualEditor/ve.dm.MWMathNode.js', diff --git a/images/button_math.png b/images/button_math.png new file mode 100644 index 0000000..507e4b5 Binary files /dev/null and b/images/button_math.png differ diff --git a/modules/ext.math.editbutton.js b/modules/ext.math.editbutton.js new file mode 100644 index 0000000..123bed9 --- /dev/null +++ b/modules/ext.math.editbutton.js @@ -0,0 +1,13 @@ +( function ( mw ) { + if ( mw.toolbar ) { + var iconPath = mw.config.get( 'wgExtensionAssetsPath' ) + '/Math/images/'; + mw.toolbar.addButton( { + imageFile: iconPath + 'button_math.png', + speedTip: mw.msg( 'math_tip' ), + tagOpen: '', + tagClose: '', + sampleText: mw.msg( 'math_sample' ), + imageId: 'mw-editbutton-math' + } ); + } +} ( mediaWiki ) );