From eacf1118f86fa0bf489fa86f65b970347f45077a Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 21 Jan 2015 02:55:03 +0000 Subject: [PATCH 1/8] blind attempt to try --- src/static/js/ace2_inner.js | 20 ++++++++------------ src/static/js/contentcollector.js | 3 ++- src/static/js/domline.js | 4 ++-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index bd1f0053f..d2952ffe3 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -34,8 +34,9 @@ var isNodeText = Ace2Common.isNodeText, binarySearchInfinite = Ace2Common.binarySearchInfinite, htmlPrettyEscape = Ace2Common.htmlPrettyEscape, noop = Ace2Common.noop; - var hooks = require('./pluginfw/hooks'); - var browser = require('./browser').browser; + +var hooks = require('./pluginfw/hooks'); +var browser = require('./browser').browser; function Ace2Inner(){ @@ -944,7 +945,7 @@ function Ace2Inner(){ showslinenumbers : function(value){ hasLineNumbers = !! value; // disable line numbers on mobile devices - if (browser.mobile) hasLineNumbers = false; + // if (browser.mobile) hasLineNumbers = false; setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers); fixView(); }, @@ -1605,7 +1606,7 @@ function Ace2Inner(){ if (linesWrapped > 0) { - if(!browser.ie){ + if(!browser.msie){ // chrome decides in it's infinite wisdom that its okay to put the browsers visisble window in the middle of the span // an outcome of this is that the first chars of the string are no longer visible to the user.. Yay chrome.. // Move the browsers visible area to the left hand side of the span @@ -2964,6 +2965,7 @@ function Ace2Inner(){ } else { + // cake return domline.createDomLine(nonEmpty, doesWrap, browser, doc); } } @@ -3583,7 +3585,7 @@ function Ace2Inner(){ // On Mac and Linux, move right moves to end of word and move left moves to start; // on Windows, always move to start of word. // On Windows, Firefox and IE disagree on whether to stop for punctuation (FF says no). - if (browser.windows && forwardNotBack) + if (browser.msie && forwardNotBack) { while ((!isDone()) && isWordChar(nextChar())) { @@ -4264,12 +4266,6 @@ function Ace2Inner(){ end.collapse(false); selection.startPoint = pointFromCollapsedRange(start); selection.endPoint = pointFromCollapsedRange(end); -/*if ((!selection.startPoint.node.isText) && (!selection.endPoint.node.isText)) { - console.log(selection.startPoint.node.uniqueId()+","+ - selection.startPoint.index+" / "+ - selection.endPoint.node.uniqueId()+","+ - selection.endPoint.index); -}*/ } return selection; } @@ -4867,7 +4863,7 @@ function Ace2Inner(){ }) // CompositionEvent is not implemented below IE version 8 - if ( !(browser.msie && browser.version < 9) && document.documentElement) + if ( !(browser.msie && browser.version <= 9) && document.documentElement) { $(document.documentElement).on("compositionstart", handleCompositionEvent); $(document.documentElement).on("compositionend", handleCompositionEvent); diff --git a/src/static/js/contentcollector.js b/src/static/js/contentcollector.js index b7b3c568b..7a6deeb11 100644 --- a/src/static/js/contentcollector.js +++ b/src/static/js/contentcollector.js @@ -37,7 +37,8 @@ function sanitizeUnicode(s) function makeContentCollector(collectStyles, browser, apool, domInterface, className2Author) { - browser = browser || {}; + // browser = browser || {}; + // I don't like the above. var dom = domInterface || { isNodeText: function(n) diff --git a/src/static/js/domline.js b/src/static/js/domline.js index b1927b162..e793956b5 100644 --- a/src/static/js/domline.js +++ b/src/static/js/domline.js @@ -65,7 +65,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument) lineMarker: 0 }; - var browser = (optBrowser || {}); + // var browser = (optBrowser || {}); var document = optDocument; if (document) @@ -225,7 +225,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument) { newHTML += ' '; } - else if (!browser.msie) + else if (!optBrowser.msie) { newHTML += '
'; } From 34d6b31c983475e7bf222a593e937fdee796788d Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 21 Jan 2015 13:24:21 +0000 Subject: [PATCH 2/8] some sanity --- src/static/js/ace2_inner.js | 93 ++++++++++++++++------------------ src/static/js/broadcast.js | 12 ----- src/static/js/collab_client.js | 2 +- src/static/js/pad.js | 3 +- 4 files changed, 47 insertions(+), 63 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index d2952ffe3..8adbc8dcd 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -19,8 +19,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -var _, $, jQuery, plugins, Ace2Common; - +var _, $, jQuery, plugins, Ace2Common, mybrowser; +mybrowser = require('./browser').browser; Ace2Common = require('./ace2_common'); plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins'); @@ -36,7 +36,6 @@ var isNodeText = Ace2Common.isNodeText, noop = Ace2Common.noop; var hooks = require('./pluginfw/hooks'); -var browser = require('./browser').browser; function Ace2Inner(){ @@ -599,7 +598,7 @@ function Ace2Inner(){ // Chrome can't handle the truth.. If CSS rule white-space:pre-wrap // is true then any paste event will insert two lines.. - if(browser.chrome){ + if(mybrowser.chrome){ $("#innerdocbody").css({"white-space":"normal"}); } @@ -945,7 +944,7 @@ function Ace2Inner(){ showslinenumbers : function(value){ hasLineNumbers = !! value; // disable line numbers on mobile devices - // if (browser.mobile) hasLineNumbers = false; + // if (mybrowser.mobile) hasLineNumbers = false; setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers); fixView(); }, @@ -1312,7 +1311,9 @@ function Ace2Inner(){ else { var offsetIntoLine = 0; - var filteredFunc = linestylefilter.getFilterStack(text, textAndClassFunc, browser); +mybrowser.msie = false; // cake 1 + var filteredFunc = linestylefilter.getFilterStack(text, textAndClassFunc, mybrowser); +mybrowser.msie = true; var lineNum = rep.lines.indexOfEntry(lineEntry); var aline = rep.alines[lineNum]; filteredFunc = linestylefilter.getLineStyleFilter( @@ -1560,13 +1561,16 @@ function Ace2Inner(){ lastDirtyNode = (lastDirtyNode && isNodeDirty(lastDirtyNode) && lastDirtyNode); if (firstDirtyNode && lastDirtyNode) { - var cc = makeContentCollector(isStyled, browser, rep.apool, null, className2Author); +// cake 2 +mybrowser.msie = false; + var cc = makeContentCollector(isStyled, mybrowser, rep.apool, null, className2Author); +mybrowser.msie = true; cc.notifySelection(selection); var dirtyNodes = []; for (var n = firstDirtyNode; n && !(n.previousSibling && n.previousSibling == lastDirtyNode); n = n.nextSibling) { - if (browser.msie) + if (mybrowser.msie) { // try to undo IE's pesky and overzealous linkification try @@ -1606,7 +1610,7 @@ function Ace2Inner(){ if (linesWrapped > 0) { - if(!browser.msie){ + if(!mybrowser.msie){ // chrome decides in it's infinite wisdom that its okay to put the browsers visisble window in the middle of the span // an outcome of this is that the first chars of the string are no longer visible to the user.. Yay chrome.. // Move the browsers visible area to the left hand side of the span @@ -1911,7 +1915,7 @@ function Ace2Inner(){ if (charsLeft === 0) { var index = 0; - if (browser.msie && line == (rep.lines.length() - 1) && lineNode.childNodes.length === 0) + if (mybrowser.msie && line == (rep.lines.length() - 1) && lineNode.childNodes.length === 0) { // best to stay at end of last empty div in IE index = 1; @@ -2904,7 +2908,7 @@ function Ace2Inner(){ function doCreateDomLine(nonEmpty) { - if (browser.msie && (!nonEmpty)) + if (mybrowser.msie && (!nonEmpty)) { var result = { node: null, @@ -2965,8 +2969,10 @@ function Ace2Inner(){ } else { - // cake - return domline.createDomLine(nonEmpty, doesWrap, browser, doc); + // cake 3 +mybrowser.msie = false; + return domline.createDomLine(nonEmpty, doesWrap, mybrowser, doc); +mybrowser.msie = true; } } @@ -3233,7 +3239,7 @@ function Ace2Inner(){ var dirtiness = {}; dirtiness.nodeId = uniqueId(n); dirtiness.knownHTML = n.innerHTML; - if (browser.msie) + if (mybrowser.msie) { // adding a space to an "empty" div in IE designMode doesn't // change the innerHTML of the div's parent; also, other @@ -3250,7 +3256,7 @@ function Ace2Inner(){ var data = getAssoc(n, "dirtiness"); if (!data) return true; if (n.id !== data.nodeId) return true; - if (browser.msie) + if (mybrowser.msie) { if (n.innerText !== data.knownText) return true; } @@ -3585,7 +3591,7 @@ function Ace2Inner(){ // On Mac and Linux, move right moves to end of word and move left moves to start; // on Windows, always move to start of word. // On Windows, Firefox and IE disagree on whether to stop for punctuation (FF says no). - if (browser.msie && forwardNotBack) + if (mybrowser.msie && forwardNotBack) { while ((!isDone()) && isWordChar(nextChar())) { @@ -3657,13 +3663,13 @@ function Ace2Inner(){ if (isModKey) return; // If the key is a keypress and the browser is opera and the key is enter, do nothign at all as this fires twice. - if (keyCode == 13 && browser.opera && (type == "keypress")){ + if (keyCode == 13 && mybrowser.opera && (type == "keypress")){ return; // This stops double enters in Opera but double Tabs still show on single tab keypress, adding keyCode == 9 to this doesn't help as the event is fired twice } var specialHandled = false; - var isTypeForSpecialKey = ((browser.msie || browser.safari || browser.chrome) ? (type == "keydown") : (type == "keypress")); - var isTypeForCmdKey = ((browser.msie || browser.safari || browser.chrome) ? (type == "keydown") : (type == "keypress")); + var isTypeForSpecialKey = ((mybrowser.msie || mybrowser.safari || mybrowser.chrome) ? (type == "keydown") : (type == "keypress")); + var isTypeForCmdKey = ((mybrowser.msie || mybrowser.safari || mybrowser.chrome) ? (type == "keydown") : (type == "keypress")); var stopped = false; @@ -3880,7 +3886,7 @@ function Ace2Inner(){ /* Attempt to apply some sanity to cursor handling in Chrome after a copy / paste event We have to do this the way we do because rep. doesn't hold the value for keyheld events IE if the user presses and holds the arrow key .. Sorry if this is ugly, blame Chrome's weird handling of viewports after new content is added*/ - if((evt.which == 37 || evt.which == 38 || evt.which == 39 || evt.which == 40) && browser.chrome){ + if((evt.which == 37 || evt.which == 38 || evt.which == 39 || evt.which == 40) && mybrowser.chrome){ var viewport = getViewPortTopBottom(); var myselection = document.getSelection(); // get the current caret selection, can't use rep. here because that only gives us the start position not the current var caretOffsetTop = myselection.focusNode.parentNode.offsetTop || myselection.focusNode.offsetTop; // get the carets selection offset in px IE 214 @@ -3951,10 +3957,10 @@ function Ace2Inner(){ } // Is part of multi-keystroke international character on Firefox Mac - var isFirefoxHalfCharacter = (browser.mozilla && evt.altKey && charCode === 0 && keyCode === 0); + var isFirefoxHalfCharacter = (mybrowser.firefox && evt.altKey && charCode === 0 && keyCode === 0); // Is part of multi-keystroke international character on Safari Mac - var isSafariHalfCharacter = (browser.safari && evt.altKey && keyCode == 229); + var isSafariHalfCharacter = (mybrowser.safari && evt.altKey && keyCode == 229); if (thisKeyDoesntTriggerNormalize || isFirefoxHalfCharacter || isSafariHalfCharacter) { @@ -4068,7 +4074,7 @@ function Ace2Inner(){ // each of which has node (a magicdom node), index, and maxIndex. If the node // is a text node, maxIndex is the length of the text; else maxIndex is 1. // index is between 0 and maxIndex, inclusive. - if (browser.msie) + if (mybrowser.msie) { var browserSelection; try @@ -4364,7 +4370,7 @@ function Ace2Inner(){ maxIndex: pt.maxIndex }; } - if (browser.msie) + if (mybrowser.msie) { // Oddly enough, accessing scrollHeight fixes return key handling on IE 8, // presumably by forcing some kind of internal DOM update. @@ -4653,17 +4659,17 @@ function Ace2Inner(){ for (var i = 0; i < 2; i++) { var newHeight = root.clientHeight; - var newWidth = (browser.msie ? root.createTextRange().boundingWidth : root.clientWidth); + var newWidth = root.clientWidth; var viewHeight = getInnerHeight() - iframePadBottom - iframePadTop; var viewWidth = getInnerWidth() - iframePadLeft - iframePadRight; if (newHeight < viewHeight) { newHeight = viewHeight; - if (browser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'auto'); +// if (mybrowser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'auto'); } else { - if (browser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'scroll'); +// if (mybrowser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'scroll'); } if (doesWrap) { @@ -4677,7 +4683,7 @@ function Ace2Inner(){ setIfNecessary(iframe.style, "width", newWidth + "px"); setIfNecessary(sideDiv.style, "height", newHeight + "px"); } - if (browser.mozilla) + if (mybrowser.firefox) { if (!doesWrap) { @@ -4776,14 +4782,14 @@ function Ace2Inner(){ } return false; } - if (browser.msie || browser.safari) + if (mybrowser.msie || mybrowser.safari) { setIfNecessary(root, 'contentEditable', (newVal ? 'true' : 'false')); } else { var wasSet = setIfNecessary(doc, 'designMode', (newVal ? 'on' : 'off')); - if (wasSet && newVal && browser.opera) + if (wasSet && newVal && mybrowser.opera) { // turning on designMode clears event handlers bindTheEventHandlers(); @@ -4849,11 +4855,11 @@ function Ace2Inner(){ $(document).on("keyup", handleKeyEvent); $(document).on("click", handleClick); $(root).on("blur", handleBlur); - if (browser.msie) + if (mybrowser.msie) { $(document).on("click", handleIEOuterClick); } - if (browser.msie) $(root).on("paste", handleIEPaste); + if (mybrowser.msie) $(root).on("paste", handleIEPaste); // Don't paste on middle click of links $(root).on("paste", function(e){ @@ -4863,7 +4869,7 @@ function Ace2Inner(){ }) // CompositionEvent is not implemented below IE version 8 - if ( !(browser.msie && browser.version <= 9) && document.documentElement) + if ( !(mybrowser.msie && mybrowser.version <= 9) && document.documentElement) { $(document.documentElement).on("compositionstart", handleCompositionEvent); $(document.documentElement).on("compositionend", handleCompositionEvent); @@ -4926,7 +4932,7 @@ function Ace2Inner(){ function handleBlur(evt) { - if (browser.msie) + if (mybrowser.msie) { // a fix: in IE, clicking on a control like a button outside the // iframe can "blur" the editor, causing it to stop getting @@ -4997,7 +5003,7 @@ function Ace2Inner(){ var win = outerWin; var odoc = win.document; var h; - if (browser.opera) h = win.innerHeight; + if (mybrowser.opera) h = win.innerHeight; else h = odoc.documentElement.clientHeight; if (h) return h; @@ -5326,20 +5332,9 @@ function Ace2Inner(){ { var body = doc.getElementById("innerdocbody"); root = body; // defined as a var in scope outside - if (browser.mozilla) $(root).addClass("mozilla"); - if (browser.safari) $(root).addClass("safari"); - if (browser.msie) $(root).addClass("msie"); - if (browser.msie) - { - // cache CSS background images - try - { - doc.execCommand("BackgroundImageCache", false, true); - } - catch (e) - { /* throws an error in some IE 6 but not others! */ - } - } + if (mybrowser.firefox) $(root).addClass("mozilla"); + if (mybrowser.safari) $(root).addClass("safari"); + if (mybrowser.msie) $(root).addClass("msie"); setClassPresence(root, "authorColors", true); setClassPresence(root, "doesWrap", doesWrap); diff --git a/src/static/js/broadcast.js b/src/static/js/broadcast.js index a25d889b9..817155b55 100644 --- a/src/static/js/broadcast.js +++ b/src/static/js/broadcast.js @@ -66,18 +66,6 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro } } - // for IE - if (browser.msie) - { - try - { - document.execCommand("BackgroundImageCache", false, true); - } - catch (e) - {} - } - - //var socket; var channelState = "DISCONNECTED"; diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js index 6089f1972..8bc5020b1 100644 --- a/src/static/js/collab_client.js +++ b/src/static/js/collab_client.js @@ -82,7 +82,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) {} }; - if (browser.mozilla) + if (browser.firefox) { // Prevent "escape" from taking effect and canceling a comet connection; // doesn't work if focus is on an iframe. diff --git a/src/static/js/pad.js b/src/static/js/pad.js index ff62f86cc..685b420b1 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -494,7 +494,8 @@ var pad = { pad.initTime = +(new Date()); pad.padOptions = clientVars.initialOptions; - if ((!browser.msie) && (!(browser.mozilla && browser.version.indexOf("1.8.") == 0))) +console.log("pad", browser); + if ((!browser.msie) && (!(browser.firefox && browser.version.indexOf("1.8.") == 0))) { document.domain = document.domain; // for comet } From 990e14c9042cacd03ff16259b9140a28269678c9 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 21 Jan 2015 14:25:24 +0000 Subject: [PATCH 3/8] working with a big hack --- src/static/js/ace2_inner.js | 32 +++++++++++++++---------------- src/static/js/collab_client.js | 1 - src/static/js/contentcollector.js | 10 +++++----- src/static/js/domline.js | 3 ++- src/static/js/linestylefilter.js | 6 +++--- 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 8adbc8dcd..aa65ff958 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -21,6 +21,15 @@ */ var _, $, jQuery, plugins, Ace2Common, mybrowser; mybrowser = require('./browser').browser; + +if(mybrowser.msie){ + // Honestly fuck IE royally. + // Basically every hack we have since V11 causes a problem + if(parseInt(mybrowser.version) >= 11){ + delete mybrowser.msie; + mybrowser.firefox = true; + } +} Ace2Common = require('./ace2_common'); plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins'); @@ -1311,9 +1320,7 @@ function Ace2Inner(){ else { var offsetIntoLine = 0; -mybrowser.msie = false; // cake 1 var filteredFunc = linestylefilter.getFilterStack(text, textAndClassFunc, mybrowser); -mybrowser.msie = true; var lineNum = rep.lines.indexOfEntry(lineEntry); var aline = rep.alines[lineNum]; filteredFunc = linestylefilter.getLineStyleFilter( @@ -1355,7 +1362,7 @@ mybrowser.msie = true; // (from how it looks in our representation) and record them in a way // that can be used to "normalize" the document (apply the changes to our // representation, and put the DOM in a canonical form). - //top.console.log("observeChangesAroundNode(%o)", node); + // top.console.log("observeChangesAroundNode(%o)", node); var cleanNode; var hasAdjacentDirtyness; if (!isNodeDirty(node)) @@ -1561,10 +1568,7 @@ mybrowser.msie = true; lastDirtyNode = (lastDirtyNode && isNodeDirty(lastDirtyNode) && lastDirtyNode); if (firstDirtyNode && lastDirtyNode) { -// cake 2 -mybrowser.msie = false; var cc = makeContentCollector(isStyled, mybrowser, rep.apool, null, className2Author); -mybrowser.msie = true; cc.notifySelection(selection); var dirtyNodes = []; for (var n = firstDirtyNode; n && !(n.previousSibling && n.previousSibling == lastDirtyNode); @@ -2964,15 +2968,11 @@ mybrowser.msie = true; { return ""; }; - return result; } else { - // cake 3 -mybrowser.msie = false; return domline.createDomLine(nonEmpty, doesWrap, mybrowser, doc); -mybrowser.msie = true; } } @@ -3632,7 +3632,6 @@ mybrowser.msie = true; evt.preventDefault(); return; } - // Is caret potentially hidden by the chat button? var myselection = document.getSelection(); // get the current caret selection var caretOffsetTop = myselection.focusNode.parentNode.offsetTop | myselection.focusNode.offsetTop; // get the carets selection offset in px IE 214 @@ -3669,8 +3668,7 @@ mybrowser.msie = true; var specialHandled = false; var isTypeForSpecialKey = ((mybrowser.msie || mybrowser.safari || mybrowser.chrome) ? (type == "keydown") : (type == "keypress")); - var isTypeForCmdKey = ((mybrowser.msie || mybrowser.safari || mybrowser.chrome) ? (type == "keydown") : (type == "keypress")); - + var isTypeForCmdKey = (type === "keydown") var stopped = false; inCallStackIfNecessary("handleKeyEvent", function() @@ -3920,10 +3918,10 @@ mybrowser.msie = true; // only move the viewport if we're at the bottom of the viewport, if we hit down any other time the viewport shouldn't change // NOTE: This behavior only fires if Chrome decides to break the page layout after a paste, it's annoying but nothing I can do var selection = getSelection(); - top.console.log("line #", rep.selStart[0]); // the line our caret is on - top.console.log("firstvisible", visibleLineRange[0]); // the first visiblel ine - top.console.log("lastVisible", visibleLineRange[1]); // the last visible line - top.console.log(rep.selStart[0], visibleLineRange[1], rep.selStart[0], visibleLineRange[0]); + // top.console.log("line #", rep.selStart[0]); // the line our caret is on + // top.console.log("firstvisible", visibleLineRange[0]); // the first visiblel ine + // top.console.log("lastVisible", visibleLineRange[1]); // the last visible line + // top.console.log(rep.selStart[0], visibleLineRange[1], rep.selStart[0], visibleLineRange[0]); var newY = viewport.top + lineHeight; } if(newY){ diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js index 8bc5020b1..e5c0ec8b2 100644 --- a/src/static/js/collab_client.js +++ b/src/static/js/collab_client.js @@ -81,7 +81,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) onServerMessage: function() {} }; - if (browser.firefox) { // Prevent "escape" from taking effect and canceling a comet connection; diff --git a/src/static/js/contentcollector.js b/src/static/js/contentcollector.js index 7a6deeb11..c39410b7c 100644 --- a/src/static/js/contentcollector.js +++ b/src/static/js/contentcollector.js @@ -35,9 +35,9 @@ function sanitizeUnicode(s) return UNorm.nfc(s); } -function makeContentCollector(collectStyles, browser, apool, domInterface, className2Author) +function makeContentCollector(collectStyles, abrowser, apool, domInterface, className2Author) { - // browser = browser || {}; + abrowser = abrowser || {}; // I don't like the above. var dom = domInterface || { @@ -485,7 +485,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class var cls = dom.nodeProp(node, "className"); var isPre = (tname == "pre"); - if ((!isPre) && browser.safari) + if ((!isPre) && abrowser.safari) { isPre = (styl && /\bwhite-space:\s*pre\b/i.exec(styl)); } @@ -611,7 +611,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class } } } - if (!browser.msie) + if (!abrowser.msie) { _reachBlockPoint(node, 1, state); } @@ -627,7 +627,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class } } - if (browser.msie) + if (abrowser.msie) { // in IE, a point immediately after a DIV appears on the next line _reachBlockPoint(node, 1, state); diff --git a/src/static/js/domline.js b/src/static/js/domline.js index e793956b5..03f1b9c89 100644 --- a/src/static/js/domline.js +++ b/src/static/js/domline.js @@ -65,7 +65,6 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument) lineMarker: 0 }; - // var browser = (optBrowser || {}); var document = optDocument; if (document) @@ -93,8 +92,10 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument) var perTextNodeProcess = (doesWrap ? _.identity : processSpaces); var perHtmlLineProcess = (doesWrap ? processSpaces : _.identity); var lineClass = 'ace-line'; + result.appendSpan = function(txt, cls) { + var processedMarker = false; // Handle lineAttributeMarker, if present if (cls.indexOf(lineAttributeMarker) >= 0) diff --git a/src/static/js/linestylefilter.js b/src/static/js/linestylefilter.js index 675f19d02..17ab993b1 100644 --- a/src/static/js/linestylefilter.js +++ b/src/static/js/linestylefilter.js @@ -318,20 +318,20 @@ linestylefilter.textAndClassFuncSplitter = function(func, splitPointsOpt) return spanHandler; }; -linestylefilter.getFilterStack = function(lineText, textAndClassFunc, browser) +linestylefilter.getFilterStack = function(lineText, textAndClassFunc, abrowser) { var func = linestylefilter.getURLFilter(lineText, textAndClassFunc); var hookFilters = hooks.callAll("aceGetFilterStack", { linestylefilter: linestylefilter, - browser: browser + browser: abrowser }); _.map(hookFilters ,function(hookFilter) { func = hookFilter(lineText, func); }); - if (browser !== undefined && browser.msie) + if (abrowser !== undefined && abrowser.msie) { // IE7+ will take an e-mail address like and linkify it to foo@bar.com. // We then normalize it back to text with no angle brackets. It's weird. So always From ce40cacafaf220e4c075daa79240dd0263aeaa5d Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 21 Jan 2015 14:49:06 +0000 Subject: [PATCH 4/8] mheh looks fixed --- src/static/js/ace2_inner.js | 78 ++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index aa65ff958..dd2f2b124 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -19,15 +19,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -var _, $, jQuery, plugins, Ace2Common, mybrowser; -mybrowser = require('./browser').browser; +var _, $, jQuery, plugins, Ace2Common, bowser; +bowser = require('./browser').browser; -if(mybrowser.msie){ +if(bowser.msie){ // Honestly fuck IE royally. // Basically every hack we have since V11 causes a problem - if(parseInt(mybrowser.version) >= 11){ - delete mybrowser.msie; - mybrowser.firefox = true; + if(parseInt(bowser.version) >= 11){ + delete bowser.msie; + bowser.chrome = true; } } Ace2Common = require('./ace2_common'); @@ -607,7 +607,7 @@ function Ace2Inner(){ // Chrome can't handle the truth.. If CSS rule white-space:pre-wrap // is true then any paste event will insert two lines.. - if(mybrowser.chrome){ + if(bowser.chrome){ $("#innerdocbody").css({"white-space":"normal"}); } @@ -953,7 +953,7 @@ function Ace2Inner(){ showslinenumbers : function(value){ hasLineNumbers = !! value; // disable line numbers on mobile devices - // if (mybrowser.mobile) hasLineNumbers = false; + // if (bowser.mobile) hasLineNumbers = false; setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers); fixView(); }, @@ -1320,7 +1320,7 @@ function Ace2Inner(){ else { var offsetIntoLine = 0; - var filteredFunc = linestylefilter.getFilterStack(text, textAndClassFunc, mybrowser); + var filteredFunc = linestylefilter.getFilterStack(text, textAndClassFunc, bowser); var lineNum = rep.lines.indexOfEntry(lineEntry); var aline = rep.alines[lineNum]; filteredFunc = linestylefilter.getLineStyleFilter( @@ -1568,13 +1568,13 @@ function Ace2Inner(){ lastDirtyNode = (lastDirtyNode && isNodeDirty(lastDirtyNode) && lastDirtyNode); if (firstDirtyNode && lastDirtyNode) { - var cc = makeContentCollector(isStyled, mybrowser, rep.apool, null, className2Author); + var cc = makeContentCollector(isStyled, bowser, rep.apool, null, className2Author); cc.notifySelection(selection); var dirtyNodes = []; for (var n = firstDirtyNode; n && !(n.previousSibling && n.previousSibling == lastDirtyNode); n = n.nextSibling) { - if (mybrowser.msie) + if (bowser.msie) { // try to undo IE's pesky and overzealous linkification try @@ -1614,7 +1614,7 @@ function Ace2Inner(){ if (linesWrapped > 0) { - if(!mybrowser.msie){ + if(!bowser.msie){ // chrome decides in it's infinite wisdom that its okay to put the browsers visisble window in the middle of the span // an outcome of this is that the first chars of the string are no longer visible to the user.. Yay chrome.. // Move the browsers visible area to the left hand side of the span @@ -1919,7 +1919,7 @@ function Ace2Inner(){ if (charsLeft === 0) { var index = 0; - if (mybrowser.msie && line == (rep.lines.length() - 1) && lineNode.childNodes.length === 0) + if (bowser.msie && line == (rep.lines.length() - 1) && lineNode.childNodes.length === 0) { // best to stay at end of last empty div in IE index = 1; @@ -2912,7 +2912,7 @@ function Ace2Inner(){ function doCreateDomLine(nonEmpty) { - if (mybrowser.msie && (!nonEmpty)) + if (bowser.msie && (!nonEmpty)) { var result = { node: null, @@ -2972,7 +2972,7 @@ function Ace2Inner(){ } else { - return domline.createDomLine(nonEmpty, doesWrap, mybrowser, doc); + return domline.createDomLine(nonEmpty, doesWrap, bowser, doc); } } @@ -3239,7 +3239,7 @@ function Ace2Inner(){ var dirtiness = {}; dirtiness.nodeId = uniqueId(n); dirtiness.knownHTML = n.innerHTML; - if (mybrowser.msie) + if (bowser.msie) { // adding a space to an "empty" div in IE designMode doesn't // change the innerHTML of the div's parent; also, other @@ -3256,7 +3256,7 @@ function Ace2Inner(){ var data = getAssoc(n, "dirtiness"); if (!data) return true; if (n.id !== data.nodeId) return true; - if (mybrowser.msie) + if (bowser.msie) { if (n.innerText !== data.knownText) return true; } @@ -3591,7 +3591,7 @@ function Ace2Inner(){ // On Mac and Linux, move right moves to end of word and move left moves to start; // on Windows, always move to start of word. // On Windows, Firefox and IE disagree on whether to stop for punctuation (FF says no). - if (mybrowser.msie && forwardNotBack) + if (bowser.msie && forwardNotBack) { while ((!isDone()) && isWordChar(nextChar())) { @@ -3662,13 +3662,13 @@ function Ace2Inner(){ if (isModKey) return; // If the key is a keypress and the browser is opera and the key is enter, do nothign at all as this fires twice. - if (keyCode == 13 && mybrowser.opera && (type == "keypress")){ + if (keyCode == 13 && bowser.opera && (type == "keypress")){ return; // This stops double enters in Opera but double Tabs still show on single tab keypress, adding keyCode == 9 to this doesn't help as the event is fired twice } var specialHandled = false; - var isTypeForSpecialKey = ((mybrowser.msie || mybrowser.safari || mybrowser.chrome) ? (type == "keydown") : (type == "keypress")); - var isTypeForCmdKey = (type === "keydown") + var isTypeForSpecialKey = ((bowser.msie || bowser.safari || bowser.chrome) ? (type == "keydown") : (type == "keypress")); + var isTypeForCmdKey = ((bowser.msie || bowser.safari || bowser.chrome) ? (type == "keydown") : (type == "keypress")); var stopped = false; inCallStackIfNecessary("handleKeyEvent", function() @@ -3884,7 +3884,7 @@ function Ace2Inner(){ /* Attempt to apply some sanity to cursor handling in Chrome after a copy / paste event We have to do this the way we do because rep. doesn't hold the value for keyheld events IE if the user presses and holds the arrow key .. Sorry if this is ugly, blame Chrome's weird handling of viewports after new content is added*/ - if((evt.which == 37 || evt.which == 38 || evt.which == 39 || evt.which == 40) && mybrowser.chrome){ + if((evt.which == 37 || evt.which == 38 || evt.which == 39 || evt.which == 40) && bowser.chrome){ var viewport = getViewPortTopBottom(); var myselection = document.getSelection(); // get the current caret selection, can't use rep. here because that only gives us the start position not the current var caretOffsetTop = myselection.focusNode.parentNode.offsetTop || myselection.focusNode.offsetTop; // get the carets selection offset in px IE 214 @@ -3955,10 +3955,10 @@ function Ace2Inner(){ } // Is part of multi-keystroke international character on Firefox Mac - var isFirefoxHalfCharacter = (mybrowser.firefox && evt.altKey && charCode === 0 && keyCode === 0); + var isFirefoxHalfCharacter = (bowser.firefox && evt.altKey && charCode === 0 && keyCode === 0); // Is part of multi-keystroke international character on Safari Mac - var isSafariHalfCharacter = (mybrowser.safari && evt.altKey && keyCode == 229); + var isSafariHalfCharacter = (bowser.safari && evt.altKey && keyCode == 229); if (thisKeyDoesntTriggerNormalize || isFirefoxHalfCharacter || isSafariHalfCharacter) { @@ -4072,7 +4072,7 @@ function Ace2Inner(){ // each of which has node (a magicdom node), index, and maxIndex. If the node // is a text node, maxIndex is the length of the text; else maxIndex is 1. // index is between 0 and maxIndex, inclusive. - if (mybrowser.msie) + if (bowser.msie) { var browserSelection; try @@ -4368,7 +4368,7 @@ function Ace2Inner(){ maxIndex: pt.maxIndex }; } - if (mybrowser.msie) + if (bowser.msie) { // Oddly enough, accessing scrollHeight fixes return key handling on IE 8, // presumably by forcing some kind of internal DOM update. @@ -4663,11 +4663,11 @@ function Ace2Inner(){ if (newHeight < viewHeight) { newHeight = viewHeight; -// if (mybrowser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'auto'); +// if (bowser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'auto'); } else { -// if (mybrowser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'scroll'); +// if (bowser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'scroll'); } if (doesWrap) { @@ -4681,7 +4681,7 @@ function Ace2Inner(){ setIfNecessary(iframe.style, "width", newWidth + "px"); setIfNecessary(sideDiv.style, "height", newHeight + "px"); } - if (mybrowser.firefox) + if (bowser.firefox) { if (!doesWrap) { @@ -4780,14 +4780,14 @@ function Ace2Inner(){ } return false; } - if (mybrowser.msie || mybrowser.safari) + if (bowser.msie || bowser.safari) { setIfNecessary(root, 'contentEditable', (newVal ? 'true' : 'false')); } else { var wasSet = setIfNecessary(doc, 'designMode', (newVal ? 'on' : 'off')); - if (wasSet && newVal && mybrowser.opera) + if (wasSet && newVal && bowser.opera) { // turning on designMode clears event handlers bindTheEventHandlers(); @@ -4853,11 +4853,11 @@ function Ace2Inner(){ $(document).on("keyup", handleKeyEvent); $(document).on("click", handleClick); $(root).on("blur", handleBlur); - if (mybrowser.msie) + if (bowser.msie) { $(document).on("click", handleIEOuterClick); } - if (mybrowser.msie) $(root).on("paste", handleIEPaste); + if (bowser.msie) $(root).on("paste", handleIEPaste); // Don't paste on middle click of links $(root).on("paste", function(e){ @@ -4867,7 +4867,7 @@ function Ace2Inner(){ }) // CompositionEvent is not implemented below IE version 8 - if ( !(mybrowser.msie && mybrowser.version <= 9) && document.documentElement) + if ( !(bowser.msie && bowser.version <= 9) && document.documentElement) { $(document.documentElement).on("compositionstart", handleCompositionEvent); $(document.documentElement).on("compositionend", handleCompositionEvent); @@ -4930,7 +4930,7 @@ function Ace2Inner(){ function handleBlur(evt) { - if (mybrowser.msie) + if (bowser.msie) { // a fix: in IE, clicking on a control like a button outside the // iframe can "blur" the editor, causing it to stop getting @@ -5001,7 +5001,7 @@ function Ace2Inner(){ var win = outerWin; var odoc = win.document; var h; - if (mybrowser.opera) h = win.innerHeight; + if (bowser.opera) h = win.innerHeight; else h = odoc.documentElement.clientHeight; if (h) return h; @@ -5330,9 +5330,9 @@ function Ace2Inner(){ { var body = doc.getElementById("innerdocbody"); root = body; // defined as a var in scope outside - if (mybrowser.firefox) $(root).addClass("mozilla"); - if (mybrowser.safari) $(root).addClass("safari"); - if (mybrowser.msie) $(root).addClass("msie"); + if (bowser.firefox) $(root).addClass("mozilla"); + if (bowser.safari) $(root).addClass("safari"); + if (bowser.msie) $(root).addClass("msie"); setClassPresence(root, "authorColors", true); setClassPresence(root, "doesWrap", doesWrap); From f2891e3b8b3c1b0d34c729ba5c14dc4f291d5b7a Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 21 Jan 2015 14:55:29 +0000 Subject: [PATCH 5/8] working --- src/static/js/ace2_inner.js | 14 +++++++------- src/static/js/pad.js | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index dd2f2b124..937398051 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -19,9 +19,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -var _, $, jQuery, plugins, Ace2Common, bowser; -bowser = require('./browser').browser; +var _, $, jQuery, plugins, Ace2Common; +var bowser = require('./browser').browser; if(bowser.msie){ // Honestly fuck IE royally. // Basically every hack we have since V11 causes a problem @@ -30,6 +30,7 @@ if(bowser.msie){ bowser.chrome = true; } } + Ace2Common = require('./ace2_common'); plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins'); @@ -43,7 +44,6 @@ var isNodeText = Ace2Common.isNodeText, binarySearchInfinite = Ace2Common.binarySearchInfinite, htmlPrettyEscape = Ace2Common.htmlPrettyEscape, noop = Ace2Common.noop; - var hooks = require('./pluginfw/hooks'); function Ace2Inner(){ @@ -953,7 +953,7 @@ function Ace2Inner(){ showslinenumbers : function(value){ hasLineNumbers = !! value; // disable line numbers on mobile devices - // if (bowser.mobile) hasLineNumbers = false; + if (bowser.mobile) hasLineNumbers = false; setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers); fixView(); }, @@ -4657,17 +4657,17 @@ function Ace2Inner(){ for (var i = 0; i < 2; i++) { var newHeight = root.clientHeight; - var newWidth = root.clientWidth; + var newWidth = (browser.msie ? root.createTextRange().boundingWidth : root.clientWidth); var viewHeight = getInnerHeight() - iframePadBottom - iframePadTop; var viewWidth = getInnerWidth() - iframePadLeft - iframePadRight; if (newHeight < viewHeight) { newHeight = viewHeight; -// if (bowser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'auto'); + if (bowser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'auto'); } else { -// if (bowser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'scroll'); + if (bowser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'scroll'); } if (doesWrap) { diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 685b420b1..5bbf41236 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -494,7 +494,6 @@ var pad = { pad.initTime = +(new Date()); pad.padOptions = clientVars.initialOptions; -console.log("pad", browser); if ((!browser.msie) && (!(browser.firefox && browser.version.indexOf("1.8.") == 0))) { document.domain = document.domain; // for comet From a2cb8a2f1933dff672d5cbe6b7671d83b4f2e948 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 21 Jan 2015 15:01:39 +0000 Subject: [PATCH 6/8] rename back to browser --- src/static/js/ace2_inner.js | 76 ++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 937398051..e68a1b669 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -21,13 +21,13 @@ */ var _, $, jQuery, plugins, Ace2Common; -var bowser = require('./browser').browser; -if(bowser.msie){ +var browser = require('./browser').browser; +if(browser.msie){ // Honestly fuck IE royally. // Basically every hack we have since V11 causes a problem - if(parseInt(bowser.version) >= 11){ - delete bowser.msie; - bowser.chrome = true; + if(parseInt(browser.version) >= 11){ + delete browser.msie; + browser.chrome = true; } } @@ -607,7 +607,7 @@ function Ace2Inner(){ // Chrome can't handle the truth.. If CSS rule white-space:pre-wrap // is true then any paste event will insert two lines.. - if(bowser.chrome){ + if(browser.chrome){ $("#innerdocbody").css({"white-space":"normal"}); } @@ -953,7 +953,7 @@ function Ace2Inner(){ showslinenumbers : function(value){ hasLineNumbers = !! value; // disable line numbers on mobile devices - if (bowser.mobile) hasLineNumbers = false; + if (browser.mobile) hasLineNumbers = false; setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers); fixView(); }, @@ -1320,7 +1320,7 @@ function Ace2Inner(){ else { var offsetIntoLine = 0; - var filteredFunc = linestylefilter.getFilterStack(text, textAndClassFunc, bowser); + var filteredFunc = linestylefilter.getFilterStack(text, textAndClassFunc, browser); var lineNum = rep.lines.indexOfEntry(lineEntry); var aline = rep.alines[lineNum]; filteredFunc = linestylefilter.getLineStyleFilter( @@ -1568,13 +1568,13 @@ function Ace2Inner(){ lastDirtyNode = (lastDirtyNode && isNodeDirty(lastDirtyNode) && lastDirtyNode); if (firstDirtyNode && lastDirtyNode) { - var cc = makeContentCollector(isStyled, bowser, rep.apool, null, className2Author); + var cc = makeContentCollector(isStyled, browser, rep.apool, null, className2Author); cc.notifySelection(selection); var dirtyNodes = []; for (var n = firstDirtyNode; n && !(n.previousSibling && n.previousSibling == lastDirtyNode); n = n.nextSibling) { - if (bowser.msie) + if (browser.msie) { // try to undo IE's pesky and overzealous linkification try @@ -1614,7 +1614,7 @@ function Ace2Inner(){ if (linesWrapped > 0) { - if(!bowser.msie){ + if(!browser.msie){ // chrome decides in it's infinite wisdom that its okay to put the browsers visisble window in the middle of the span // an outcome of this is that the first chars of the string are no longer visible to the user.. Yay chrome.. // Move the browsers visible area to the left hand side of the span @@ -1919,7 +1919,7 @@ function Ace2Inner(){ if (charsLeft === 0) { var index = 0; - if (bowser.msie && line == (rep.lines.length() - 1) && lineNode.childNodes.length === 0) + if (browser.msie && line == (rep.lines.length() - 1) && lineNode.childNodes.length === 0) { // best to stay at end of last empty div in IE index = 1; @@ -2912,7 +2912,7 @@ function Ace2Inner(){ function doCreateDomLine(nonEmpty) { - if (bowser.msie && (!nonEmpty)) + if (browser.msie && (!nonEmpty)) { var result = { node: null, @@ -2972,7 +2972,7 @@ function Ace2Inner(){ } else { - return domline.createDomLine(nonEmpty, doesWrap, bowser, doc); + return domline.createDomLine(nonEmpty, doesWrap, browser, doc); } } @@ -3239,7 +3239,7 @@ function Ace2Inner(){ var dirtiness = {}; dirtiness.nodeId = uniqueId(n); dirtiness.knownHTML = n.innerHTML; - if (bowser.msie) + if (browser.msie) { // adding a space to an "empty" div in IE designMode doesn't // change the innerHTML of the div's parent; also, other @@ -3256,7 +3256,7 @@ function Ace2Inner(){ var data = getAssoc(n, "dirtiness"); if (!data) return true; if (n.id !== data.nodeId) return true; - if (bowser.msie) + if (browser.msie) { if (n.innerText !== data.knownText) return true; } @@ -3591,7 +3591,7 @@ function Ace2Inner(){ // On Mac and Linux, move right moves to end of word and move left moves to start; // on Windows, always move to start of word. // On Windows, Firefox and IE disagree on whether to stop for punctuation (FF says no). - if (bowser.msie && forwardNotBack) + if (browser.msie && forwardNotBack) { while ((!isDone()) && isWordChar(nextChar())) { @@ -3662,13 +3662,13 @@ function Ace2Inner(){ if (isModKey) return; // If the key is a keypress and the browser is opera and the key is enter, do nothign at all as this fires twice. - if (keyCode == 13 && bowser.opera && (type == "keypress")){ + if (keyCode == 13 && browser.opera && (type == "keypress")){ return; // This stops double enters in Opera but double Tabs still show on single tab keypress, adding keyCode == 9 to this doesn't help as the event is fired twice } var specialHandled = false; - var isTypeForSpecialKey = ((bowser.msie || bowser.safari || bowser.chrome) ? (type == "keydown") : (type == "keypress")); - var isTypeForCmdKey = ((bowser.msie || bowser.safari || bowser.chrome) ? (type == "keydown") : (type == "keypress")); + var isTypeForSpecialKey = ((browser.msie || browser.safari || browser.chrome) ? (type == "keydown") : (type == "keypress")); + var isTypeForCmdKey = ((browser.msie || browser.safari || browser.chrome) ? (type == "keydown") : (type == "keypress")); var stopped = false; inCallStackIfNecessary("handleKeyEvent", function() @@ -3884,7 +3884,7 @@ function Ace2Inner(){ /* Attempt to apply some sanity to cursor handling in Chrome after a copy / paste event We have to do this the way we do because rep. doesn't hold the value for keyheld events IE if the user presses and holds the arrow key .. Sorry if this is ugly, blame Chrome's weird handling of viewports after new content is added*/ - if((evt.which == 37 || evt.which == 38 || evt.which == 39 || evt.which == 40) && bowser.chrome){ + if((evt.which == 37 || evt.which == 38 || evt.which == 39 || evt.which == 40) && browser.chrome){ var viewport = getViewPortTopBottom(); var myselection = document.getSelection(); // get the current caret selection, can't use rep. here because that only gives us the start position not the current var caretOffsetTop = myselection.focusNode.parentNode.offsetTop || myselection.focusNode.offsetTop; // get the carets selection offset in px IE 214 @@ -3955,10 +3955,10 @@ function Ace2Inner(){ } // Is part of multi-keystroke international character on Firefox Mac - var isFirefoxHalfCharacter = (bowser.firefox && evt.altKey && charCode === 0 && keyCode === 0); + var isFirefoxHalfCharacter = (browser.firefox && evt.altKey && charCode === 0 && keyCode === 0); // Is part of multi-keystroke international character on Safari Mac - var isSafariHalfCharacter = (bowser.safari && evt.altKey && keyCode == 229); + var isSafariHalfCharacter = (browser.safari && evt.altKey && keyCode == 229); if (thisKeyDoesntTriggerNormalize || isFirefoxHalfCharacter || isSafariHalfCharacter) { @@ -4072,7 +4072,7 @@ function Ace2Inner(){ // each of which has node (a magicdom node), index, and maxIndex. If the node // is a text node, maxIndex is the length of the text; else maxIndex is 1. // index is between 0 and maxIndex, inclusive. - if (bowser.msie) + if (browser.msie) { var browserSelection; try @@ -4368,7 +4368,7 @@ function Ace2Inner(){ maxIndex: pt.maxIndex }; } - if (bowser.msie) + if (browser.msie) { // Oddly enough, accessing scrollHeight fixes return key handling on IE 8, // presumably by forcing some kind of internal DOM update. @@ -4663,11 +4663,11 @@ function Ace2Inner(){ if (newHeight < viewHeight) { newHeight = viewHeight; - if (bowser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'auto'); + if (browser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'auto'); } else { - if (bowser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'scroll'); + if (browser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'scroll'); } if (doesWrap) { @@ -4681,7 +4681,7 @@ function Ace2Inner(){ setIfNecessary(iframe.style, "width", newWidth + "px"); setIfNecessary(sideDiv.style, "height", newHeight + "px"); } - if (bowser.firefox) + if (browser.firefox) { if (!doesWrap) { @@ -4780,14 +4780,14 @@ function Ace2Inner(){ } return false; } - if (bowser.msie || bowser.safari) + if (browser.msie || browser.safari) { setIfNecessary(root, 'contentEditable', (newVal ? 'true' : 'false')); } else { var wasSet = setIfNecessary(doc, 'designMode', (newVal ? 'on' : 'off')); - if (wasSet && newVal && bowser.opera) + if (wasSet && newVal && browser.opera) { // turning on designMode clears event handlers bindTheEventHandlers(); @@ -4853,11 +4853,11 @@ function Ace2Inner(){ $(document).on("keyup", handleKeyEvent); $(document).on("click", handleClick); $(root).on("blur", handleBlur); - if (bowser.msie) + if (browser.msie) { $(document).on("click", handleIEOuterClick); } - if (bowser.msie) $(root).on("paste", handleIEPaste); + if (browser.msie) $(root).on("paste", handleIEPaste); // Don't paste on middle click of links $(root).on("paste", function(e){ @@ -4867,7 +4867,7 @@ function Ace2Inner(){ }) // CompositionEvent is not implemented below IE version 8 - if ( !(bowser.msie && bowser.version <= 9) && document.documentElement) + if ( !(browser.msie && browser.version <= 9) && document.documentElement) { $(document.documentElement).on("compositionstart", handleCompositionEvent); $(document.documentElement).on("compositionend", handleCompositionEvent); @@ -4930,7 +4930,7 @@ function Ace2Inner(){ function handleBlur(evt) { - if (bowser.msie) + if (browser.msie) { // a fix: in IE, clicking on a control like a button outside the // iframe can "blur" the editor, causing it to stop getting @@ -5001,7 +5001,7 @@ function Ace2Inner(){ var win = outerWin; var odoc = win.document; var h; - if (bowser.opera) h = win.innerHeight; + if (browser.opera) h = win.innerHeight; else h = odoc.documentElement.clientHeight; if (h) return h; @@ -5330,9 +5330,9 @@ function Ace2Inner(){ { var body = doc.getElementById("innerdocbody"); root = body; // defined as a var in scope outside - if (bowser.firefox) $(root).addClass("mozilla"); - if (bowser.safari) $(root).addClass("safari"); - if (bowser.msie) $(root).addClass("msie"); + if (browser.firefox) $(root).addClass("mozilla"); + if (browser.safari) $(root).addClass("safari"); + if (browser.msie) $(root).addClass("msie"); setClassPresence(root, "authorColors", true); setClassPresence(root, "doesWrap", doesWrap); From 26a158447074dc3048c26882379cbc09c7c8d4a5 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 21 Jan 2015 15:21:15 +0000 Subject: [PATCH 7/8] fix tests w/ new context --- tests/frontend/specs/bold.js | 2 +- tests/frontend/specs/caret.js | 2 +- tests/frontend/specs/indentation.js | 2 +- tests/frontend/specs/italic.js | 2 +- tests/frontend/specs/redo.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/frontend/specs/bold.js b/tests/frontend/specs/bold.js index bffb281b5..b54466e4e 100644 --- a/tests/frontend/specs/bold.js +++ b/tests/frontend/specs/bold.js @@ -44,7 +44,7 @@ describe("bold button", function(){ //select this text element $firstTextElement.sendkeys('{selectall}'); - if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.msie){ // if it's a mozilla or IE + if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/caret.js b/tests/frontend/specs/caret.js index 6e68b6f52..14ff8d6a6 100644 --- a/tests/frontend/specs/caret.js +++ b/tests/frontend/specs/caret.js @@ -297,7 +297,7 @@ function prepareDocument(n, target){ // generates a random document with random } function keyEvent(target, charCode, ctrl, shift){ // sends a charCode to the window - if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.msie){ // if it's a mozilla or IE + if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/indentation.js b/tests/frontend/specs/indentation.js index c8f2cee81..8e851d873 100644 --- a/tests/frontend/specs/indentation.js +++ b/tests/frontend/specs/indentation.js @@ -15,7 +15,7 @@ describe("indentation button", function(){ //select this text element $firstTextElement.sendkeys('{selectall}'); - if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.msie){ // if it's a mozilla or IE + if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/italic.js b/tests/frontend/specs/italic.js index 4ef4b4085..bf7f2bc60 100644 --- a/tests/frontend/specs/italic.js +++ b/tests/frontend/specs/italic.js @@ -44,7 +44,7 @@ describe("italic some text", function(){ //select this text element $firstTextElement.sendkeys('{selectall}'); - if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.msie){ // if it's a mozilla or IE + if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE var evtType = "keypress"; }else{ var evtType = "keydown"; diff --git a/tests/frontend/specs/redo.js b/tests/frontend/specs/redo.js index 00873d14a..caa32feec 100644 --- a/tests/frontend/specs/redo.js +++ b/tests/frontend/specs/redo.js @@ -47,7 +47,7 @@ describe("undo button then redo button", function(){ var modifiedValue = $firstTextElement.text(); // get the modified value expect(modifiedValue).not.to.be(originalValue); // expect the value to change - if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.msie){ // if it's a mozilla or IE + if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE var evtType = "keypress"; }else{ var evtType = "keydown"; From 3cd8759cec034534a29b753648263b7d08d6cb75 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 21 Jan 2015 15:21:31 +0000 Subject: [PATCH 8/8] expose modernIE value --- src/static/js/ace2_inner.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 0e122e6a3..4b84e784d 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -28,6 +28,7 @@ if(browser.msie){ if(parseInt(browser.version) >= 11){ delete browser.msie; browser.chrome = true; + browser.modernIE = true; } }