From 9da5a59401ba850ea0fdb4a6c116dbdb0a183a5c Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Mon, 6 May 2013 21:56:21 -0400 Subject: fixed IE8 issues in the editor and on the question page --- askbot/media/js/wmd/wmd.js | 21 ++++++++------------- askbot/templates/question.html | 6 +++++- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/askbot/media/js/wmd/wmd.js b/askbot/media/js/wmd/wmd.js index c3c85b21..35a571e5 100644 --- a/askbot/media/js/wmd/wmd.js +++ b/askbot/media/js/wmd/wmd.js @@ -452,8 +452,7 @@ util.prompt = function(text, defaultInputText, makeLinkMarkdown, dialogType){ if (input.type == 'text' && input.selectionStart !== undefined) { input.selectionStart = 0; input.selectionEnd = defTextLen; - } - else if (input.createTextRange) { + } else if (input.createTextRange) { var range = input.createTextRange(); range.collapse(false); range.moveStart("character", -defTextLen); @@ -494,30 +493,26 @@ util.prompt = function(text, defaultInputText, makeLinkMarkdown, dialogType){ var innerWidth, innerHeight; // It's not very clear which blocks work with which browsers. - if(self.innerHeight && self.scrollMaxY){ + if (self.innerHeight && self.scrollMaxY) { scrollWidth = doc.body.scrollWidth; scrollHeight = self.innerHeight + self.scrollMaxY; - } - else if(doc.body.scrollHeight > doc.body.offsetHeight){ + } else if (doc.body.scrollHeight > doc.body.offsetHeight){ scrollWidth = doc.body.scrollWidth; scrollHeight = doc.body.scrollHeight; - } - else{ + } else { scrollWidth = doc.body.offsetWidth; scrollHeight = doc.body.offsetHeight; } - if(self.innerHeight){ + if (self.innerHeight) { // Non-IE browser innerWidth = self.innerWidth; innerHeight = self.innerHeight; - } - else if(doc.documentElement && doc.documentElement.clientHeight){ + } 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){ + } else if(doc.body) { // Other versions of IE innerWidth = doc.body.clientWidth; innerHeight = doc.body.clientHeight; @@ -1950,7 +1945,7 @@ util.prompt = function(text, defaultInputText, makeLinkMarkdown, dialogType){ var result = 0; - if (innerHeight) { + if (window.innerHeight) { result = pageYOffset; } else diff --git a/askbot/templates/question.html b/askbot/templates/question.html index 9a508a2f..a8aef0a7 100644 --- a/askbot/templates/question.html +++ b/askbot/templates/question.html @@ -43,6 +43,10 @@ return nodes; }; + var getTextContent = function(node) { + return node.innerText || node.textContent; + }; + var hasAttribute = function(node, attrName) { if (node.hasAttribute) { return node.hasAttribute(attrName); @@ -139,7 +143,7 @@ //todo: this is not reliable var answerBodyNodes = answerBody.childNodes; var answerElement = answerBodyNodes[answerBodyNodes.length - 1]; - if (trim(answerElement.textContent).length > askbot['data']['maxCommentLength']) { + if (trim(getTextContent(answerElement)).length > askbot['data']['maxCommentLength']) { repostAsQuestionComment.parentNode.removeChild(repostAsQuestionComment); repostAsPrevAnsComment.parentNode.removeChild(repostAsPrevAnsComment); } else if (parseInt(post_id) === data['oldestAnswerId']) { -- cgit v1.2.3-1-g7c22