scribble-mathjax/docs/html/api/jax.html
2011-07-20 15:56:58 -04:00

326 lines
17 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The Base Jax Class &mdash; MathJax v1.1 documentation</title>
<link rel="stylesheet" href="../_static/mj.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '1.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<!--<script type="text/javascript" src="../../../MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>-->
<link rel="top" title="MathJax v1.1 documentation" href="../index.html" />
<link rel="up" title="The MathJax API" href="index.html" />
<link rel="next" title="The MathJax Object-Oriented Programming Model" href="object.html" />
<link rel="prev" title="The MathJax.ElementJax Class" href="elementjax.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="object.html" title="The MathJax Object-Oriented Programming Model"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="elementjax.html" title="The MathJax.ElementJax Class"
accesskey="P">previous</a> |</li>
<li><a href="../index.html">MathJax v1.1 documentation</a> &raquo;</li>
<li><a href="index.html" accesskey="U">The MathJax API</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="the-base-jax-class">
<span id="api-jax"></span><h1>The Base Jax Class<a class="headerlink" href="#the-base-jax-class" title="Permalink to this headline"></a></h1>
<p>The <cite>MathJax.InputJax</cite>, <cite>MathJax.OutputJax</cite> and <cite>MathJax.ElementJax</cite>
classes are all subclasses of the base <cite>Jax</cite> class in MathJax. This
is a private class that implements the methods common to all three
other jax classes.</p>
<p>Unlike most MathJax.Object classes, calling the class object creates a
<em>subclass</em> of the class, rather than an instance of the class. E.g.,</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">MathJax</span><span class="p">.</span><span class="nx">InputJax</span><span class="p">.</span><span class="nx">MyInputJax</span> <span class="o">=</span> <span class="nx">MathJax</span><span class="p">.</span><span class="nx">InputJax</span><span class="p">({</span>
<span class="nx">id</span><span class="o">:</span> <span class="s2">&quot;MyInputJax&quot;</span><span class="p">,</span>
<span class="nx">version</span><span class="o">:</span> <span class="s2">&quot;1.0&quot;</span><span class="p">,</span>
<span class="p">...</span>
<span class="p">});</span>
</pre></div>
</div>
<p>creates <tt class="docutils literal"><span class="pre">MathJax.InputJax.MyInputJax</span></tt> as a subclass of <tt class="docutils literal"><span class="pre">MathJax.InputJax</span></tt>.</p>
<div class="section" id="class-properties">
<h2>Class Properties<a class="headerlink" href="#class-properties" title="Permalink to this headline"></a></h2>
<dl class="describe">
<dt>
<tt class="descname">directory</tt></dt>
<dd><p>The name of the jax directory (usually <tt class="docutils literal"><span class="pre">&quot;[MathJax]/jax&quot;</span></tt>).
Overridden in the subclass to be the specific directory for the
class, e.g. <tt class="docutils literal"><span class="pre">&quot;[MathJax]/jax/input&quot;</span></tt>.</p>
</dd></dl>
<dl class="describe">
<dt>
<tt class="descname">extensionDir</tt></dt>
<dd><p>The name of the extensions directory (usually <tt class="docutils literal"><span class="pre">&quot;[MathJax]/extensions&quot;</span></tt>).</p>
</dd></dl>
</div>
<div class="section" id="instance-properties">
<h2>Instance Properties<a class="headerlink" href="#instance-properties" title="Permalink to this headline"></a></h2>
<dl class="describe">
<dt>
<tt class="descname">id</tt></dt>
<dd><p>The name of the jax.</p>
</dd></dl>
<dl class="describe">
<dt>
<tt class="descname">version</tt></dt>
<dd><p>The version number of the jax.</p>
</dd></dl>
<dl class="describe">
<dt>
<tt class="descname">directory</tt></dt>
<dd><p>The directory for the jax (e.g., <tt class="docutils literal"><span class="pre">&quot;[MathJax]/jax/input/TeX&quot;</span></tt>).</p>
</dd></dl>
<dl class="describe">
<dt>
<tt class="descname">require: null</tt></dt>
<dd><p>An array of files to load before the <tt class="docutils literal"><span class="pre">jax.js</span></tt> file calls the
<tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Ajax.loadComplete()</span></tt> method.</p>
</dd></dl>
<dl class="describe">
<dt>
<tt class="descname">config: {}</tt></dt>
<dd><p>An object that contains the default configuration options for the
jax. These can be modified by the author by including a
configuration subsection for the specific jax in question.</p>
</dd></dl>
</div>
<div class="section" id="methods">
<h2>Methods<a class="headerlink" href="#methods" title="Permalink to this headline"></a></h2>
<dl class="method">
<dt>
<tt class="descname">Process</tt><big>(</big><em>script</em><big>)</big></dt>
<dd><p>This is the method that the <tt class="docutils literal"><span class="pre">MathJax.Hub</span></tt> calls when it needs the
input or output jax to process the given math <tt class="docutils literal"><span class="pre">&lt;script&gt;</span></tt>. Its
default action is to start loading the jax&#8217;s <tt class="docutils literal"><span class="pre">jax.js</span></tt> file, and
redefine itself to simply return the callback for the load operation
(so that further calls to it will cause the processing to wait for the
callback). Once the <tt class="docutils literal"><span class="pre">jax.js</span></tt> file has loaded, this method is
replaced by the jax&#8217;s <a class="reference internal" href="#Translate" title="Translate"><tt class="xref py py-meth docutils literal"><span class="pre">Translate()</span></tt></a> method, so that subsequent calls
to <a class="reference internal" href="hub.html#Process" title="Process"><tt class="xref py py-meth docutils literal"><span class="pre">Process()</span></tt></a> will perform the appropriate translation.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first">
<li><dl class="first docutils">
<dt><strong>script</strong> &#8212; reference to the DOM <tt class="docutils literal"><span class="pre">&lt;script&gt;</span></tt> object for</dt>
<dd><p class="first last">the mathematics to be translated</p>
</dd>
</dl>
</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last">an <cite>ElementJax</cite> object, or <tt class="docutils literal"><span class="pre">null</span></tt></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="Translate">
<tt class="descname">Translate</tt><big>(</big><em>script</em><big>)</big><a class="headerlink" href="#Translate" title="Permalink to this definition"></a></dt>
<dd><p>This is a stub for a routine that should be defined by the jax&#8217;s
<tt class="docutils literal"><span class="pre">jax.js</span></tt> file when it is loaded. It should perform the translation
action for the specific jax. For an input jax, it should return the
<cite>ElementJax</cite> object that it created. The <a class="reference internal" href="#Translate" title="Translate"><tt class="xref py py-meth docutils literal"><span class="pre">Translate()</span></tt></a> method is
never called directly by MathJax; during the <a class="reference internal" href="ajax.html#loadComplete" title="loadComplete"><tt class="xref py py-meth docutils literal"><span class="pre">loadComplete()</span></tt></a>
call, this function is copied to the <a class="reference internal" href="hub.html#Process" title="Process"><tt class="xref py py-meth docutils literal"><span class="pre">Process()</span></tt></a> method, and is
called via that name. The default <a class="reference internal" href="#Translate" title="Translate"><tt class="xref py py-meth docutils literal"><span class="pre">Translate()</span></tt></a> method throws an
error indicating that the <a class="reference internal" href="#Translate" title="Translate"><tt class="xref py py-meth docutils literal"><span class="pre">Translate()</span></tt></a> method was not
redefined. That way, if the <tt class="docutils literal"><span class="pre">jax.js</span></tt> file fails to load for some
reason, you will receive an error trying to process mathematics with
this jax.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first">
<li><dl class="first docutils">
<dt><strong>script</strong> &#8212; reference to the DOM <tt class="docutils literal"><span class="pre">&lt;script&gt;</span></tt> object for</dt>
<dd><p class="first last">the mathematics to be translated</p>
</dd>
</dl>
</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last">an <cite>ElementJax</cite> object, or <tt class="docutils literal"><span class="pre">null</span></tt></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="Register">
<tt class="descname">Register</tt><big>(</big><em>mimetype</em><big>)</big><a class="headerlink" href="#Register" title="Permalink to this definition"></a></dt>
<dd><p>This method is overridden in the <cite>InputJax</cite>, <cite>OutputJax</cite> and
<cite>ElementJax</cite> subclasses to handle the registration of those
classes of jax.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
<li><strong>mimetype</strong> &#8212; the MIME-type to be associated with the jax</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last"><tt class="docutils literal"><span class="pre">null</span></tt></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">Config</tt><big>(</big><big>)</big></dt>
<dd><p>Inserts the configuration block for this jax from the author&#8217;s
configuration specification into the jax&#8217;s <tt class="docutils literal"><span class="pre">config</span></tt> property.
If the configuration includes an <tt class="docutils literal"><span class="pre">Augment</span></tt> object, that is used
to augment the jax (that is, the configuration can override the
methods of the object, as well as the data). This is called
automatically during the loading of the <tt class="docutils literal"><span class="pre">jax.js</span></tt> file.</p>
</dd></dl>
<dl class="method">
<dt id="Startup">
<tt class="descname">Startup</tt><big>(</big><big>)</big><a class="headerlink" href="#Startup" title="Permalink to this definition"></a></dt>
<dd><p>This is a method that can be overridden in the subclasses to
perform initialization at startup time (after the configuration
has occurred).</p>
</dd></dl>
<dl class="method">
<dt>
<tt class="descname">loadComplete</tt><big>(</big><em>file</em><big>)</big></dt>
<dd><p>This is called by the <tt class="docutils literal"><span class="pre">config.js</span></tt> and <tt class="docutils literal"><span class="pre">jax.js</span></tt> files when they
are completely loaded and are ready to signal that fact to
MathJax. For <tt class="docutils literal"><span class="pre">config.js</span></tt>, this simply calls the
<tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Ajax.loadComplete()</span></tt> method for the <tt class="docutils literal"><span class="pre">config.js</span></tt>
file. For <tt class="docutils literal"><span class="pre">jax.js</span></tt>, the actions performed here are the
following:</p>
<blockquote>
<div><ol class="arabic simple">
<li>Post the &#8220;[name] Jax Config&#8221; message to the startup signal.</li>
<li>Perform the jax&#8217;s <a class="reference internal" href="hub.html#Config" title="Config"><tt class="xref py py-meth docutils literal"><span class="pre">Config()</span></tt></a> method.</li>
<li>Post the &#8220;[name] Jax Require&#8221; message to the startup signal.</li>
<li>Load the files from the jax&#8217;s <tt class="docutils literal"><span class="pre">require</span></tt> and
<tt class="docutils literal"><span class="pre">config.extensions</span></tt> arrays.</li>
<li>Post the &#8220;[name] Jax Startup&#8221; message to the startup signal.</li>
<li>Perform the jax&#8217;s <a class="reference internal" href="#Startup" title="Startup"><tt class="xref py py-meth docutils literal"><span class="pre">Startup()</span></tt></a> method.</li>
<li>Post the &#8220;[name] Jax Ready&#8221; message to the startup signal.</li>
<li>Perform the <tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Ajax.loadComplete()</span></tt> call for the
<tt class="docutils literal"><span class="pre">jax.js</span></tt> file.</li>
</ol>
</div></blockquote>
<p>Note that the configuration process (the <a class="reference internal" href="hub.html#Config" title="Config"><tt class="xref py py-meth docutils literal"><span class="pre">Config()</span></tt></a> call) can
modify the <tt class="docutils literal"><span class="pre">require</span></tt> or <tt class="docutils literal"><span class="pre">config.extensions</span></tt> arrays to add more
files that need to be loaded, and that the <a class="reference internal" href="#Startup" title="Startup"><tt class="xref py py-meth docutils literal"><span class="pre">Startup()</span></tt></a> method
isn&#8217;t called until those files are completely loaded.</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">The Base Jax Class</a><ul>
<li><a class="reference internal" href="#class-properties">Class Properties</a></li>
<li><a class="reference internal" href="#instance-properties">Instance Properties</a></li>
<li><a class="reference internal" href="#methods">Methods</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="elementjax.html"
title="previous chapter">The MathJax.ElementJax Class</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="object.html"
title="next chapter">The MathJax Object-Oriented Programming Model</a></p>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="object.html" title="The MathJax Object-Oriented Programming Model"
>next</a> |</li>
<li class="right" >
<a href="elementjax.html" title="The MathJax.ElementJax Class"
>previous</a> |</li>
<li><a href="../index.html">MathJax v1.1 documentation</a> &raquo;</li>
<li><a href="index.html" >The MathJax API</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2011 Design Science.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
</div>
</body>
</html>