Remove old IE support froM WMD, part II

native methods that IE8 didn't support but IE9 does
This commit is contained in:
Jeff Atwood 2014-10-12 00:46:08 -07:00
parent 28b9176bbc
commit 43bcde2060
1 changed files with 7 additions and 43 deletions

View File

@ -38,7 +38,7 @@
doc = window.document, doc = window.document,
re = window.RegExp, re = window.RegExp,
nav = window.navigator, nav = window.navigator,
SETTINGS = { lineLength: 72 } SETTINGS = { lineLength: 72 };
var defaultsStrings = { var defaultsStrings = {
@ -330,43 +330,21 @@
// Returns true if the DOM element is visible, false if it's hidden. // Returns true if the DOM element is visible, false if it's hidden.
// Checks if display is anything other than none. // Checks if display is anything other than none.
util.isVisible = function (elem) { util.isVisible = function (elem) {
if (window.getComputedStyle) {
// Most browsers
return window.getComputedStyle(elem, null).getPropertyValue("display") !== "none"; return window.getComputedStyle(elem, null).getPropertyValue("display") !== "none";
}
else if (elem.currentStyle) {
// IE
return elem.currentStyle["display"] !== "none";
}
}; };
// Adds a listener callback to a DOM element which is fired on a specified // Adds a listener callback to a DOM element which is fired on a specified
// event. // event.
util.addEvent = function (elem, event, listener) { util.addEvent = function (elem, event, listener) {
if (elem.attachEvent) {
// IE only. The "on" is mandatory.
elem.attachEvent("on" + event, listener);
}
else {
// Other browsers.
elem.addEventListener(event, listener, false); elem.addEventListener(event, listener, false);
}
}; };
// Removes a listener callback from a DOM element which is fired on a specified // Removes a listener callback from a DOM element which is fired on a specified
// event. // event.
util.removeEvent = function (elem, event, listener) { util.removeEvent = function (elem, event, listener) {
if (elem.detachEvent) {
// IE only. The "on" is mandatory.
elem.detachEvent("on" + event, listener);
}
else {
// Other browsers.
elem.removeEventListener(event, listener, false); elem.removeEventListener(event, listener, false);
}
}; };
// Converts \r\n and \r to \n. // Converts \r\n and \r to \n.
@ -449,21 +427,8 @@
scrollHeight = doc.body.offsetHeight; scrollHeight = doc.body.offsetHeight;
} }
if (self.innerHeight) {
// Non-IE browser
innerWidth = self.innerWidth; innerWidth = self.innerWidth;
innerHeight = self.innerHeight; innerHeight = self.innerHeight;
}
else if (doc.documentElement && doc.documentElement.clientHeight) {
// Some versions of IE (IE 6 w/ a DOCTYPE declaration)
innerWidth = doc.documentElement.clientWidth;
innerHeight = doc.documentElement.clientHeight;
}
else if (doc.body) {
// Other versions of IE
innerWidth = doc.body.clientWidth;
innerHeight = doc.body.clientHeight;
}
var maxWidth = Math.max(scrollWidth, innerWidth); var maxWidth = Math.max(scrollWidth, innerWidth);
var maxHeight = Math.max(scrollHeight, innerHeight); var maxHeight = Math.max(scrollHeight, innerHeight);
@ -594,8 +559,7 @@
if ((event.ctrlKey || event.metaKey) && !event.altKey) { if ((event.ctrlKey || event.metaKey) && !event.altKey) {
// IE and Opera do not support charCode. var keyCode = event.charCode;
var keyCode = event.charCode || event.keyCode;
var keyCodeChar = String.fromCharCode(keyCode); var keyCodeChar = String.fromCharCode(keyCode);
switch (keyCodeChar.toLowerCase()) { switch (keyCodeChar.toLowerCase()) {