2015-01-23 13:09:30 +00:00
|
|
|
|
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;
|
|
|
|
},
|
2015-01-23 13:09:30 +00:00
|
|
|
|
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;
|
|
|
|
},
|
2015-01-23 13:09:30 +00:00
|
|
|
|
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;
|
|
|
|
},
|
2015-01-23 13:09:30 +00:00
|
|
|
|
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-01-23 13:09:30 +00:00
|
|
|
|
2015-03-06 23:33:54 +00:00
|
|
|
return radio;
|
|
|
|
},
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
setInputTypeNumber(input) {
|
2015-03-06 23:33:54 +00:00
|
|
|
input.type = 'text';
|
|
|
|
}
|
|
|
|
};
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-05-30 01:30:33 +00:00
|
|
|
if (!Function.bind) {
|
|
|
|
Function.prototype.bind = function() {
|
2015-01-23 13:09:30 +00:00
|
|
|
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();
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
for (var i = 1; i < bindArgs.length; i++)
|
2022-05-30 01:30:33 +00:00
|
|
|
args.push(bindArgs[i]);
|
2015-01-23 13:09:30 +00:00
|
|
|
for (var i = 0; i < arguments.length; i++)
|
2022-05-30 01:30:33 +00:00
|
|
|
args.push(arguments[i]);
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-05-30 01:30:33 +00:00
|
|
|
bindFunc.apply(bindThis, args);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return IE_bind;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// attachEvent -> addEventListener
|
|
|
|
|
2022-05-30 01:30:33 +00:00
|
|
|
if (window.attachEvent && !window.addEventListener) {
|
|
|
|
function IE_addEventListener(signal, func, capture) {
|
2015-01-23 13:09:30 +00:00
|
|
|
var obj = this;
|
|
|
|
|
2022-05-30 01:30:33 +00:00
|
|
|
func.IE_eventHandler = function(event) {
|
2015-01-23 13:09:30 +00:00
|
|
|
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() {
|
2015-01-23 13:09:30 +00:00
|
|
|
this.cancelBubble = true;
|
|
|
|
}
|
|
|
|
|
2022-05-30 01:30:33 +00:00
|
|
|
func.call(obj, event);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-30 01:30:33 +00:00
|
|
|
this.attachEvent('on' + signal, func.IE_eventHandler);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-30 01:30:33 +00:00
|
|
|
function IE_removeEventListener(signal, func, capture) {
|
|
|
|
this.detachEvent('on' + signal, func.IE_eventHandler);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2015-01-23 13:09:30 +00:00
|
|
|
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');
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|