📄 atlascompat_0.08.js
字号:
// This must be the first script file (except for the optional debug library)
// Dependencies: none
// Note: This file must only be downloaded by Mozilla
// If you can't exclude this file via server processing, it should be included using
// a conditional comment such as:
// <![if !IE]><script src="AtlasCompat.js"></script><![endif]>
var CompatVersion = "0.082305.0";
function registerNamespaces()
{
for (var i=0;i<arguments.length;i++)
{
var astrParts = arguments[i].split(".")
var root = window;
for (var j=0; j < astrParts.length; j++)
{
if (!root[astrParts[j]])
{
root[astrParts[j]] = new Object();
}
root = root[astrParts[j]];
}
}
}
registerNamespaces("Web.Browser","Web.Debug.Performance");
// Stub debug functions
if (!Web.Debug.Enabled)
{
Web.Debug.Enabled = false;
Web.Debug.Assert = Web.Debug.Trace = function() {};
Web.Debug.Performance.Start = function()
{
this.End = function(){}
return this
}
}
// Need more robust checks
Web.Browser._isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined');
Web.Browser.isMozilla = function()
{
return Web.Browser._isMozilla;
}
// Mozilla implementation of CreatePopup
Web.Browser._Private = function() {}
Web.Browser._Private.CreatePopup = function()
{
var obj = new Object();
obj.document = document.createDocumentFragment();
obj.document.body = obj.document.appendChild(document.createElement("div"));
obj.document.close = obj.document.open = function() {};
obj.document.write = function(v)
{
obj.document.body.innerHTML += v;
}
obj.show = function(x,y,width,height,offset)
{
if (!offset) offset = document.body;
var offsetLoc = Web.Dom.GetLocation(offset);
obj.document.body.style.cssText = "z-index:100;position:absolute;margin:0px;padding:0px;top:{0}px;left:{1}px;width:{2}px;height:{3}px;background:white".format(y+offsetLoc.top,x+offsetLoc.left,width,height);
var r = document.body.appendChild(obj.document.body);
document.addEventListener("mousedown",doHide,true)
r.onclicktemp = obj.document.onclick;
r.onclick = doClick
function doHide(ev)
{
if (!obj.document.body.contains(ev.target))
{
ev.stopPropagation()
r.removeNode();
}
document.removeEventListener("mousedown",doHide,true);
}
function doClick(ev)
{
if (this.onclicktemp)
this.onclicktemp()
r.removeNode();
}
}
return obj;
}
// Stub out filters
Web.Browser._Private.MozillaFilterMethods = new Array("addAmbient","addCone","addPoint","apply","changeColor","changeStrength","clear","moveLight")
Web.Browser._Private.MozillaFilterEventMethods = new Array("play","stop");
Web.Browser._Private.MozillaFilterSub = function()
{
// Need to implement item, etc)
// Use prototype to make more efficient
var privFilter = Web.Browser._Private;
for (var i=0;i<privFilter.MozillaFilterMethods.length;i++)
this[privFilter.MozillaFilterMethods[i]] = doblank;
for (var i=0;i<privFilter.MozillaFilterEventMethods.length;i++)
this[privFilter.MozillaFilterEventMethods[i]] = doevent;
function doblank() {}
function doevent()
{ // TODO - need to hook up event object and related properties
if (this.onfilterchange) this.onfilterchange();
}
return this;
}
Web.Browser.AttachMozillaCompatibility = function (w)
{
// Mozilla->IE Compatibility Library
w.CollectGarbage = function() {};
function EstablishMode()
{
var el = w.document.getElementsByName("Web.moz-custom");
if (el.length>0)
Web.Browser.MozillaCompatMode = el[0].getAttribute("content").toLowerCase()=="enabled";
else
Web.Browser.MozillaCompatMode = false;
}
EstablishMode();
function GenWindowEvent(e) {
window.event = e;
}
Web.Browser.Button = {LEFT:0,RIGHT:2,MIDDLE:1};
function Map(el,mozillaType, callback)
{
var strMozillaType = mozillaType.slice(2);
if (strMozillaType=="mousewheel")
{
strMozillaType = "DOMMouseScroll";
}
if (strMozillaType!="mouseenter" && strMozillaType!="mouseleave")
{
el.addEventListener(strMozillaType, GenWindowEvent, true); // Grab events first to establish window object
}
else // Simulate events
{
el.addEventListener("mouseover", GenWindowEvent, true); // Grab events first to establish window object
el.addEventListener("mouseout", GenWindowEvent, true); // Grab events first to establish window object
el.addEventListener("mouseover",CheckEnter,false);
el.addEventListener("mouseout",CheckLeave,false);
}
el.addEventListener(strMozillaType, callback, false); // Hook the actual event
}
function CheckEnter()
{
if (!this.contains(event.fromElement))
{
var oEvent = document.createEvent("MouseEvents");
oEvent.initEvent("mouseenter",false,false);
this.dispatchEvent(oEvent)
}
}
function CheckLeave()
{
if (!this.contains(event.toElement))
{
var oEvent = document.createEvent("MouseEvents");
oEvent.initEvent("mouseleave",false,false);
this.dispatchEvent(oEvent)
}
}
function RemoveMap(el,mozillaType,callback)
{
var strMozillaType = mozillaType.slice(2)
if (mozillaType=="mousewheel")
{
strMozillaType = "DOMMouseScroll";
}
el.removeEventListener(strMozillaType, callback, false);
}
function GetNonTextNode(n)
{
try
{
while (n && n.nodeType!=1) n=n.parentNode;
}
catch(ex)
{
n = null;
}
return n;
}
var elementProto = w.Element.prototype;
var htmlProto = w.HTMLDocument.prototype;
var eventProto = w.Event.prototype;
var cssProto = w.CSSStyleDeclaration.prototype;
var docProto = w.Document.prototype;
w.attachEvent = w.HTMLDocument.prototype.attachEvent = w.HTMLElement.prototype.attachEvent = function (type, callback) {Map(this,type,callback);}
w.detachEvent = w.HTMLDocument.prototype.detachEvent = w.HTMLElement.prototype.detachEvent = function (type, callback) {RemoveMap(this,type,callback);}
w.createPopup = Web.Browser._Private.CreatePopup;
// TODO - implement this on nodes
docProto.__proto__ = {
get xml(){ return (new XMLSerializer()).serializeToString(this);},
__proto__ : docProto.__proto__
}
w.Document.prototype.scripts = document.getElementsByTagName("script");
// TODO - implement selection
w.Document.prototype.selection = new Object();
w.Document.prototype.selection.clear = function() {}; // Need to find Mozilla equivalent
w.Document.prototype.selection.createRange = function() {return window.getSelection().getRangeAt(0);}
w.XMLDocument.prototype.transformNodeToObject = function(p_objXsl)
{
var objXslProcessor = new XSLTProcessor();
objXslProcessor.importStylesheet(p_objXsl);
var ownerDocument = document.implementation.createDocument("", "", null);
return objXslProcessor.transformToFragment(this, ownerDocument);
}
w.HTMLElement.prototype.removeNode = function(b)
{
return this.parentNode.removeChild(this)
}
w.HTMLElement.prototype.contains = function (el)
{
while (el!=null && el!=this)
el = el.parentElement;
return (el!=null)
};
function CurrentStyle(el)
{
// Extend this if additional CurrentStyle properties are required
var PropertyList = new Array("Top","Left","Right","Bottom");
var cs = document.defaultView.getComputedStyle(el,null);
for (var i=0;i<PropertyList.length;i++)
{
var p = PropertyList[i]
this["border" + p + "Width"] = cs.getPropertyValue("border-" + p + "-width")
this["margin" + p] = cs.getPropertyValue("margin-" + p)
this["padding" + p] = cs.getPropertyValue("padding-" + p)
}
this["position"] = cs.getPropertyValue("position");
this["height"] = cs.getPropertyValue("height");
this["width"] = cs.getPropertyValue("width");
this["zIndex"] = cs.getPropertyValue("z-index");
return this;
}
w.HTMLElement.prototype.filters = Web.Browser._Private.MozillaFilterSub(); // stub out
var m_Capturing = false;
var root = document.getElementsByTagName("HTML")[0];
function CaptureMouse(ev)
{
if (m_Capturing)
{
ev.preventDefault();
ev.returnValue = false;
document.removeEventListener("mousemove",CaptureMouse,true);
var oEvent = document.createEvent("MouseEvents");
oEvent.initMouseEvent(ev.type,
ev.bubbles, ev.cancelable, ev.view, ev.detail,
ev.screenX, ev.screenY, ev.clientX, ev.clientY,
ev.ctrlKey, ev.altKey, ev.shiftKey, ev.metaKey,
ev.button, ev.relatedTarget);
oEvent._FixOffset = GetNonTextNode(ev.srcElement);
if (oEvent._FixOffset == root)
oEvent._FixOffset = document.body;
m_Capturing.dispatchEvent(oEvent);
oEvent._FixOffset = null;
document.addEventListener("mousemove",CaptureMouse,true);
ev.stopPropagation();
}
}
function ReleaseMouse(ev)
{
if (m_Capturing)
{
document.removeEventListener("mouseup",ReleaseMouse,true);
document.removeEventListener("mousemove",CaptureMouse,true);
var eventCanBubble = ev.bubbles;
var eventIsCancelable = ev.cancelable;
if (ev.type == "mouseup")
{
eventCanBubble = false;
eventIsCancelable = false;
}
var oEvent = document.createEvent("MouseEvents");
oEvent.initMouseEvent(ev.type,
eventCanBubble, eventIsCancelable, ev.view, ev.detail,
ev.screenX, ev.screenY, ev.clientX, ev.clientY,
ev.ctrlKey, ev.altKey, ev.shiftKey, ev.metaKey,
ev.button, ev.relatedTarget);
oEvent._FixOffset = GetNonTextNode(ev.srcElement);
if (oEvent._FixOffset == root)
oEvent._FixOffset = document.body;
m_Capturing.dispatchEvent(oEvent);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -