jenkins-bot has submitted this change and it was merged.

Change subject: MathJax: Listen for wikipage.content hook
......................................................................


MathJax: Listen for wikipage.content hook

This brings us one step closer to solving the JS rendering bug. The
remaining issue is how to know that the enabler script needs to be
loaded.

Bug: 36060
Change-Id: I9cbd032afaf90a735c92f055c2bf82766e9acbe0
---
M modules/ext.math.mathjax.enabler.js
1 file changed, 22 insertions(+), 33 deletions(-)

Approvals:
  Frédéric Wang: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ext.math.mathjax.enabler.js 
b/modules/ext.math.mathjax.enabler.js
index eb9a51e..9a45a01 100644
--- a/modules/ext.math.mathjax.enabler.js
+++ b/modules/ext.math.mathjax.enabler.js
@@ -201,48 +201,37 @@
         * Renders all Math TeX inside the given elements.
         * @param {function} callback to be executed after text elements have 
rendered [optional]
         */
-       $.fn.renderTex = function ( callback ) {
-               var elem = this.find( '.tex' ).parent().toArray();
+       $.fn.renderTex = function () {
+               mathJax.LoadAndRender( this );
+               return this;
+       };
+       mw.log.deprecate( $.fn, 'renderTex', $.fn.renderTex,
+               'Use the mw.hook wikipage.content instead' );
 
-               if ( !$.isFunction( callback ) ) {
-                       callback = $.noop;
+       mathJax.LoadAndRender = function ( $content ) {
+               // create the global MathJax variable to hook into MathJax 
startup
+               if( typeof MathJax === 'undefined' ) {
+                       window.MathJax = {
+                               delayStartupUntil: 'configured',
+                               skipStartupTypeset: true,
+                               AuthorInit: mathJax.Init
+                       };
                }
 
                function render() {
-                       MathJax.Hub.Queue( ['Typeset', MathJax.Hub, elem, 
callback] );
+                       var elem = $content.toArray();
+                       MathJax.Hub.Queue( ['Typeset', MathJax.Hub, elem] );
                }
 
-               mw.loader.using( 'ext.math.mathjax.mathjax', function () {
-                       if ( MathJax.isReady ) {
-                               render();
-                       } else {
+               if ( MathJax.isReady ) {
+                       render();
+               } else {
+                       mw.loader.using( 'ext.math.mathjax.mathjax', function 
() {
                                MathJax.Hub.Startup.signal.MessageHook( 'End', 
render );
-                       }
-               } );
-               return this;
-       };
-
-       mathJax.Load = function () {
-               if ( this.loaded ) {
-                       return true;
+                       } );
                }
-
-               // create the global MathJax variable to hook into MathJax 
startup
-               window.MathJax = {
-                       delayStartupUntil: 'configured',
-                       AuthorInit: mathJax.Init
-               };
-
-               // load MathJax.js
-               mw.loader.load('ext.math.mathjax.mathjax');
-
-               this.loaded = true;
-
-               return false;
        };
 
-       $( document ).ready( function () {
-               mathJax.Load();
-       } );
+       mw.hook( 'wikipage.content' ).add( mathJax.LoadAndRender );
 
 }( mediaWiki, jQuery ) );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9cbd032afaf90a735c92f055c2bf82766e9acbe0
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: TheDJ <hartman.w...@gmail.com>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Frédéric Wang <fred.w...@free.fr>
Gerrit-Reviewer: Physikerwelt <w...@physikerwelt.de>
Gerrit-Reviewer: TheDJ <hartman.w...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to