From 990e14c9042cacd03ff16259b9140a28269678c9 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 21 Jan 2015 14:25:24 +0000 Subject: [PATCH] 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