Overload ShowSource.text

18 views
Skip to first unread message

XERNON XERNON

unread,
May 19, 2012, 4:06:14 AM5/19/12
to MathJax Users
Hi,
I would like to overload the MENU.ShowSource.text function in
MathMenu.js in order to display a MsgBox with Div and Css instead of a
new window.
Requirements:
I can insert a script tag before the MathJax api is initialized, cant
do it after.
Can use the Config() Function as well
I dont want MathJax to be run on the server.
The engine is WordPress, Plugin: Latex for WordPress
http://wordpress.org/extend/plugins/latex/
How can I do it? the function is already written.

Davide P. Cervone

unread,
May 19, 2012, 7:58:02 AM5/19/12
to mathja...@googlegroups.com
Add the following script to your page somewhere BEFORE the script that
loads MathJax.js:

<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("MathMenu Ready",function () {
MathJax.Menu.ShowSource.Window = function () {}; // don't open the
Show Math window
MathJax.Menu.ShowSource.Text = function (text,event) {
... your code here ...
};
});
</script>

Note that I have disabled the routine that opens the window used by
the current ShowSource.Text function, so you won't get an unwanted
window.

Add your code in the place indicated. One reason that MathJax uses a
separate window is that it is then easy to "select all" and copy the
contents of the window. That is not so easy to do with a div. You
might consider setting the selection to the contents of the div so
that is is pre-selected when the source is shown.

Davide

XERNON XERNON

unread,
May 20, 2012, 3:15:26 AM5/20/12
to MathJax Users
Thanks a lot, it worked =)
I had already in mind to preselect it, will propably add a button for
that on the MsgBox.

Davide P. Cervone

unread,
May 21, 2012, 9:12:41 AM5/21/12
to mathja...@googlegroups.com
If you are willing to share your implementation, it might help others
if you could provide the code that you used. Perhaps it could be made
into an extension that could be part of the contributed extensions
archive at

https://github.com/leathrum/mathjax-ext-contrib

Davide
Reply all
Reply to author
Forward
0 new messages