0
1
Fork 0
hedera-web-mindshore/js/vn/ie.js

120 lines
2.7 KiB
JavaScript
Raw Normal View History

2022-05-30 01:30:33 +00:00
module.exports = {
2022-11-16 01:46:44 +00:00
getPageYOffset() {
2015-03-06 23:33:54 +00:00
if (document.documentElement.scrollTop)
return document.documentElement.scrollTop;
else
return document.body.scrollTop;
},
2022-11-16 01:46:44 +00:00
getPageXOffset() {
2015-03-06 23:33:54 +00:00
if (document.documentElement.scrollLeft)
return document.documentElement.scrollLeft;
else
return document.body.scrollLeft;
},
2022-11-16 01:46:44 +00:00
getInnerHeight() {
2015-03-06 23:33:54 +00:00
if (document.documentElement.clientHeight)
return document.documentElement.clientHeight;
else
return document.body.clientHeight;
},
2022-11-16 01:46:44 +00:00
getInnerWidth() {
2015-03-06 23:33:54 +00:00
if (document.documentElement.clientWidth)
return document.documentElement.clientWidth;
else
return document.body.clientWidth;
},
2022-11-16 01:46:44 +00:00
createRadio(radioName) {
2015-03-06 23:33:54 +00:00
var radio;
try {
2022-05-30 01:30:33 +00:00
radio = document.createElement('<input type="radio" name="' + radioName + '">');
} catch (e) {
radio = document.createElement('input');
2015-03-06 23:33:54 +00:00
radio.type = 'radio';
radio.name = radioName;
}
2015-03-06 23:33:54 +00:00
return radio;
},
2022-11-16 01:46:44 +00:00
setInputTypeNumber(input) {
2015-03-06 23:33:54 +00:00
input.type = 'text';
}
};
2022-05-30 01:30:33 +00:00
if (!Function.bind) {
Function.prototype.bind = function() {
var bindFunc = this;
var bindThis = arguments[0];
var bindArgs = arguments;
2022-05-30 01:30:33 +00:00
var IE_bind = function() {
var args = new Array();
for (var i = 1; i < bindArgs.length; i++)
2022-05-30 01:30:33 +00:00
args.push(bindArgs[i]);
for (var i = 0; i < arguments.length; i++)
2022-05-30 01:30:33 +00:00
args.push(arguments[i]);
2022-05-30 01:30:33 +00:00
bindFunc.apply(bindThis, args);
}
return IE_bind;
}
}
// attachEvent -> addEventListener
2022-05-30 01:30:33 +00:00
if (window.attachEvent && !window.addEventListener) {
function IE_addEventListener(signal, func, capture) {
var obj = this;
2022-05-30 01:30:33 +00:00
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;
2022-05-30 01:30:33 +00:00
event.stopPropagation = function() {
this.cancelBubble = true;
}
2022-05-30 01:30:33 +00:00
func.call(obj, event);
}
2022-05-30 01:30:33 +00:00
this.attachEvent('on' + signal, func.IE_eventHandler);
}
2022-05-30 01:30:33 +00:00
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;
2022-05-30 01:30:33 +00:00
document.createElement = function(tagName) {
var node = IE_createElement(tagName);
node.addEventListener = IE_addEventListener;
node.removeEventListener = IE_removeEventListener;
return node;
}
}
// ActiveXObject ('Microsoft.XMLHTTP') -> XMLHttpRequest
2022-05-30 01:30:33 +00:00
if (!window.XMLHttpRequest && window.ActiveXObject) {
function XMLHttpRequest() {
return new ActiveXObject('Microsoft.XMLHTTP');
}
}