Page MenuHomePhabricator

Remove support for WikEd and ajaxPreview from ext.math.mathjax.enabler.js
Closed, ResolvedPublic

Description

While user scripts on en.wikipedia of course have to be compatible with important gadgets it should be just the other way round for MediaWiki extensions. Since ext.math.mathjax.enabler.js is not loaded in edit mode for most users, it doesn't work anyway. So I suggest just to drop the support for those two gagdets. Once bug 23580 is resolved an apropiate hook should be used, then all gadgets can comfortably work together with MathJax.


Version: unspecified
Severity: normal

Details

Reference
bz35478

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:15 AM
bzimport added a project: Math.
bzimport set Reference to bz35478.
bzimport added a subscriber: Unknown Object (MLST).
Schnark created this task.Mar 26 2012, 9:18 AM
TheDJ added a comment.Mar 26 2012, 6:07 PM

There should be a hook for preview mode somewhere. Several other scripts use it as well.

TheDJ added a comment.Mar 26 2012, 7:47 PM

That would be:
$j( mw ).bind( 'LivePreviewPrepare' , function(){ // start loading });

but only works for livepreview it seems...

Created attachment 10339
Proposed code for ext.math.mathjax.enabler.js

The proposed code (easier to read than a diff) does the following:

  • apply coding conventions
  • remove global variable mathJax (not to be mixed up with MathJax), moved this to mediaWiki.mathJax
  • remove special code for WikEd and AjaxPreview, this did only work when ext.math.mathjax.enabler.js was loaded in edit mode, which only happened when showing a preview with math.
  • introduce a jQuery method to render all TeX inside a jQuery collection, it hooks into the MathJax system, so will work no matter when you call it.

It can be used as $content.renderTeX( function () { alert('Done!'); } );
I don't think that the Math extension should implement it's own hook system, but wait for bug 23580. Gadgets can use code like

mw.loader.using( 'ext.math.mathjax.enabler', function () {
$newContent.renderTeX();
} );

to load the code (if this didn't already happen) and render the formulas in the new content.

Attached:

Related URL: https://gerrit.wikimedia.org/r/61182 (Gerrit Change I97800317366aafcaad87ecf6644e9417c698c5da)

https://gerrit.wikimedia.org/r/23073 (Gerrit Change Ic05659eaca35a939289bf49b17084299319d8c4d) | change ABANDONED [by TheDJ]

Related URL: https://gerrit.wikimedia.org/r/61183 (Gerrit Change I18e2f089d56e42b8e603ac45d726942bb478580b)

Related URL: https://gerrit.wikimedia.org/r/61184 (Gerrit Change I9811832430e9ddd8a4c03f265d07529a76efc38a)