/* * /MathJax/extensions/a11y/collapsible.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(d){var g,a=d.config.menuSettings,f={},e="data-semantic-complexity",b=MathJax.Ajax.config.path;b.a11y||(b.a11y=d.config.root+"/extensions/a11y");var c=MathJax.Extension.collapsible={version:"1.6.0",config:d.CombineConfig("collapsible",{disabled:!1}),dependents:[],COMPLEXATTR:e,COMPLEXITY:{TEXT:0.5,TOKEN:0.5,CHILD:1,SCRIPT:0.8,SQRT:2,SUBSUP:2,UNDEROVER:2,FRACTION:2,ACTION:2,PHANTOM:0,XML:2,GLYPH:2},COLLAPSE:{identifier:3,number:3,text:10,infixop:15,relseq:15,multirel:15,fenced:18,bigop:20,integral:20,fraction:12,sqrt:9,root:12,vector:15,matrix:15,cases:15,superscript:9,subscript:9,subsup:9,punctuated:{endpunct:10000000,startpunct:10000000,value:12}},MARKER:{identifier:"x",number:"#",text:"...",appl:{"limit function":"lim",value:"f()"},fraction:"/",sqrt:"\u221a",root:"\u221a",superscript:"\u25fd\u02d9",subscript:"\u25fd.",subsup:"\u25fd:",vector:{binomial:"(:)",determinant:"|:|",value:"\u27e8:\u27e9"},matrix:{squarematrix:"[::]",rowvector:"\u27e8\u22ef\u27e9",columnvector:"\u27e8\u22ee\u27e9",determinant:"|::|",value:"(::)"},cases:"{:",infixop:{addition:"+",subtraction:"\u2212",multiplication:"\u22c5",implicit:"\u22c5",value:"+"},punctuated:{text:"...",value:","}},Enable:function(j,h){a.collapsible=!0,h&&(f.collapsible=!0),this.config.disabled=!1,MathJax.Extension["semantic-enrich"].Enable(!1,h),j&&d.Queue(["Reprocess",d])},Disable:function(k,j){a.collapsible=!1,j&&(f.collapsible=!1),this.config.disabled=!0;for(var l=this.dependents.length-1;0<=l;l--){var h=this.dependents[l];h.Disable&&h.Disable(!1,j)}k&&d.Queue(["Reprocess",d])},Dependent:function(h){this.dependents.push(h)},Startup:function(){g=MathJax.ElementJax.mml;var h=MathJax.Extension["semantic-enrich"];h&&h.Dependent(this),d.postInputHooks.Add(["Filter",c],100)},Filter:function(j,h,k){j.enriched&&!this.config.disabled&&(j.root=j.root.Collapse(),j.root.inputID=k.id)},Marker:function(h){return g.mtext("\u25c2"+h+"\u25b8").With({mathcolor:"blue",attr:{},attrNames:[]})},MakeAction:function(m,k){var o=g.maction(m).With({id:this.getActionID(),actiontype:"toggle",complexity:m.getComplexity(),collapsible:!0,attrNames:["id","actiontype","selection",e],attr:{},selection:2});if(o.attr[e]=o.complexity,"math"===k.type){var j=g.mrow().With({complexity:k.complexity,attrNames:[],attr:{}});j.Append.apply(j,k.data[0].data),k.data[0].data=[];for(var n,h=k.attrNames.length-1;n=k.attrNames[h];h--){"data-semantic-"===n.substr(0,14)&&(j.attr[n]=k.attr[n],j.attrNames.push(n),delete k.attr[n],k.attrNames.splice(h,1))}j.complexity=k.complexity,o.Append(j),k.Append(o),k.complexity=o.complexity,o=k}else{o.Append(k)}return o},actionID:1,getActionID:function(){return"MJX-Collapse-"+this.actionID++},Collapse:function(k){k.getComplexity();var j,m,h,l=(k.attr||{})["data-semantic-type"];return l&&(this["Collapse_"+l]?k=this["Collapse_"+l](k):this.COLLAPSE[l]&&this.MARKER[l]&&(j=k.attr["data-semantic-role"],"number"!=typeof(m=this.COLLAPSE[l])&&(m=m[j]||m.value),k.complexity>m&&("string"!=typeof(h=this.MARKER[l])&&(h=h[j]||h.value),k=this.MakeAction(this.Marker(h),k)))),k},UncollapseChild:function(k,j,l){if(null==l&&(l=1),this.SplitAttribute(k,"children").length===l){var h=1===k.data.length&&k.data[0].inferred?k.data[0]:k;if(h&&h.data[j]&&h.data[j].collapsible){return h.SetData(j,h.data[j].data[1]),k.complexity=h.complexity=null,k.getComplexity(),1}}return 0},FindChildText:function(j,h){var k=this.FindChild(j,h);return k?(k.CoreMO()||k).data.join(""):"?"},FindChild:function(k,j){if(k){if(k.attr&&k.attr["data-semantic-id"]===j){return k}if(!k.isToken){for(var m=0,h=k.data.length;mthis.COLLAPSE.fenced&&"leftright"===j.attr["data-semantic-role"]&&(h=j.data[0].data.join("")+j.data[j.data.length-1].data.join(""),j=this.MakeAction(this.Marker(h),j)),j},Collapse_appl:function(j){var h;return this.UncollapseChild(j,2,2)&&(h=(h=this.MARKER.appl)[j.attr["data-semantic-role"]]||h.value,j=this.MakeAction(this.Marker(h),j)),j},Collapse_sqrt:function(h){return this.UncollapseChild(h,0),h.complexity>this.COLLAPSE.sqrt&&(h=this.MakeAction(this.Marker(this.MARKER.sqrt),h)),h},Collapse_root:function(h){return this.UncollapseChild(h,0),h.complexity>this.COLLAPSE.sqrt&&(h=this.MakeAction(this.Marker(this.MARKER.sqrt),h)),h},Collapse_enclose:function(j){var h,k;return 1!==this.SplitAttribute(j,"children").length||(h=1===j.data.length&&j.data[0].inferred?j.data[0]:j).data[0]&&h.data[0].collapsible&&(k=h.data[0],h.SetData(0,k.data[1]),k.SetData(1,j),j=k),j},Collapse_bigop:function(j){var h,k;return(j.complexity>this.COLLAPSE.bigop||"mo"!==j.data[0].type)&&(h=this.SplitAttribute(j,"content").pop(),k=c.FindChildText(j,h),j=this.MakeAction(this.Marker(k),j)),j},Collapse_integral:function(j){var h,k;return(j.complexity>this.COLLAPSE.integral||"mo"!==j.data[0].type)&&(h=this.SplitAttribute(j,"content")[0],k=c.FindChildText(j,h),j=this.MakeAction(this.Marker(k),j)),j},Collapse_relseq:function(j){var h,k;return j.complexity>this.COLLAPSE.relseq&&(h=this.SplitAttribute(j,"content"),k=c.FindChildText(j,h[0]),1this.COLLAPSE.multirel&&(h=this.SplitAttribute(j,"content"),k=c.FindChildText(j,h[0])+"\u22ef",j=this.MakeAction(this.Marker(k),j)),j},Collapse_superscript:function(h){return this.UncollapseChild(h,0,2),h.complexity>this.COLLAPSE.superscript&&(h=this.MakeAction(this.Marker(this.MARKER.superscript),h)),h},Collapse_subscript:function(h){return this.UncollapseChild(h,0,2),h.complexity>this.COLLAPSE.subscript&&(h=this.MakeAction(this.Marker(this.MARKER.subscript),h)),h},Collapse_subsup:function(h){return this.UncollapseChild(h,0,3),h.complexity>this.COLLAPSE.subsup&&(h=this.MakeAction(this.Marker(this.MARKER.subsup),h)),h}};d.Register.StartupHook("End Extensions",function(){null==a.collapsible?a.collapsible=!c.config.disabled:c.config.disabled=!a.collapsible,d.Register.StartupHook("MathMenu Ready",function(){f=MathJax.Menu.cookie;var k,j=MathJax.Menu.ITEM,m=MathJax.Menu.menu,h=j.CHECKBOX(["CollapsibleMath","Collapsible Math"],"collapsible",{action:function(i){c[a.collapsible?"Enable":"Disable"](!0,!0),MathJax.Menu.saveCookie()}}),l=(m.FindId("Accessibility")||{}).submenu;l?null!==(k=l.IndexOfId("CollapsibleMath"))?l.items[k]=h:l.items.push(j.RULE(),h):(k=m.IndexOfId("About"),m.items.splice(k,0,h,j.RULE()))},15)},15)}(MathJax.Hub),MathJax.Ajax.Require("[a11y]/semantic-enrich.js"),MathJax.Hub.Register.StartupHook("Semantic Enrich Ready",function(){var d=MathJax.ElementJax.mml,c=MathJax.Extension.collapsible,b=c.COMPLEXITY,e=c.COMPLEXATTR;c.Startup(),d.mbase.Augment({Collapse:function(){return c.Collapse(this)},getComplexity:function(){if(null==this.complexity){var f=0;if(this.isToken){f=b.TEXT*this.data.join("").length+b.TOKEN}else{for(var a=0,g=this.data.length;a