/* * /MathJax/extensions/a11y/auto-collapse.js * * Copyright (c) 2009-2018 The MathJax Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ !function(f){var d=f.config.menuSettings,e={},b=MathJax.Ajax.config.path;b.a11y||(b.a11y=f.config.root+"/extensions/a11y");var a=MathJax.Extension["auto-collapse"]={version:"1.6.0",config:f.CombineConfig("auto-collapse",{disabled:!1}),dependents:[],Enable:function(c,g){d.autocollapse=!0,g&&(e.autocollapse=!0),this.config.disabled=!1,MathJax.Extension.collapsible.Enable(!1,g),c&&f.Queue(["Reprocess",f],["CollapseWideMath",this])},Disable:function(c,g){d.autocollapse=!1,g&&(e.autocollapse=!1),this.config.disabled=!0;for(var i=this.dependents.length-1;0<=i;i--){var h=this.dependents[i];h.Disable&&h.Disable(!1,g)}c&&f.Queue(["Rerender",f])},Dependent:function(c){this.dependents.push(c)},Startup:function(){var c=MathJax.Extension.collapsible;c&&c.Dependent(this),f.postInputHooks.Add(["Filter",a],150),f.Queue(function(){return a.CollapseWideMath()}),window.addEventListener?window.addEventListener("resize",a.resizeHandler,!1):window.attachEvent?window.attachEvent("onresize",a.resizeHandler):window.onresize=a.resizeHandler},Filter:function(c,g,h){c.enriched&&!this.config.disabled&&("block"===c.root.Get("display")||h.parentNode.childNodes.length<=3)&&(c.root.SRE={action:this.Actions(c.root)})},Actions:function(c){var g=[];return this.getActions(c,0,g),this.sortActions(g)},getActions:function(h,j,l){if(!h.isToken&&h.data){j++;for(var k,g=0,c=h.data.length;gj.M)){var c=this.getActionWidths(k,g);if(c){return c}this.collapseActions(j,g),g.changed&&h.push(k.SourceElement())}g.i++}if(0!==h.length){return 1===h.length&&(h=h[0]),f.Rerender(h)}},collapseActions:function(h,l){for(var p=h.width,m=p,g=1000000,c=h.action.length-1;0<=c;c--){var j=h.action[c],k=j.selection;p>h.cwidth?(j.selection=1,m=j.SREwidth,g=p):j.selection=2,p=j.SREwidth,h.DOMupdate?document.getElementById(j.id).setAttribute("selection",j.selection):j.selection!==k&&(l.changed=!0)}h.m=m,h.M=g},getActionWidths:function(c,g){if(!c.root.SRE.actionWidths){MathJax.OutputJax[c.outputJax].getMetrics(c);try{this.computeActionWidths(c)}catch(c){if(!c.restart){throw c}return MathJax.Callback.After(["collapseState",this,g],c.restart)}g.changed=!0}return null},computeActionWidths:function(h){var j,l=h.root.SRE,k=l.action,g={};for(l.width=h.sreGetRootWidth(g),j=k.length-1;0<=j;j--){k[j].selection=2}for(j=k.length-1;0<=j;j--){var c=k[j];null==c.SREwidth&&(c.selection=1,c.SREwidth=h.sreGetActionWidth(g,c))}l.actionWidths=!0},GetContainerWidths:function(q){for(var m,h,g,k=f.getAllJax(q),p=MathJax.HTML.Element("span",{style:{display:"block"}}),u=[],c=0,j=k.length;c