friendica-addons/mathjax/asset/extensions/a11y/explorer.js

1 line
14 KiB
JavaScript
Raw Normal View History

MathJax.Hub.Register.StartupHook("Sre Ready",function(){var a,b,c=MathJax.Hub.config.menuSettings,d={};MathJax.Hub.Register.StartupHook("MathEvents Ready",function(){a=MathJax.Extension.MathEvents.Event.False,b=MathJax.Extension.MathEvents.Event.KEY});var e=MathJax.Extension.explorer={version:"1.5.0",dependents:[],defaults:{walker:"table",highlight:"none",background:"blue",foreground:"black",speech:!0,generation:"lazy",subtitle:!1,ruleset:"mathspeak-default"},eagerComplexity:80,prefix:"Assistive-",hook:null,locHook:null,oldrules:null,addMenuOption:function(a,b){c[e.prefix+a]=b},addDefaults:function(){for(var a,b=MathJax.Hub.CombineConfig("explorer",e.defaults),d=Object.keys(b),f=0;a=d[f];f++)void 0===c[e.prefix+a]&&e.addMenuOption(a,b[a]);e.setSpeechOption(),h.Reset()},setOption:function(a,b){c[e.prefix+a]!==b&&(e.addMenuOption(a,b),h.Reset())},getOption:function(a){return c[e.prefix+a]},speechOption:function(a){e.oldrules!==a.value&&(e.setSpeechOption(),h.Regenerate())},setSpeechOption:function(){var a=c[e.prefix+"ruleset"],b=a.split("-");sre.System.getInstance().setupEngine({locale:MathJax.Localization.locale,domain:e.Domain(b[0]),style:b[1],rules:e.RuleSet(b[0])}),e.oldrules=a},Domain:function(a){switch(a){case"chromevox":return"default";case"mathspeak":default:return"mathspeak"}},RuleSet:function(a){switch(a){case"chromevox":return["AbstractionRules","SemanticTreeRules"];case"mathspeak":default:return["AbstractionRules","AbstractionSpanish","MathspeakRules","MathspeakSpanish"]}},hook:null,locHook:null,Enable:function(a,b){c.explorer=!0,b&&(d.explorer=!0),MathJax.Extension.collapsible.Enable(!1,b),MathJax.Extension.AssistiveMML&&(MathJax.Extension.AssistiveMML.config.disabled=!0,c.assistiveMML=!1,b&&(d.assistiveMML=!1)),this.DisableMenus(!1),this.hook||(this.hook=MathJax.Hub.Register.MessageHook("New Math",["Register",this.Explorer])),this.locHook||(this.locHook=MathJax.Hub.Register.MessageHook("Locale Reset",["RemoveSpeech",this.Explorer])),a&&MathJax.Hub.Queue(["Reprocess",MathJax.Hub])},Disable:function(a,b){c.explorer=!1,b&&(d.explorer=!1),this.DisableMenus(!0),this.hook&&(MathJax.Hub.UnRegister.MessageHook(this.hook),this.hook=null);for(var e=this.dependents.length-1;e>=0;e--){var f=this.dependents[e];f.Disable&&f.Disable(!1,b)}},DisableMenus:function(a){if(MathJax.Menu){var b=MathJax.Menu.menu.FindId("Accessibility","Explorer");if(b){b=b.submenu;for(var d,f=b.items,g=2;d=f[g];g++)d.disabled=a;a||!b.FindId("SpeechOutput")||c[e.prefix+"speech"]||(b.FindId("Subtitles").disabled=!0)}}},Dependent:function(a){this.dependents.push(a)}},f=MathJax.Object.Subclass({div:null,inner:null,Init:function(){this.div=f.Create("assertive"),this.inner=MathJax.HTML.addElement(this.div,"div")},Add:function(){f.added||(document.body.appendChild(this.div),f.added=!0)},Show:function(a,b){this.div.classList.add("MJX_LiveRegion_Show");var c=a.getBoundingClientRect(),d=c.bottom+10+window.pageYOffset,e=c.left+window.pageXOffset;this.div.style.top=d+"px",this.div.style.left=e+"px";var f=b.colorString();this.inner.style.backgroundColor=f.background,this.inner.style.color=f.foreground},Hide:function(a){this.div.classList.remove("MJX_LiveRegion_Show")},Clear:function(){this.Update(""),this.inner.style.top="",this.inner.style.backgroundColor=""},Update:function(a){e.getOption("speech")&&f.Update(this.inner,a)}},{ANNOUNCE:"Navigatable Math in page. Explore with shift space and arrow keys. Expand or collapse elements hitting enter.",announced:!1,added:!1,styles:{".MJX_LiveRegion":{position:"absolute",top:"0",height:"1px",width:"1px",padding:"1px",overflow:"hidden"},".MJX_LiveRegion_Show":{top:"0",position:"absolute",width:"auto",height:"auto",padding:"0px 0px",opacity:1,"z-index":"202",left:0,right:0,margin:"0 auto","background-color":"white","box-shadow":"0px 10px 20px #888",border:"2px solid #CCCCCC"}},Create:function(a){var b=MathJax.HTML.Element("div",{className:"MJX_LiveRegion"});return b.setAttribute("aria-live",a),b},Update:MathJax.Hub.Browser.isPC?function(a,b){a.textContent="",setTimeout(function(){a.textContent=b},100)}:function(a,b){a.