Refactor event handling to move common routines to MathJax.HTML.Event (in preparateion for handling hover discoverability
This commit is contained in:
parent
56e6e1fe8b
commit
5b421d32d1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -12,5 +12,5 @@
|
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
MathJax.OutputJax["HTML-CSS"]=MathJax.OutputJax({id:"HTML-CSS",version:"1.1.7",directory:MathJax.OutputJax.directory+"/HTML-CSS",extensionDir:MathJax.OutputJax.extensionDir+"/HTML-CSS",autoloadDir:MathJax.OutputJax.directory+"/HTML-CSS/autoload",fontDir:MathJax.OutputJax.directory+"/HTML-CSS/fonts",webfontDir:MathJax.OutputJax.fontDir+"/HTML-CSS",config:{scale:100,minScaleAdjust:50,availableFonts:["STIX","TeX"],preferredFont:"TeX",webFont:"TeX",imageFont:"TeX",undefinedFamily:"STIXGeneral,'Arial Unicode MS',serif",showMathMenu:true,styles:{".MathJax_Display":{"text-align":"center",margin:"1em 0em"},".MathJax .merror":{"background-color":"#FFFF88",color:"#CC0000",border:"1px solid #CC0000",padding:"1px 3px","font-family":"serif","font-style":"normal","font-size":"90%"},".MathJax_Preview":{color:"#888888"},"#MathJax_Tooltip":{"background-color":"InfoBackground",color:"InfoText",border:"1px solid black","box-shadow":"2px 2px 5px #AAAAAA","-webkit-box-shadow":"2px 2px 5px #AAAAAA","-moz-box-shadow":"2px 2px 5px #AAAAAA","-khtml-box-shadow":"2px 2px 5px #AAAAAA",filter:"progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')",padding:"3px 4px"}}}});if(MathJax.Hub.Browser.isMSIE&&document.documentMode>=9){delete MathJax.OutputJax["HTML-CSS"].config.styles["#MathJax_Tooltip"].filter}if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax["HTML-CSS"].Register("jax/mml")}MathJax.Hub.Register.StartupHook("End Config",[function(b,c){var a=b.Insert({minBrowserVersion:{Firefox:3,Opera:9.52,MSIE:6,Chrome:0.3,Safari:2,Konqueror:4},inlineMathDelimiters:["$","$"],displayMathDelimiters:["$$","$$"],multilineDisplay:true,minBrowserTranslate:function(f){var e=b.getJaxFor(f),k=["[Math]"],j;var h=document.createElement("span",{className:"MathJax_Preview"});if(e.inputJax.id==="TeX"){if(e.root.Get("displaystyle")){j=a.displayMathDelimiters;k=[j[0]+e.originalText+j[1]];if(a.multilineDisplay){k=k[0].split(/\n/)}}else{j=a.inlineMathDelimiters;k=[j[0]+e.originalText.replace(/^\s+/,"").replace(/\s+$/,"")+j[1]]}}for(var g=0,d=k.length;g<d;g++){h.appendChild(document.createTextNode(k[g]));if(g<d-1){h.appendChild(document.createElement("br"))}}f.parentNode.insertBefore(h,f)}},(b.config["HTML-CSS"]||{}));if(b.Browser.version!=="0.0"&&!b.Browser.versionAtLeast(a.minBrowserVersion[b.Browser]||0)){c.Translate=a.minBrowserTranslate;b.Config({showProcessingMessages:false});MathJax.Message.Set("Your browser does not support MathJax",null,4000);b.Startup.signal.Post("MathJax not supported")}},MathJax.Hub,MathJax.OutputJax["HTML-CSS"]]);MathJax.OutputJax["HTML-CSS"].loadComplete("config.js");
|
||||
MathJax.OutputJax["HTML-CSS"]=MathJax.OutputJax({id:"HTML-CSS",version:"1.1.8",directory:MathJax.OutputJax.directory+"/HTML-CSS",extensionDir:MathJax.OutputJax.extensionDir+"/HTML-CSS",autoloadDir:MathJax.OutputJax.directory+"/HTML-CSS/autoload",fontDir:MathJax.OutputJax.directory+"/HTML-CSS/fonts",webfontDir:MathJax.OutputJax.fontDir+"/HTML-CSS",config:{scale:100,minScaleAdjust:50,availableFonts:["STIX","TeX"],preferredFont:"TeX",webFont:"TeX",imageFont:"TeX",undefinedFamily:"STIXGeneral,'Arial Unicode MS',serif",showMathMenu:true,styles:{".MathJax_Display":{"text-align":"center",margin:"1em 0em"},".MathJax .merror":{"background-color":"#FFFF88",color:"#CC0000",border:"1px solid #CC0000",padding:"1px 3px","font-family":"serif","font-style":"normal","font-size":"90%"},".MathJax_Preview":{color:"#888888"},"#MathJax_Tooltip":{"background-color":"InfoBackground",color:"InfoText",border:"1px solid black","box-shadow":"2px 2px 5px #AAAAAA","-webkit-box-shadow":"2px 2px 5px #AAAAAA","-moz-box-shadow":"2px 2px 5px #AAAAAA","-khtml-box-shadow":"2px 2px 5px #AAAAAA",filter:"progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')",padding:"3px 4px"}}}});if(MathJax.Hub.Browser.isMSIE&&document.documentMode>=9){delete MathJax.OutputJax["HTML-CSS"].config.styles["#MathJax_Tooltip"].filter}if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax["HTML-CSS"].Register("jax/mml")}MathJax.Hub.Register.StartupHook("End Config",[function(b,c){var a=b.Insert({minBrowserVersion:{Firefox:3,Opera:9.52,MSIE:6,Chrome:0.3,Safari:2,Konqueror:4},inlineMathDelimiters:["$","$"],displayMathDelimiters:["$$","$$"],multilineDisplay:true,minBrowserTranslate:function(f){var e=b.getJaxFor(f),k=["[Math]"],j;var h=document.createElement("span",{className:"MathJax_Preview"});if(e.inputJax.id==="TeX"){if(e.root.Get("displaystyle")){j=a.displayMathDelimiters;k=[j[0]+e.originalText+j[1]];if(a.multilineDisplay){k=k[0].split(/\n/)}}else{j=a.inlineMathDelimiters;k=[j[0]+e.originalText.replace(/^\s+/,"").replace(/\s+$/,"")+j[1]]}}for(var g=0,d=k.length;g<d;g++){h.appendChild(document.createTextNode(k[g]));if(g<d-1){h.appendChild(document.createElement("br"))}}f.parentNode.insertBefore(h,f)}},(b.config["HTML-CSS"]||{}));if(b.Browser.version!=="0.0"&&!b.Browser.versionAtLeast(a.minBrowserVersion[b.Browser]||0)){c.Translate=a.minBrowserTranslate;b.Config({showProcessingMessages:false});MathJax.Message.Set("Your browser does not support MathJax",null,4000);b.Startup.signal.Post("MathJax not supported")}},MathJax.Hub,MathJax.OutputJax["HTML-CSS"]]);MathJax.OutputJax["HTML-CSS"].loadComplete("config.js");
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -12,5 +12,5 @@
|
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
MathJax.OutputJax.NativeMML=MathJax.OutputJax({id:"NativeMML",version:"1.1.4",directory:MathJax.OutputJax.directory+"/NativeMML",extensionDir:MathJax.OutputJax.extensionDir+"/NativeMML",config:{scale:100,showMathMenu:true,showMathMenuMSIE:true,styles:{"DIV.MathJax_MathML":{"text-align":"center",margin:".75em 0px"}}}});if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax.NativeMML.Register("jax/mml")}MathJax.OutputJax.NativeMML.loadComplete("config.js");
|
||||
MathJax.OutputJax.NativeMML=MathJax.OutputJax({id:"NativeMML",version:"1.1.5",directory:MathJax.OutputJax.directory+"/NativeMML",extensionDir:MathJax.OutputJax.extensionDir+"/NativeMML",config:{scale:100,showMathMenu:true,showMathMenuMSIE:true,styles:{"DIV.MathJax_MathML":{"text-align":"center",margin:".75em 0px"}}}});if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax.NativeMML.Register("jax/mml")}MathJax.OutputJax.NativeMML.loadComplete("config.js");
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -30,7 +30,7 @@ if (!window.MathJax) {window.MathJax= {}}
|
|||
if (!MathJax.Hub) { // skip if already loaded
|
||||
|
||||
MathJax.version = "1.1a";
|
||||
MathJax.fileversion = "1.1.9";
|
||||
MathJax.fileversion = "1.1.10";
|
||||
|
||||
/**********************************************************/
|
||||
|
||||
|
@ -900,103 +900,235 @@ MathJax.fileversion = "1.1.9";
|
|||
|
||||
/**********************************************************/
|
||||
|
||||
MathJax.HTML = {
|
||||
//
|
||||
// Create an HTML element with given attributes and content.
|
||||
// The def parameter is an (optional) object containing key:value pairs
|
||||
// of the attributes and their values, and contents is an (optional)
|
||||
// array of strings to be inserted as text, or arrays of the form
|
||||
// [type,def,contents] that describes an HTML element to be inserted
|
||||
// into the current element. Thus the contents can describe a complete
|
||||
// HTML snippet of arbitrary complexity. E.g.:
|
||||
//
|
||||
// MathJax.HTML.Element("span",{id:"mySpan",style{"font-style":"italic"}},[
|
||||
// "(See the ",["a",{href:"http://www.mathjax.org"},["MathJax home page"]],
|
||||
// " for more details.)"]);
|
||||
//
|
||||
Element: function (type,def,contents) {
|
||||
var obj = document.createElement(type);
|
||||
if (def) {
|
||||
if (def.style) {
|
||||
var style = def.style; def.style = {};
|
||||
for (var id in style) {if (style.hasOwnProperty(id))
|
||||
{def.style[id.replace(/-([a-z])/g,this.ucMatch)] = style[id]}}
|
||||
}
|
||||
MathJax.Hub.Insert(obj,def);
|
||||
}
|
||||
if (contents) {
|
||||
for (var i = 0; i < contents.length; i++) {
|
||||
if (contents[i] instanceof Array) {
|
||||
obj.appendChild(this.Element(contents[i][0],contents[i][1],contents[i][2]));
|
||||
} else {
|
||||
obj.appendChild(document.createTextNode(contents[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
ucMatch: function (match,c) {return c.toUpperCase()},
|
||||
addElement: function (span,type,def,contents) {return span.appendChild(this.Element(type,def,contents))},
|
||||
TextNode: function (text) {return document.createTextNode(text)},
|
||||
addText: function (span,text) {return span.appendChild(this.TextNode(text))},
|
||||
(function (BASENAME) {
|
||||
var BASE = window[BASENAME];
|
||||
if (!BASE) {BASE = window[BASENAME] = {}}
|
||||
var AJAX = BASE.Ajax, CALLBACK = BASE.Callback;
|
||||
|
||||
//
|
||||
// Set the text of a script
|
||||
//
|
||||
setScript: function (script,text) {
|
||||
if (this.setScriptBug) {script.text = text} else {
|
||||
while (script.firstChild) {script.removeChild(script.firstChild)}
|
||||
this.addText(script,text);
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// Manage cookies
|
||||
//
|
||||
Cookie: {
|
||||
prefix: "mjx",
|
||||
expires: 365,
|
||||
BASE.HTML = {
|
||||
|
||||
//
|
||||
// Save an object as a named cookie
|
||||
//
|
||||
Set: function (name,def) {
|
||||
var keys = [];
|
||||
// Create an HTML element with given attributes and content.
|
||||
// The def parameter is an (optional) object containing key:value pairs
|
||||
// of the attributes and their values, and contents is an (optional)
|
||||
// array of strings to be inserted as text, or arrays of the form
|
||||
// [type,def,contents] that describes an HTML element to be inserted
|
||||
// into the current element. Thus the contents can describe a complete
|
||||
// HTML snippet of arbitrary complexity. E.g.:
|
||||
//
|
||||
// MathJax.HTML.Element("span",{id:"mySpan",style{"font-style":"italic"}},[
|
||||
// "(See the ",["a",{href:"http://www.mathjax.org"},["MathJax home page"]],
|
||||
// " for more details.)"]);
|
||||
//
|
||||
Element: function (type,def,contents) {
|
||||
var obj = document.createElement(type);
|
||||
if (def) {
|
||||
for (var id in def) {if (def.hasOwnProperty(id)) {
|
||||
keys.push(id+":"+def[id].toString().replace(/&/g,"&&"));
|
||||
}}
|
||||
if (def.style) {
|
||||
var style = def.style; def.style = {};
|
||||
for (var id in style) {if (style.hasOwnProperty(id))
|
||||
{def.style[id.replace(/-([a-z])/g,this.ucMatch)] = style[id]}}
|
||||
}
|
||||
BASE.Hub.Insert(obj,def);
|
||||
}
|
||||
var cookie = this.prefix+"."+name+"="+escape(keys.join('&;'));
|
||||
if (this.expires) {
|
||||
var time = new Date(); time.setDate(time.getDate() + this.expires);
|
||||
cookie += '; expires='+time.toGMTString();
|
||||
}
|
||||
document.cookie = cookie+"; path=/";
|
||||
},
|
||||
|
||||
//
|
||||
// Get the contents of a named cookie and incorporate
|
||||
// it into the given object (or return a fresh one)
|
||||
//
|
||||
Get: function (name,obj) {
|
||||
if (!obj) {obj = {}}
|
||||
var pattern = new RegExp("(?:^|;\\s*)"+this.prefix+"\\."+name+"=([^;]*)(?:;|$)");
|
||||
var match = pattern.exec(document.cookie);
|
||||
if (match && match[1] !== "") {
|
||||
var keys = unescape(match[1]).split('&;');
|
||||
for (var i = 0, m = keys.length; i < m; i++) {
|
||||
match = keys[i].match(/([^:]+):(.*)/);
|
||||
var value = match[2].replace(/&&/g,'&');
|
||||
if (value === "true") {value = true} else if (value === "false") {value = false}
|
||||
else if (value.match(/^-?(\d+(\.\d+)?|\.\d+)$/)) {value = parseFloat(value)}
|
||||
obj[match[1]] = value;
|
||||
if (contents) {
|
||||
for (var i = 0; i < contents.length; i++) {
|
||||
if (contents[i] instanceof Array) {
|
||||
obj.appendChild(this.Element(contents[i][0],contents[i][1],contents[i][2]));
|
||||
} else {
|
||||
obj.appendChild(document.createTextNode(contents[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
ucMatch: function (match,c) {return c.toUpperCase()},
|
||||
addElement: function (span,type,def,contents) {return span.appendChild(this.Element(type,def,contents))},
|
||||
TextNode: function (text) {return document.createTextNode(text)},
|
||||
addText: function (span,text) {return span.appendChild(this.TextNode(text))},
|
||||
|
||||
//
|
||||
// Set the text of a script
|
||||
//
|
||||
setScript: function (script,text) {
|
||||
if (this.setScriptBug) {script.text = text} else {
|
||||
while (script.firstChild) {script.removeChild(script.firstChild)}
|
||||
this.addText(script,text);
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// Manage cookies
|
||||
//
|
||||
Cookie: {
|
||||
prefix: "mjx",
|
||||
expires: 365,
|
||||
|
||||
//
|
||||
// Save an object as a named cookie
|
||||
//
|
||||
Set: function (name,def) {
|
||||
var keys = [];
|
||||
if (def) {
|
||||
for (var id in def) {if (def.hasOwnProperty(id)) {
|
||||
keys.push(id+":"+def[id].toString().replace(/&/g,"&&"));
|
||||
}}
|
||||
}
|
||||
var cookie = this.prefix+"."+name+"="+escape(keys.join('&;'));
|
||||
if (this.expires) {
|
||||
var time = new Date(); time.setDate(time.getDate() + this.expires);
|
||||
cookie += '; expires='+time.toGMTString();
|
||||
}
|
||||
document.cookie = cookie+"; path=/";
|
||||
},
|
||||
|
||||
//
|
||||
// Get the contents of a named cookie and incorporate
|
||||
// it into the given object (or return a fresh one)
|
||||
//
|
||||
Get: function (name,obj) {
|
||||
if (!obj) {obj = {}}
|
||||
var pattern = new RegExp("(?:^|;\\s*)"+this.prefix+"\\."+name+"=([^;]*)(?:;|$)");
|
||||
var match = pattern.exec(document.cookie);
|
||||
if (match && match[1] !== "") {
|
||||
var keys = unescape(match[1]).split('&;');
|
||||
for (var i = 0, m = keys.length; i < m; i++) {
|
||||
match = keys[i].match(/([^:]+):(.*)/);
|
||||
var value = match[2].replace(/&&/g,'&');
|
||||
if (value === "true") {value = true} else if (value === "false") {value = false}
|
||||
else if (value.match(/^-?(\d+(\.\d+)?|\.\d+)$/)) {value = parseFloat(value)}
|
||||
obj[match[1]] = value;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// Common event-handling code
|
||||
//
|
||||
var EVENT = BASE.HTML.Event = {
|
||||
Mousedown: function (event) {return EVENT.Handler(event,"Mousedown",this)},
|
||||
Mouseup: function (event) {return EVENT.Handler(event,"Mouseup",this)},
|
||||
Mousemove: function (event) {return EVENT.Handler(event,"Mousemove",this)},
|
||||
Mouseover: function (event) {return EVENT.Handler(event,"Mouseover",this)},
|
||||
Mouseout: function (event) {return EVENT.Handler(event,"Mouseout",this)},
|
||||
Click: function (event) {return EVENT.Handler(event,"Click",this)},
|
||||
DblClick: function (event) {return EVENT.Handler(event,"DblClick",this)},
|
||||
Menu: function (event) {return EVENT.Handler(event,"ContextMenu",this)},
|
||||
|
||||
//
|
||||
// Call the output jax's event handler
|
||||
//
|
||||
Handler: function (event,type,math) {
|
||||
if (AJAX.loadingMathMenu) {return False(event)}
|
||||
var jax = BASE.OutputJax[math.jaxID];
|
||||
if (!event) {event = window.event}
|
||||
return jax.HandleEvent(event,type,math);
|
||||
},
|
||||
//
|
||||
// For use in the handler
|
||||
//
|
||||
HandleEvent: function (event,type,math) {
|
||||
if (this[type]) {return this[type].call(this,event,math)}
|
||||
if (MathJax.Extension.MathZoom)
|
||||
{return MathJax.Extension.MathZoom.HandleEvent(event,type,math)}
|
||||
},
|
||||
|
||||
|
||||
//
|
||||
// Try to cancel the event in every way we can
|
||||
//
|
||||
False: function (event) {
|
||||
if (!event) {event = window.event}
|
||||
if (event) {
|
||||
if (event.preventDefault) {event.preventDefault()}
|
||||
if (event.stopPropagation) {event.stopPropagation()}
|
||||
event.cancelBubble = true;
|
||||
event.returnValue = false;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
//
|
||||
// Load the contextual menu code, if needed, and post the menu
|
||||
//
|
||||
ContextMenu: function (event,math) {
|
||||
var MENU = BASE.Menu;
|
||||
if (MENU) {
|
||||
MENU.jax = BASE.Hub.getJaxFor(math.nextSibling);
|
||||
MENU.menu.items[1].menu.items[1].name =
|
||||
(MENU.jax.inputJax.id === "MathML" ? "Original" : MENU.jax.inputJax.id);
|
||||
return MENU.menu.Post(event);
|
||||
} else {
|
||||
if (!AJAX.loadingMathMenu) {
|
||||
AJAX.loadingMathMenu = true;
|
||||
var ev = {pageX:event.pageX, pageY:event.pageY, clientX:event.clientX, clientY:event.clientY};
|
||||
CALLBACK.Queue(
|
||||
AJAX.Require("[MathJax]/extensions/MathMenu.js"),
|
||||
function () {delete AJAX.loadingMathMenu; if (!BASE.Menu) {BASE.Menu = {}}},
|
||||
["ContextMenu",this,ev,math] // call this function again
|
||||
);
|
||||
}
|
||||
return this.False(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var TOUCH = BASE.HTML.Touch = {
|
||||
|
||||
// Handle touch events.
|
||||
//
|
||||
// Use double-tap-and-hold as a replacement for context menu event.
|
||||
// Use double-tap as a replacement for double click.
|
||||
//
|
||||
last: 0, // time of last tap event
|
||||
delay: 500, // delay time for double-click
|
||||
|
||||
//
|
||||
// Check if this is a double-tap, and if so, start the timer
|
||||
// for the double-tap and hold (to trigger the contextual menu)
|
||||
//
|
||||
start: function (event) {
|
||||
var now = new Date().getTime();
|
||||
var dblTap = (now - TOUCH.last < TOUCH.delay);
|
||||
TOUCH.last = now;
|
||||
if (dblTap) {
|
||||
TOUCH.timeout = setTimeout(TOUCH.menu,TOUCH.delay,event,this);
|
||||
event.preventDefault();
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// Check if there is a timeout pending, i.e., we have a
|
||||
// double-tap and were waiting to see if it is held long
|
||||
// enough for the menu. Since we got the end before the
|
||||
// timeout, it is a double-click, not a double-tap-and-hold.
|
||||
// Prevent the default action and issue a double click.
|
||||
//
|
||||
end: function (event) {
|
||||
if (TOUCH.timeout) {
|
||||
clearTimeout(TOUCH.timeout);
|
||||
delete TOUCH.timeout; TOUCH.last = 0;
|
||||
event.preventDefault();
|
||||
return EVENT.Handler((event.touches[0]||event.touch),"DblClick",this);
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// If the timeout passes without an end event, we issue
|
||||
// the contextual menu event.
|
||||
//
|
||||
menu: function (event,math) {
|
||||
delete TOUCH.timeout; TOUCH.last = 0;
|
||||
return EVENT.Handler((event.touches[0]||event.touch),"ContextMenu",math);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
})("MathJax");
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
|
||||
|
@ -2068,6 +2200,7 @@ MathJax.Hub.Startup = {
|
|||
MSIE: function (browser) {
|
||||
browser.isIE9 = !!(document.documentMode && (window.performance || window.msPerformance));
|
||||
MathJax.HTML.setScriptBug = !browser.isIE9 || document.documentMode < 9;
|
||||
MathJax.HTML.Event.msieButtonBug = (document.documentMode||0) >= 9;
|
||||
}
|
||||
});
|
||||
HUB.Browser.Select(MathJax.Message.browsers);
|
||||
|
|
|
@ -138,16 +138,7 @@
|
|||
/*
|
||||
* Cancel event's default action (try everything we can)
|
||||
*/
|
||||
var FALSE = function (event) {
|
||||
if (!event) {event = window.event}
|
||||
if (event) {
|
||||
if (event.preventDefault) {event.preventDefault()}
|
||||
if (event.stopPropagation) {event.stopPropagation()}
|
||||
event.cancelBubble = true;
|
||||
event.returnValue = false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
var FALSE = MathJax.HTML.Event.False;
|
||||
|
||||
/*************************************************************/
|
||||
/*
|
||||
|
|
|
@ -61,16 +61,7 @@
|
|||
/*
|
||||
* Cancel event's default action (try everything we can)
|
||||
*/
|
||||
var FALSE = function (event) {
|
||||
if (!event) {event = window.event}
|
||||
if (event) {
|
||||
if (event.preventDefault) {event.preventDefault()}
|
||||
if (event.stopPropagation) {event.stopPropagation()}
|
||||
event.cancelBubble = true;
|
||||
event.returnValue = false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
var FALSE = MathJax.HTML.Event.False;
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
|
@ -79,10 +70,9 @@
|
|||
settings: HUB.config.menuSettings,
|
||||
|
||||
//
|
||||
// Used to override HTMLCSS or nMML method of the same name
|
||||
// Process events passed from output jax
|
||||
//
|
||||
HandleEvent: function (event,type,math) {
|
||||
if (!event) {event = window.event}
|
||||
if (ZOOM.settings.CTRL && !event.ctrlKey) return true;
|
||||
if (ZOOM.settings.ALT && !event.altKey) return true;
|
||||
if (ZOOM.settings.CMD && !event.metaKey) return true;
|
||||
|
@ -216,7 +206,6 @@
|
|||
else if (window.attachEvent) {attachEvent("onresize",this.Resize)}
|
||||
else {this.onresize = window.onresize; window.onresize = this.Resize}
|
||||
|
||||
|
||||
//
|
||||
// Canel further actions
|
||||
//
|
||||
|
@ -320,16 +309,11 @@
|
|||
};
|
||||
|
||||
//
|
||||
// Hook into the HTML-CSS and NativeMML event handling
|
||||
// Handle IE events for NativeMML
|
||||
//
|
||||
HUB.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
||||
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
|
||||
HTMLCSS.Augment({HandleEvent: ZOOM.HandleEvent});
|
||||
});
|
||||
HUB.Register.StartupHook("NativeMML Jax Ready", function () {
|
||||
nMML = MathJax.OutputJax.NativeMML;
|
||||
nMML.Augment({
|
||||
HandleEvent: ZOOM.HandleEvent,
|
||||
MSIEmouseup: function (event,math,span) {
|
||||
if (this.trapUp) {delete this.trapUp; return true}
|
||||
if (this.MSIEzoomKeys(event)) {return true}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
MathJax.OutputJax["HTML-CSS"] = MathJax.OutputJax({
|
||||
id: "HTML-CSS",
|
||||
version: "1.1.7",
|
||||
version: "1.1.8",
|
||||
directory: MathJax.OutputJax.directory + "/HTML-CSS",
|
||||
extensionDir: MathJax.OutputJax.extensionDir + "/HTML-CSS",
|
||||
autoloadDir: MathJax.OutputJax.directory + "/HTML-CSS/autoload",
|
||||
|
|
|
@ -82,9 +82,9 @@
|
|||
return false;
|
||||
},
|
||||
|
||||
styleChar: String.fromCharCode(0xEFFD), // width encodes style
|
||||
versionChar: String.fromCharCode(0xEFFE), // width encodes version
|
||||
compChar: String.fromCharCode(0xEFFF), // "standard" width to compare to
|
||||
styleChar: "\uEFFD", // width encodes style
|
||||
versionChar: "\uEFFE", // width encodes version
|
||||
compChar: "\uEFFF", // "standard" width to compare to
|
||||
|
||||
testStyleChar: function (font,size) {
|
||||
var n = 3 + (font.weight ? 2 : 0) + (font.style ? 4 : 0);
|
||||
|
@ -182,57 +182,10 @@
|
|||
}
|
||||
});
|
||||
|
||||
//
|
||||
// Handle touch events.
|
||||
//
|
||||
// Use double-tap and hold as a replacement for context menu event.
|
||||
// Use double-tap as a replacement for double click.
|
||||
//
|
||||
var TOUCH = {
|
||||
last: 0, // time of last tap event
|
||||
delay: 500, // delay time for double-click
|
||||
|
||||
//
|
||||
// Check if this is a double-tap, and if so, start the timer
|
||||
// for the double-tap and hold (to trigger the contextual menu)
|
||||
//
|
||||
start: function (event) {
|
||||
var now = new Date().getTime();
|
||||
var dblTap = (now - TOUCH.last < TOUCH.delay);
|
||||
TOUCH.last = now;
|
||||
if (dblTap) {
|
||||
TOUCH.timeout = setTimeout(TOUCH.menu,TOUCH.delay,this,event);
|
||||
event.preventDefault();
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// Check if there is a timeout pending, i.e., we have a
|
||||
// double-tap and were waiting to see if it is held long
|
||||
// enough for the menu. Since we got the end before the
|
||||
// timeout, it is a double-click, not a double-tap-and-hold.
|
||||
// Prevent the default action and issue a double click.
|
||||
//
|
||||
end: function (event) {
|
||||
if (TOUCH.timeout) {
|
||||
clearTimeout(TOUCH.timeout);
|
||||
delete TOUCH.timeout; TOUCH.last = 0;
|
||||
event.preventDefault();
|
||||
HTMLCSS.DblClick.call(this,event.touches[0]||event.touch);
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// If the timeout passes without an end event, we issue
|
||||
// the contextual menu event.
|
||||
//
|
||||
menu: function (math,event) {
|
||||
delete TOUCH.timeout; TOUCH.last = 0;
|
||||
HTMLCSS.ContextMenu.call(math,event.touches[0]||even.touch);
|
||||
}
|
||||
};
|
||||
|
||||
var EVENT = MathJax.HTML.Event;
|
||||
var TOUCH = MathJax.HTML.Touch;
|
||||
|
||||
|
||||
HTMLCSS.Augment({
|
||||
config: {
|
||||
styles: {
|
||||
|
@ -312,7 +265,6 @@
|
|||
LEFTBUTTON: (HUB.Browser.isMSIE ? 1 : 0), // the event.button value for left button
|
||||
MENUKEY: "altKey", // the event value for alternate context menu
|
||||
|
||||
Touch: TOUCH, // Touch event handling
|
||||
Font: null, // created by Config() below
|
||||
|
||||
Config: function () {
|
||||
|
@ -434,13 +386,14 @@
|
|||
{prev.parentNode.removeChild(prev)}
|
||||
var math = script.MathJax.elementJax.root, span, div, frame;
|
||||
span = div = frame = this.Element("span",{
|
||||
className:"MathJax", isMathJax: true,
|
||||
oncontextmenu:this.ContextMenu, onmousedown: this.Mousedown,
|
||||
onmouseover:this.Mouseover, onclick:this.Click, ondblclick:this.DblClick
|
||||
className:"MathJax", isMathJax:true, jaxID:"HTML-CSS",
|
||||
oncontextmenu:EVENT.Menu, onmousedown: EVENT.Mousedown,
|
||||
onmouseover:EVENT.Mouseover, onmouseout: EVENT.Mouseout, onmousemove: EVENT.Mousemove,
|
||||
onclick:EVENT.Click, ondblclick:EVENT.DblClick
|
||||
});
|
||||
if (MathJax.Hub.Browser.noContextMenu) {
|
||||
span.ontouchstart = this.Touch.start;
|
||||
span.ontouchend = this.Touch.end;
|
||||
span.ontouchstart = TOUCH.start;
|
||||
span.ontouchend = TOUCH.end;
|
||||
}
|
||||
var blockMode = (math.Get("display") === "block");
|
||||
if (blockMode) {
|
||||
|
@ -467,56 +420,26 @@
|
|||
if (this.useProcessingFrame) frame.parentNode.replaceChild(div,frame);
|
||||
},
|
||||
|
||||
/*
|
||||
* Autoload the MathMenu code, when needed
|
||||
*/
|
||||
ContextMenu: function (event,force) {
|
||||
if (HTMLCSS.config.showMathMenu && (HTMLCSS.settings.context === "MathJax" || force)) {
|
||||
if (HTMLCSS.safariContextMenuBug) {setTimeout('window.getSelection().empty()',0)}
|
||||
if (!event || HTMLCSS.msieEventBug) {event = window.event}
|
||||
var MENU = MathJax.Menu;
|
||||
if (MENU) {
|
||||
var math = (this.parentNode.className === "MathJax_Display" ? this.parentNode : this)
|
||||
MENU.jax = HUB.getJaxFor(math.nextSibling);
|
||||
MENU.menu.items[1].menu.items[1].name =
|
||||
(MENU.jax.inputJax.id === "MathML" ? "Original" : MENU.jax.inputJax.id);
|
||||
return MENU.menu.Post(event);
|
||||
} else {
|
||||
if (!AJAX.loadingMathMenu) {
|
||||
AJAX.loadingMathMenu = true;
|
||||
var EVENT = {pageX:event.pageX, pageY:event.pageY, clientX:event.clientX, clientY:event.clientY};
|
||||
MathJax.Callback.Queue(
|
||||
AJAX.Require("[MathJax]/extensions/MathMenu.js"),
|
||||
function () {delete AJAX.loadingMathMenu},
|
||||
[this,arguments.callee,EVENT,force] // call this function again
|
||||
);
|
||||
}
|
||||
if (event.preventDefault) {event.preventDefault()}
|
||||
if (event.stopPropagation) {event.stopPropagation()}
|
||||
event.cancelBubble = true;
|
||||
event.returnValue = false;
|
||||
return false;
|
||||
}
|
||||
HandleEvent: EVENT.HandleEvent,
|
||||
ContextMenu: function (event,math,force) {
|
||||
if (this.config.showMathMenu && (this.settings.context === "MathJax" || force)) {
|
||||
if (this.safariContextMenuBug) {setTimeout("window.getSelection().empty()",0)}
|
||||
if (this.msieEventBug) {event = window.event}
|
||||
if (math.parentNode.className === "MathJax_Display") {math = math.parentNode}
|
||||
return EVENT.ContextMenu(event,math);
|
||||
}
|
||||
},
|
||||
Mousedown: function (event) {
|
||||
if (HTMLCSS.config.showMathMenu) {
|
||||
if (!event) {event = window.event}
|
||||
if (HTMLCSS.settings.context === "MathJax") {
|
||||
if (!HTMLCSS.noContextMenuBug || event.button !== 2) return
|
||||
Mousedown: function (event,math) {
|
||||
if (this.config.showMathMenu) {
|
||||
if (this.settings.context === "MathJax") {
|
||||
if (!this.noContextMenuBug || event.button !== 2) return
|
||||
} else {
|
||||
if (!event[HTMLCSS.MENUKEY] || event.button !== HTMLCSS.LEFTBUTTON) return
|
||||
var BUTTON = (EVENT.msieButtonBug ? event.buttons & 1 : event.button);
|
||||
if (!event[HTMLCSS.MENUKEY] || BUTTON !== HTMLCSS.LEFTBUTTON) return
|
||||
}
|
||||
return HTMLCSS.ContextMenu.call(this,event,true);
|
||||
return this.ContextMenu(event,math,true);
|
||||
}
|
||||
},
|
||||
/*
|
||||
* Used for zooming, when that is enabled by the MathMenu
|
||||
*/
|
||||
Mouseover: function (event) {HTMLCSS.HandleEvent(event,"Mouseover",this)},
|
||||
Click: function (event) {HTMLCSS.HandleEvent(event,"Click",this)},
|
||||
DblClick: function (event) {HTMLCSS.HandleEvent(event,"DblClick",this)},
|
||||
HandleEvent: function (event,type,math) {},
|
||||
|
||||
initImg: function (span) {},
|
||||
initHTML: function (math,span) {},
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
MathJax.OutputJax.NativeMML = MathJax.OutputJax({
|
||||
id: "NativeMML",
|
||||
version: "1.1.4",
|
||||
version: "1.1.5",
|
||||
directory: MathJax.OutputJax.directory + "/NativeMML",
|
||||
extensionDir: MathJax.OutputJax.extensionDir + "/NativeMML",
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function (nMML,HUB,AJAX) {
|
||||
(function (nMML,HUB,AJAX,HTML,EVENT) {
|
||||
var MML, isMSIE = HUB.Browser.isMSIE;
|
||||
|
||||
nMML.Augment({
|
||||
LEFTBUTTON: (isMSIE ? 1 : 0), // the event.button value for left button
|
||||
MENUKEY: "altKey", // the event value for alternate context menu
|
||||
MENUKEY: "altKey", // the event value for alternate context menu
|
||||
noContextMenuBug: HUB.Browser.isKonequeror,
|
||||
msieQuirks: (isMSIE && !(document.compatMode === "BackCompat")),
|
||||
msieEventBug: HUB.Browser.isIE9,
|
||||
|
@ -36,7 +36,7 @@
|
|||
// User can configure styles
|
||||
//
|
||||
config: {styles: {}}, settings: HUB.config.menuSettings,
|
||||
Startup: function () {return MathJax.Ajax.Styles(this.config.styles)},
|
||||
Startup: function () {return AJAX.Styles(this.config.styles)},
|
||||
Config: function () {
|
||||
this.SUPER(arguments).Config.call(this);
|
||||
if (this.settings.scale) {this.config.scale = this.settings.scale}
|
||||
|
@ -58,7 +58,7 @@
|
|||
//
|
||||
InitializeMML: function () {
|
||||
this.initialized = true;
|
||||
if (MathJax.Hub.Browser.isMSIE) {
|
||||
if (HUB.Browser.isMSIE) {
|
||||
try {
|
||||
//
|
||||
// Insert data needed to use MathPlayer for MathML output
|
||||
|
@ -100,7 +100,7 @@
|
|||
var span = document.createElement(type), container = span;
|
||||
span.className = "MathJax_MathML"; span.style.fontSize = this.config.scale+"%";
|
||||
if (isMSIE && this.config.showMathMenuMSIE) {
|
||||
container = MathJax.HTML.addElement(span,"span",{
|
||||
container = HTML.addElement(span,"span",{
|
||||
className:"MathJax_MathContainer",
|
||||
style:{display:"inline-block",position:"relative"}
|
||||
});
|
||||
|
@ -110,12 +110,13 @@
|
|||
if (isMSIE) {
|
||||
if (this.config.showMathMenuMSIE) {this.MSIEoverlay(span)}
|
||||
} else {
|
||||
math = span.firstChild;
|
||||
math.oncontextmenu = this.ContextMenu;
|
||||
math.onmouseover = this.Mouseover;
|
||||
math.onmousedown = this.Mousedown;
|
||||
math.onclick = this.Click;
|
||||
math.ondblclick = this.DblClick;
|
||||
math = span.firstChild; math.jaxID = "NativeMML";
|
||||
math.oncontextmenu = EVENT.Menu;
|
||||
math.onmouseover = EVENT.Mouseover;
|
||||
math.onmousout = EVENT.Mouseout;
|
||||
math.onmousedown = EVENT.Mousedown;
|
||||
math.onclick = EVENT.Click;
|
||||
math.ondblclick = EVENT.DblClick;
|
||||
}
|
||||
},
|
||||
//
|
||||
|
@ -141,19 +142,19 @@
|
|||
var math = span.firstChild;
|
||||
span.style.position = "absolute"; // so we can measure height/depth
|
||||
var HD = span.scrollHeight, W = span.offsetWidth;
|
||||
var tmp = MathJax.HTML.addElement(span,"img",{src:"about:blank",style:{width:0,height:HD+"px"}});
|
||||
var tmp = HTML.addElement(span,"img",{src:"about:blank",style:{width:0,height:HD+"px"}});
|
||||
var D = span.scrollHeight - HD; span.removeChild(tmp);
|
||||
span.style.position = ""; // back to normal
|
||||
var top, left, isDisplay = (span.parentNode.nodeName.toLowerCase() === "div");
|
||||
if (isDisplay && this.quirks) {top = -HD; left = Math.floor(-W/2)} else {top = D-HD, left = -W}
|
||||
MathJax.HTML.addElement(span,"span",{
|
||||
HTML.addElement(span,"span",{
|
||||
style:{display:"inline-block", width:0, height:0, position:"relative"}
|
||||
},[["span",{
|
||||
style:{display:"inline-block", position:"absolute", left:left+"px", top:top+"px",
|
||||
width:math.offsetWidth+"px", height:HD+"px", cursor:"pointer",
|
||||
"background-color":"white", filter:"alpha(opacity=0)"},
|
||||
onmousedown: this.MSIEevent, oncontextmenu: this.MSIEevent, onclick: this.MSIEevent,
|
||||
/*onmouseup: this.MSIEevent,*/ onmousemove: this.MSIEevent, ondblclick: this.MSIEevent,
|
||||
onmouseup: this.MSIEevent, onmousemove: this.MSIEevent, ondblclick: this.MSIEevent,
|
||||
onmouseover: this.MSIEevent, onmouseout: this.MSIEevent
|
||||
}]]);
|
||||
},
|
||||
|
@ -167,13 +168,13 @@
|
|||
var event = window.event;
|
||||
var action = nMML["MSIE"+event.type];
|
||||
if (action && action.call(nMML,event,math,this)) {return false}
|
||||
math.fireEvent("on"+event.type,event);
|
||||
if (math.fireEvent) {math.fireEvent("on"+event.type,event)}
|
||||
return false;
|
||||
},
|
||||
MSIEmousedown: function (event,math,span) {
|
||||
if (event[this.MENUKEY] && event.button === this.LEFTBUTTON && this.settings.context !== "MathJax") {
|
||||
this.trapUp = this.trapClick = true;
|
||||
this.ContextMenu.call(span,event,true);
|
||||
this.ContextMenu(event,span,true);
|
||||
return true;
|
||||
}
|
||||
if (this.MSIEzoomKeys && this.MSIEzoomKeys(event)) {this.trapUp = true; return true}
|
||||
|
@ -182,65 +183,33 @@
|
|||
MSIEcontextmenu: function (event,math,span) {
|
||||
if (this.settings.context === "MathJax") {
|
||||
this.trapUp = this.trapClick = true;
|
||||
this.ContextMenu.call(span,event,true);
|
||||
this.ContextMenu(event,span);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
// Other event handlers are in MathZoom.js
|
||||
// Other IE event handlers are in MathZoom.js
|
||||
|
||||
//
|
||||
// Autoload the MathMenu code, when needed
|
||||
//
|
||||
ContextMenu: function (event,force) {
|
||||
if (nMML.config.showMathMenu && (nMML.settings.context === "MathJax" || force)) {
|
||||
if (nMML.safariContextMenuBug) {setTimeout('window.getSelection().empty()',0)}
|
||||
if (!event || nMML.msieEventBug) {event = window.event}
|
||||
var MENU = MathJax.Menu;
|
||||
if (MENU) {
|
||||
if (document.selection) {setTimeout("document.selection.empty()",0)}
|
||||
var script = (isMSIE ? this.parentNode.parentNode.nextSibling : this.parentNode.nextSibling);
|
||||
MENU.jax = HUB.getJaxFor(script);
|
||||
MENU.menu.items[1].menu.items[1].name =
|
||||
(MENU.jax.inputJax.id === "MathML" ? "Original" : MENU.jax.inputJax.id);
|
||||
delete nMML.trapClick; delete nMML.trapUp;
|
||||
return MENU.menu.Post(event);
|
||||
} else {
|
||||
if (!AJAX.loadingMathMenu) {
|
||||
AJAX.loadingMathMenu = true;
|
||||
var EVENT = {pageX:event.pageX, pageY:event.pageY, clientX:event.clientX, clientY:event.clientY};
|
||||
MathJax.Callback.Queue(
|
||||
AJAX.Require("[MathJax]/extensions/MathMenu.js"),
|
||||
function () {delete AJAX.loadingMathMenu},
|
||||
[this,arguments.callee,EVENT,force] // call this function again
|
||||
);
|
||||
}
|
||||
if (event.preventDefault) {event.preventDefault()}
|
||||
if (event.stopPropagation) {event.stopPropagation()}
|
||||
event.cancelBubble = true;
|
||||
event.returnValue = false;
|
||||
return false;
|
||||
}
|
||||
HandleEvent: EVENT.HandleEvent,
|
||||
ContextMenu: function (event,math,force) {
|
||||
if (this.config.showMathMenu && (this.settings.context === "MathJax" || force)) {
|
||||
if (document.selection) {setTimeout("document.selection.empty()",0)}
|
||||
if (this.msieEventBug) {event = window.event}
|
||||
math = math.parentNode; if (isMSIE) {math = math.parentNode}
|
||||
delete this.trapClick; delete this.trapUp;
|
||||
return EVENT.ContextMenu(event,math);
|
||||
}
|
||||
},
|
||||
Mousedown: function (event) {
|
||||
if (nMML.config.showMathMenu) {
|
||||
if (!event) {event = window.event}
|
||||
if (nMML.settings.context === "MathJax") {
|
||||
if (!nMML.noContextMenuBug || event.button !== 2) return
|
||||
Mousedown: function (event,math) {
|
||||
if (this.config.showMathMenu) {
|
||||
if (this.settings.context === "MathJax") {
|
||||
if (!this.noContextMenuBug || event.button !== 2) return
|
||||
} else {
|
||||
if (!event[nMML.MENUKEY] || event.button !== nMML.LEFTBUTTON) return
|
||||
}
|
||||
return nMML.ContextMenu.call(this,event,true);
|
||||
return this.ContextMenu(event,math,true);
|
||||
}
|
||||
},
|
||||
/*
|
||||
* Used for zooming, when that is enabled by the MathMenu
|
||||
*/
|
||||
Mouseover: function (event) {nMML.HandleEvent(event,"Mouseover",this)},
|
||||
Click: function (event) {nMML.HandleEvent(event,"Click",this)},
|
||||
DblClick: function (event) {nMML.HandleEvent(event,"DblClick",this)},
|
||||
HandleEvent: function (event,type,math) {},
|
||||
|
||||
NAMEDSPACE: {
|
||||
negativeveryverythinmathspace: "-.0556em",
|
||||
|
@ -364,7 +333,7 @@
|
|||
}
|
||||
});
|
||||
|
||||
if (MathJax.Hub.Browser.isFirefox) {
|
||||
if (HUB.Browser.isFirefox) {
|
||||
MML.mtable.Augment({
|
||||
toNativeMML: function (parent) {
|
||||
//
|
||||
|
@ -508,4 +477,4 @@
|
|||
{AJAX.Require("[MathJax]/extensions/MathZoom.js")}
|
||||
});
|
||||
|
||||
})(MathJax.OutputJax.NativeMML, MathJax.Hub, MathJax.Ajax);
|
||||
})(MathJax.OutputJax.NativeMML, MathJax.Hub, MathJax.Ajax, MathJax.HTML, MathJax.HTML.Event);
|
||||
|
|
Loading…
Reference in New Issue
Block a user