www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

handle-floats.js (2766B)


      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/HTML-CSS/handle-floats.js
      7  *
      8  *  This extension allows HTML-CSS output to deal with floating elements
      9  *  better.  In particular, when there are tags or equation numbers, these
     10  *  would overlap floating elements, but with this extension, the width of
     11  *  the line should properly correspond to the amount of space remaining.
     12  *  
     13  *  To load it, include
     14  *  
     15  *      "HTML-CSS": {
     16  *        extensions: ["handle-floats.js"]
     17  *      }
     18  *  
     19  *  in your configuration.
     20  *
     21  *  ---------------------------------------------------------------------
     22  *  
     23  *  Copyright (c) 2012-2015 The MathJax Consortium
     24  * 
     25  *  Licensed under the Apache License, Version 2.0 (the "License");
     26  *  you may not use this file except in compliance with the License.
     27  *  You may obtain a copy of the License at
     28  * 
     29  *      http://www.apache.org/licenses/LICENSE-2.0
     30  * 
     31  *  Unless required by applicable law or agreed to in writing, software
     32  *  distributed under the License is distributed on an "AS IS" BASIS,
     33  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     34  *  See the License for the specific language governing permissions and
     35  *  limitations under the License.
     36  */
     37 
     38 
     39 MathJax.Extension["HTML-CSS/handle-floats"] = {
     40   version: "2.6.0"
     41 };
     42 
     43 //
     44 //  Make the display DIV be a table-cell
     45 //  Use padding to get the separation, since table cells don't do margin
     46 //  Make the width large (it will shrink to fit the remaining room)
     47 //
     48 MathJax.Hub.Config({
     49   "HTML-CSS": {
     50     styles: {
     51       ".MathJax_Display": {
     52         display: "table-cell",
     53         padding: "1em 0 ! important",
     54         width: (MathJax.Hub.Browser.isMSIE && (document.documentMode||0) < 8 ? "100%" : "1000em")
     55       }
     56     }
     57   }
     58 });
     59 
     60 //
     61 //  Two consecutive equations would end up side-by-side, so force a separator
     62 //  (Needed by IE8, IE9, and Firefox, at least).
     63 //  
     64 MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
     65   var HTMLCSS = MathJax.OutputJax["HTML-CSS"],
     66       TRANSLATE = HTMLCSS.Translate;
     67   HTMLCSS.Augment({
     68     Translate: function (script,state) {
     69       TRANSLATE.apply(this,arguments);
     70       if (script.MathJax.elementJax.HTMLCSS.display) {
     71         var next = script.nextSibling;
     72         if (!next || next.className !== "MathJax_MSIE_Separator") {
     73           var span = HTMLCSS.Element("span",{className:"MathJax_MSIE_Separator"});
     74           script.parentNode.insertBefore(span,next);
     75         }
     76       }
     77     }
     78   });
     79   MathJax.Hub.Startup.signal.Post("HTML-CSS handle-floats Ready");
     80 });
     81 
     82 MathJax.Ajax.loadComplete("[MathJax]/extensions/HTML-CSS/handle-floats.js");