hedera-web/js/vn/ie.js

120 lines
2.7 KiB
JavaScript

module.exports = {
getPageYOffset: function() {
if (document.documentElement.scrollTop)
return document.documentElement.scrollTop;
else
return document.body.scrollTop;
},
getPageXOffset: function() {
if (document.documentElement.scrollLeft)
return document.documentElement.scrollLeft;
else
return document.body.scrollLeft;
},
getInnerHeight: function() {
if (document.documentElement.clientHeight)
return document.documentElement.clientHeight;
else
return document.body.clientHeight;
},
getInnerWidth: function() {
if (document.documentElement.clientWidth)
return document.documentElement.clientWidth;
else
return document.body.clientWidth;
},
createRadio: function(radioName) {
var radio;
try {
radio = document.createElement('<input type="radio" name="' + radioName + '">');
} catch (e) {
radio = document.createElement('input');
radio.type = 'radio';
radio.name = radioName;
}
return radio;
},
setInputTypeNumber: function(input) {
input.type = 'text';
}
};
if (!Function.bind) {
Function.prototype.bind = function() {
var bindFunc = this;
var bindThis = arguments[0];
var bindArgs = arguments;
var IE_bind = function() {
var args = new Array();
for (var i = 1; i < bindArgs.length; i++)
args.push(bindArgs[i]);
for (var i = 0; i < arguments.length; i++)
args.push(arguments[i]);
bindFunc.apply(bindThis, args);
}
return IE_bind;
}
}
// attachEvent -> addEventListener
if (window.attachEvent && !window.addEventListener) {
function IE_addEventListener(signal, func, capture) {
var obj = this;
func.IE_eventHandler = function(event) {
event.target = event.srcElement;
event.layerY = event.clientY;
event.layerX = event.clientX;
event.pageX = event.offsetX;
event.pageY = event.offsetY;
event.stopPropagation = function() {
this.cancelBubble = true;
}
func.call(obj, event);
}
this.attachEvent('on' + signal, func.IE_eventHandler);
}
function IE_removeEventListener(signal, func, capture) {
this.detachEvent('on' + signal, func.IE_eventHandler);
}
window.addEventListener = IE_addEventListener;
window.removeEventListener = IE_removeEventListener;
document.addEventListener = IE_addEventListener;
document.removeEventListener = IE_removeEventListener;
var IE_createElement = document.createElement;
document.createElement = function(tagName) {
var node = IE_createElement(tagName);
node.addEventListener = IE_addEventListener;
node.removeEventListener = IE_removeEventListener;
return node;
}
}
// ActiveXObject ('Microsoft.XMLHTTP') -> XMLHttpRequest
if (!window.XMLHttpRequest && window.ActiveXObject) {
function XMLHttpRequest() {
return new ActiveXObject('Microsoft.XMLHTTP');
}
}