123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- (function (HUB,HTML) {
- var VERSION = "2.2";
- var STIXURL = "http://www.stixfonts.org/";
- var MATHJAXURL = "https://github.com/mathjax/MathJax/tree/master/fonts/HTML-CSS/TeX/otf";
-
- var CONFIG = HUB.CombineConfig("FontWarnings",{
-
-
-
- messageStyle: {
- position:"fixed", bottom:"4em", left:"3em", width:"40em",
- border: "3px solid #880000", "background-color": "#E0E0E0", color: "black",
- padding: "1em", "font-size":"small", "white-space":"normal",
-
- "border-radius": ".75em",
- "-webkit-border-radius": ".75em",
- "-moz-border-radius": ".75em",
- "-khtml-border-radius": ".75em",
- "box-shadow": "4px 4px 10px #AAAAAA",
- "-webkit-box-shadow": "4px 4px 10px #AAAAAA",
- "-moz-box-shadow": "4px 4px 10px #AAAAAA",
- "-khtml-box-shadow": "4px 4px 10px #AAAAAA",
- filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=3, OffY=3, Color='gray', Positive='true')"
- },
-
-
-
-
- Message: {
- webFont: [
- ["closeBox"],
- ["webFont",
- "MathJax is using web-based fonts to display the mathematics "+
- "on this page. These take time to download, so the page would "+
- "render faster if you installed math fonts directly in your "+
- "system's font folder."],
- ["fonts"]
- ],
- imageFonts: [
- ["closeBox"],
- ["imageFonts",
- "MathJax is using its image fonts rather than local or web-based fonts. "+
- "This will render slower than usual, and the mathematics may not print "+
- "at the full resolution of your printer."],
- ["fonts"],
- ["webfonts"]
- ],
-
- noFonts: [
- ["closeBox"],
- ["noFonts",
- "MathJax is unable to locate a font to use to display "+
- "its mathematics, and image fonts are not available, so it "+
- "is falling back on generic unicode characters in hopes that "+
- "your browser will be able to display them. Some characters "+
- "may not show up properly, or possibly not at all."],
- ["fonts"],
- ["webfonts"]
- ]
- },
-
-
-
-
- HTML: {
-
-
-
- closeBox: [[
- "div",{
- style: {
- position:"absolute", overflow:"hidden", top:".1em", right:".1em",
- border: "1px outset", width:"1em", height:"1em",
- "text-align": "center", cursor: "pointer",
- "background-color": "#EEEEEE", color:"#606060",
- "border-radius": ".5em",
- "-webkit-border-radius": ".5em",
- "-moz-border-radius": ".5em",
- "-khtml-border-radius": ".5em"
- },
- onclick: function () {
- if (DATA.div && DATA.fade === 0)
- {if (DATA.timer) {clearTimeout(DATA.timer)}; DATA.div.style.display = "none"}
- }
- },
- [["span",{style:{position:"relative", bottom:".2em"}},["x"]]]
- ]],
-
- webfonts: [
- ["p"],
- ["webfonts",
- "Most modern browsers allow for fonts to be downloaded over the web. "+
- "Updating to a more recent version of your browser (or changing "+
- "browsers) could improve the quality of the mathematics on this page."
- ]
- ],
-
- fonts: [
- ["p"],
- ["fonts",
- "MathJax can use either the [STIX fonts](%1) or the [MathJax TeX fonts](%2). " +
- "Download and install one of those fonts to improve your MathJax experience.",
- STIXURL,MATHJAXURL
- ]
- ],
-
- STIXfonts: [
- ["p"],
- ["STIXPage",
- "This page is designed to use the [STIX fonts](%1). " +
- "Download and install those fonts to improve your MathJax experience.",
- STIXURL
- ]
- ],
- TeXfonts: [
- ["p"],
- ["TeXPage",
- "This page is designed to use the [MathJax TeX fonts](%1). " +
- "Download and install those fonts to improve your MathJax experience.",
- MATHJAXURL
- ]
- ]
-
- },
-
- removeAfter: 12*1000,
- fadeoutSteps: 10,
- fadeoutTime: 1.5*1000
- });
- if (MathJax.Hub.Browser.isIE9 && document.documentMode >= 9)
- {delete CONFIG.messageStyle.filter}
-
-
-
- var DATA = {
- div: null,
- fade: 0
- };
-
-
-
-
- var CREATEMESSAGE = function (data) {
- if (DATA.div) return;
- var HTMLCSS = MathJax.OutputJax["HTML-CSS"], frame = document.body;
- if (HUB.Browser.isMSIE) {
- if (CONFIG.messageStyle.position === "fixed") {
- MathJax.Message.Init();
- frame = document.getElementById("MathJax_MSIE_Frame");
- CONFIG.messageStyle.position = "absolute";
- }
- } else {delete CONFIG.messageStyle.filter}
- CONFIG.messageStyle.maxWidth = (document.body.clientWidth-75) + "px";
- var i = 0; while (i < data.length) {
- if (data[i] instanceof Array) {
- if (data[i].length === 1 && CONFIG.HTML[data[i][0]]) {
- data.splice.apply(data,[i,1].concat(CONFIG.HTML[data[i][0]]));
- } else if (typeof data[i][1] === "string") {
- var message = MathJax.Localization.lookupPhrase(["FontWarnings",data[i][0]],data[i][1]);
- message = MathJax.Localization.processString(message,data[i].slice(2),"FontWarnings");
- data.splice.apply(data,[i,1].concat(message));
- i += message.length;
- } else {i++}
- } else {i++}
- }
- DATA.div = HTMLCSS.addElement(frame,"div",
- {id:"MathJax_FontWarning",style:CONFIG.messageStyle},data);
- MathJax.Localization.setCSS(DATA.div);
- if (CONFIG.removeAfter) {
- HUB.Register.StartupHook("End",function ()
- {DATA.timer = setTimeout(FADEOUT,CONFIG.removeAfter)});
- }
- HTML.Cookie.Set("fontWarn",{warned:true});
- };
-
-
-
-
-
- var FADEOUT = function () {
- DATA.fade++; if (DATA.timer) {delete DATA.timer}
- if (DATA.fade < CONFIG.fadeoutSteps) {
- var opacity = 1 - DATA.fade/CONFIG.fadeoutSteps;
- DATA.div.style.opacity = opacity;
- DATA.div.style.filter = "alpha(opacity="+Math.floor(100*opacity)+")";
- setTimeout(FADEOUT,CONFIG.fadeoutTime/CONFIG.fadeoutSteps);
- } else {
- DATA.div.style.display = "none";
- }
- };
-
-
-
-
- if (!HTML.Cookie.Get("fontWarn").warned) {
-
-
-
-
- HUB.Startup.signal.Interest(function (message) {
- if (message.match(/HTML-CSS Jax - /) && !DATA.div) {
- var HTMLCSS = MathJax.OutputJax["HTML-CSS"], FONTS = HTMLCSS.config.availableFonts, MSG;
- var localFonts = (FONTS && FONTS.length);
- if (!localFonts) {CONFIG.HTML.fonts = [""]}
- else if (FONTS.length === 1) {CONFIG.HTML.fonts = CONFIG.HTML[FONTS[0]+"fonts"]}
- if (HTMLCSS.allowWebFonts) {CONFIG.HTML.webfonts = [""]}
- if (message.match(/- Web-Font/)) {if (localFonts) {MSG = "webFont"}}
- else if (message.match(/- using image fonts/)) {MSG = "imageFonts"}
- else if (message.match(/- no valid font/)) {MSG = "noFonts"}
- if (MSG && CONFIG.Message[MSG])
- {MathJax.Localization.loadDomain("FontWarnings",[CREATEMESSAGE,CONFIG.Message[MSG]])}
- }
- });
- }
- })(MathJax.Hub,MathJax.HTML);
- MathJax.Ajax.loadComplete("[MathJax]/extensions/FontWarnings.js");
|