| 1 |
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ |
| 2 |
/* vim: set ts=2 et sw=2 tw=80: */ |
| 3 |
|
| 4 |
/************************************************************* |
| 5 |
* |
| 6 |
* MathJax/extensions/TeX/action.js |
| 7 |
* |
| 8 |
* Implements the \mathtip, \texttip, and \toggle macros, which give |
| 9 |
* access from TeX to the <maction> tag in the MathML that underlies |
| 10 |
* MathJax's internal format. |
| 11 |
* |
| 12 |
* Usage: |
| 13 |
* |
| 14 |
* \mathtip{math}{tip} % use "tip" (in math mode) as tooltip for "math" |
| 15 |
* \texttip{math}{tip} % use "tip" (in text mode) as tooltip for "math" |
| 16 |
* \toggle{math1}{math2}...\endtoggle |
| 17 |
* % show math1, and when clicked, show math2, and so on. |
| 18 |
* % When the last one is clicked, go back to math1. |
| 19 |
* |
| 20 |
* --------------------------------------------------------------------- |
| 21 |
* |
| 22 |
* Copyright (c) 2011-2020 The MathJax Consortium |
| 23 |
* |
| 24 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 25 |
* you may not use this file except in compliance with the License. |
| 26 |
* You may obtain a copy of the License at |
| 27 |
* |
| 28 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 29 |
* |
| 30 |
* Unless required by applicable law or agreed to in writing, software |
| 31 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 32 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 33 |
* See the License for the specific language governing permissions and |
| 34 |
* limitations under the License. |
| 35 |
*/ |
| 36 |
|
| 37 |
MathJax.Extension["TeX/action"] = { |
| 38 |
version: "2.7.9" |
| 39 |
}; |
| 40 |
|
| 41 |
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { |
| 42 |
var TEX = MathJax.InputJax.TeX, |
| 43 |
MML = MathJax.ElementJax.mml; |
| 44 |
|
| 45 |
// |
| 46 |
// Set up control sequenecs |
| 47 |
// |
| 48 |
TEX.Definitions.Add({ |
| 49 |
macros: { |
| 50 |
toggle: 'Toggle', |
| 51 |
mathtip: 'Mathtip', |
| 52 |
texttip: ['Macro','\\mathtip{#1}{\\text{#2}}',2] |
| 53 |
} |
| 54 |
},null,true); |
| 55 |
|
| 56 |
TEX.Parse.Augment({ |
| 57 |
|
| 58 |
// |
| 59 |
// Implement \toggle {math1} {math2} ... \endtoggle |
| 60 |
// (as an <maction actiontype="toggle">) |
| 61 |
// |
| 62 |
Toggle: function (name) { |
| 63 |
var data = [], arg; |
| 64 |
while ((arg = this.GetArgument(name)) !== "\\endtoggle") |
| 65 |
{data.push(TEX.Parse(arg,this.stack.env).mml())} |
| 66 |
this.Push(MML.maction.apply(MML,data).With({actiontype: MML.ACTIONTYPE.TOGGLE})); |
| 67 |
}, |
| 68 |
|
| 69 |
// |
| 70 |
// Implement \mathtip{math}{tip} |
| 71 |
// (an an <maction actiontype="tooltip">) |
| 72 |
// |
| 73 |
Mathtip: function(name) { |
| 74 |
var arg = this.ParseArg(name), tip = this.ParseArg(name); |
| 75 |
this.Push(MML.maction(arg,tip).With({actiontype: MML.ACTIONTYPE.TOOLTIP})); |
| 76 |
} |
| 77 |
}); |
| 78 |
|
| 79 |
MathJax.Hub.Startup.signal.Post("TeX action Ready"); |
| 80 |
|
| 81 |
}); |
| 82 |
|
| 83 |
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/action.js"); |