Physikerwelt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/109923

Change subject: WIP: Editbutton for math
......................................................................

WIP: Editbutton for math

Change-Id: I3d126c1c252c27fa65ab8fb42ffab66a2d99cfa8
---
M Math.hooks.php
M Math.php
A modules/ext.math.editbutton.js
3 files changed, 27 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math 
refs/changes/23/109923/1

diff --git a/Math.hooks.php b/Math.hooks.php
index d676fb1..a70d050 100644
--- a/Math.hooks.php
+++ b/Math.hooks.php
@@ -187,4 +187,14 @@
                $files = array_merge( $files, glob( "$testDir/*Test.php" ) );
                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 49f7de5..5720e93 100644
--- a/Math.php
+++ b/Math.php
@@ -155,6 +155,7 @@
 $wgHooks['ParserTestTables'][] = 'MathHooks::onParserTestTables';
 $wgHooks['ParserTestParser'][] = 'MathHooks::onParserTestParser';
 $wgHooks['UnitTestsList'][] = 'MathHooks::onRegisterUnitTests';
+$wgHooks['EditPageBeforeEditToolbar'][] = 
'MathHooks::onEditPageBeforeEditToolbar';
 
 $dir = dirname( __FILE__ ) . '/';
 $wgAutoloadClasses['MathHooks'] = $dir . 'Math.hooks.php';
@@ -185,3 +186,7 @@
 $wgResourceModules['ext.math.mathjax.enabler'] = array(
        'scripts' => 'ext.math.mathjax.enabler.js',
 ) + $moduleTemplate;
+
+$wgResourceModules['ext.math.editbutton.enabler'] = array(
+       'scripts' => 'ext.math.editbutton.js',
+) + $moduleTemplate;
\ No newline at end of file
diff --git a/modules/ext.math.editbutton.js b/modules/ext.math.editbutton.js
new file mode 100644
index 0000000..71166a8
--- /dev/null
+++ b/modules/ext.math.editbutton.js
@@ -0,0 +1,12 @@
+( function ( mw, $ ) {
+       if (mw.toolbar) {
+               mw.toolbar.addButton( {
+                       imageFile: 
'//upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png',
+                       speedTip: 'Comment visible only for editors',
+                       tagOpen: '<math>',
+                       tagClose: '</math>',
+                       sampleText: 'E = m c^2',
+                       imageId: 'button-math'
+       } );
+}
+}( mediaWiki, jQuery ) );
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/109923
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d126c1c252c27fa65ab8fb42ffab66a2d99cfa8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <w...@physikerwelt.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to