action.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
  2. /* vim: set ts=2 et sw=2 tw=80: */
  3. /*************************************************************
  4. *
  5. * MathJax/extensions/TeX/action.js
  6. *
  7. * Implements the \mathtip, \texttip, and \toggle macros, which give
  8. * access from TeX to the <maction> tag in the MathML that underlies
  9. * MathJax's internal format.
  10. *
  11. * Usage:
  12. *
  13. * \mathtip{math}{tip} % use "tip" (in math mode) as tooltip for "math"
  14. * \texttip{math}{tip} % use "tip" (in text mode) as tooltip for "math"
  15. * \toggle{math1}{math2}...\endtoggle
  16. * % show math1, and when clicked, show math2, and so on.
  17. * % When the last one is clicked, go back to math1.
  18. *
  19. * ---------------------------------------------------------------------
  20. *
  21. * Copyright (c) 2011-2013 The MathJax Consortium
  22. *
  23. * Licensed under the Apache License, Version 2.0 (the "License");
  24. * you may not use this file except in compliance with the License.
  25. * You may obtain a copy of the License at
  26. *
  27. * http://www.apache.org/licenses/LICENSE-2.0
  28. *
  29. * Unless required by applicable law or agreed to in writing, software
  30. * distributed under the License is distributed on an "AS IS" BASIS,
  31. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  32. * See the License for the specific language governing permissions and
  33. * limitations under the License.
  34. */MathJax.Extension["TeX/action"]={version:"2.2"};MathJax.Hub.Register.StartupHook("TeX Jax Ready",function(){var d=MathJax.InputJax.TeX,b=MathJax.ElementJax.mml;d.Definitions.Add({macros:{toggle:"Toggle",mathtip:"Mathtip",texttip:["Macro","\\mathtip{#1}{\\text{#2}}",2]}},null,!0);d.Parse.Augment({Toggle:function(a){for(var c=[],e;"\\endtoggle"!==(e=this.GetArgument(a));)c.push(d.Parse(e,this.stack.env).mml());this.Push(b.maction.apply(b,c).With({actiontype:b.ACTIONTYPE.TOGGLE}))},Mathtip:function(a){var c=this.ParseArg(a);a=this.ParseArg(a);this.Push(b.maction(c,a).With({actiontype:b.ACTIONTYPE.TOOLTIP}))}});MathJax.Hub.Startup.signal.Post("TeX action Ready")});MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/action.js");