Merge remote-tracking branch 'dpvc/issue737' into develop. Issue #737.

This commit is contained in:
Davide P. Cervone 2014-03-20 05:46:40 -04:00
commit 921f9544c5

View File

@ -642,31 +642,46 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individual
SCRIPTS = []; SCRIPTS = [];
}; };
var PATH = {};
PATH[BASENAME] = ""; // empty path gets the root URL
BASE.Ajax = { BASE.Ajax = {
loaded: {}, // files already loaded loaded: {}, // files already loaded
loading: {}, // files currently in process of loading loading: {}, // files currently in process of loading
loadHooks: {}, // hooks to call when files are loaded loadHooks: {}, // hooks to call when files are loaded
timeout: 15*1000, // timeout for loading of files (15 seconds) timeout: 15*1000, // timeout for loading of files (15 seconds)
styleDelay: 1, // delay to use before styles are available styleDelay: 1, // delay to use before styles are available
config: {root: ""}, // URL of root directory to load from config: {
root: "", // URL of root directory to load from
path: PATH // paths to named URL's (e.g., [MathJax]/...)
},
STATUS: { STATUS: {
OK: 1, // file is loading or did load OK OK: 1, // file is loading or did load OK
ERROR: -1 // file timed out during load ERROR: -1 // file timed out during load
}, },
rootPattern: new RegExp("^\\["+BASENAME+"\\]"),
// //
// Return a complete URL to a file (replacing the root pattern) // Return a complete URL to a file (replacing any root names)
// //
fileURL: function (file) {return file.replace(this.rootPattern,this.config.root)}, fileURL: function (file) {
var match = file.match(/^\[([-._a-z0-9]+)\]/i);
if (match && match[1] in PATH)
{file = (PATH[match[1]]||this.config.root) + file.substr(match[1].length+2)}
return file;
},
// //
// Remove root if URL includes it // Replace root names if URL includes one
// //
fileName: function (url) { fileName: function (url) {
var root = this.config.root; var root = this.config.root;
if (url.substr(0,root.length) == root) {url = "["+BASENAME+"]"+url.substr(root.length)} if (url.substr(0,root.length) === root) {url = "["+BASENAME+"]"+url.substr(root.length)}
else {
for (var id in PATH) {if (PATH.hasOwnProperty(id) && PATH[id]) {
if (url.substr(0,PATH[id].length) === PATH[id])
{url = "["+id+"]"+url.substr(PATH[id].length); break}
}}
}
return url; return url;
}, },
// //
@ -2967,10 +2982,10 @@ MathJax.Hub.Startup = {
CONFIG.root = scripts[i].src.replace(/(^|\/)[^\/]*(\?.*)?$/,'') CONFIG.root = scripts[i].src.replace(/(^|\/)[^\/]*(\?.*)?$/,'')
.replace(/^(https?:\/\/(cdn.mathjax.org|[0-9a-f]+(-[0-9a-f]+)?.ssl.cf1.rackcdn.com)\/mathjax\/)(latest)/, .replace(/^(https?:\/\/(cdn.mathjax.org|[0-9a-f]+(-[0-9a-f]+)?.ssl.cf1.rackcdn.com)\/mathjax\/)(latest)/,
"$1"+BASE.version+"-$4"); "$1"+BASE.version+"-$4");
BASE.Ajax.config.root = CONFIG.root;
break; break;
} }
} }
BASE.Ajax.config = CONFIG;
var AGENT = navigator.userAgent; var AGENT = navigator.userAgent;
var BROWSERS = { var BROWSERS = {