From 99a6e2ab8f80d77ea4cf54fd0d1eccd372214348 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sun, 12 Apr 2015 16:37:38 +0100 Subject: [PATCH 1/8] remove editor iframes, first step --- src/static/css/iframe_editor.css | 6 +- src/static/css/pad.css | 10 --- src/static/js/ace.js | 125 +------------------------------ src/static/js/ace2_inner.js | 67 ++++++++--------- src/templates/pad.html | 10 ++- 5 files changed, 47 insertions(+), 171 deletions(-) diff --git a/src/static/css/iframe_editor.css b/src/static/css/iframe_editor.css index b7ece1e66..5b980e74e 100644 --- a/src/static/css/iframe_editor.css +++ b/src/static/css/iframe_editor.css @@ -119,10 +119,8 @@ body.doesWrap > div{ } #innerdocbody { - padding-top: 1px; /* important for some reason? */ - padding-right: 10px; - padding-bottom: 8px; - padding-left: 1px /* prevents characters from looking chopped off in FF3 -- Removed because it added too much whitespace */; + position: absolute; + top: 8px; overflow: hidden; /* blank 1x1 gif, so that IE8 doesn't consider the body transparent */ background-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==); diff --git a/src/static/css/pad.css b/src/static/css/pad.css index ff8ab5ab7..de314e172 100644 --- a/src/static/css/pad.css +++ b/src/static/css/pad.css @@ -16,9 +16,6 @@ body, textarea { font-family: Helvetica, Arial, sans-serif } -iframe { - position: absolute -} .readonly .acl-write { display: none; } @@ -217,13 +214,6 @@ li[data-key=showusers] > a #online_count { bottom: 0px; z-index: 1; } -#editorcontainer iframe { - height: 100%; - width: 100%; - padding: 0; - margin: 0; - left: 0; /* Required for safari fixes RTL */ -} #editorloadingbox { padding-top: 100px; padding-bottom: 100px; diff --git a/src/static/js/ace.js b/src/static/js/ace.js index c446939a3..efae37f0d 100644 --- a/src/static/js/ace.js +++ b/src/static/js/ace.js @@ -200,7 +200,6 @@ function Ace2Editor() editor.init = function(containerId, initialCode, doneFunc) { - editor.importText(initialCode); info.onEditorReady = function() @@ -210,126 +209,10 @@ function Ace2Editor() doneFunc(); }; - (function() - { - var doctype = ""; - - var iframeHTML = []; - - iframeHTML.push(doctype); - iframeHTML.push(""); - - // calls to these functions ($$INCLUDE_...) are replaced when this file is processed - // and compressed, putting the compressed code from the named file directly into the - // source here. - // these lines must conform to a specific format because they are passed by the build script: - var includedCSS = []; - var $$INCLUDE_CSS = function(filename) {includedCSS.push(filename)}; - $$INCLUDE_CSS("../static/css/iframe_editor.css"); - $$INCLUDE_CSS("../static/css/pad.css"); - $$INCLUDE_CSS("../static/custom/pad.css"); - - var additionalCSS = _(hooks.callAll("aceEditorCSS")).map(function(path){ return '../static/plugins/' + path }); - includedCSS = includedCSS.concat(additionalCSS); - - pushStyleTagsFor(iframeHTML, includedCSS); - - if (!Ace2Editor.EMBEDED && Ace2Editor.EMBEDED[KERNEL_SOURCE]) { - // Remotely src'd script tag will not work in IE; it must be embedded, so - // throw an error if it is not. - throw new Error("Require kernel could not be found."); - } - - iframeHTML.push(scriptTag( -Ace2Editor.EMBEDED[KERNEL_SOURCE] + '\n\ -require.setRootURI("../javascripts/src");\n\ -require.setLibraryURI("../javascripts/lib");\n\ -require.setGlobalKeyPath("require");\n\ -\n\ -var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");\n\ -var plugins = require("ep_etherpad-lite/static/js/pluginfw/client_plugins");\n\ -hooks.plugins = plugins;\n\ -plugins.adoptPluginsFromAncestorsOf(window);\n\ -\n\ -$ = jQuery = require("ep_etherpad-lite/static/js/rjquery").jQuery; // Expose jQuery #HACK\n\ -var Ace2Inner = require("ep_etherpad-lite/static/js/ace2_inner");\n\ -\n\ -plugins.ensure(function () {\n\ - Ace2Inner.init();\n\ -});\n\ -')); - - iframeHTML.push(''); - - hooks.callAll("aceInitInnerdocbodyHead", { - iframeHTML: iframeHTML - }); - - iframeHTML.push(' '); - - // Expose myself to global for my child frame. - var thisFunctionsName = "ChildAccessibleAce2Editor"; - (function () {return this}())[thisFunctionsName] = Ace2Editor; - - var outerScript = '\ -editorId = ' + JSON.stringify(info.id) + ';\n\ -editorInfo = parent[' + JSON.stringify(thisFunctionsName) + '].registry[editorId];\n\ -window.onload = function () {\n\ - window.onload = null;\n\ - setTimeout(function () {\n\ - var iframe = document.createElement("IFRAME");\n\ - iframe.name = "ace_inner";\n\ - iframe.title = "pad";\n\ - iframe.scrolling = "no";\n\ - var outerdocbody = document.getElementById("outerdocbody");\n\ - iframe.frameBorder = 0;\n\ - iframe.allowTransparency = true; // for IE\n\ - outerdocbody.insertBefore(iframe, outerdocbody.firstChild);\n\ - iframe.ace_outerWin = window;\n\ - readyFunc = function () {\n\ - editorInfo.onEditorReady();\n\ - readyFunc = null;\n\ - editorInfo = null;\n\ - };\n\ - var doc = iframe.contentWindow.document;\n\ - doc.open();\n\ - var text = (' + JSON.stringify(iframeHTML.join('\n')) + ');\n\ - doc.write(text);\n\ - doc.close();\n\ - }, 0);\n\ -}'; - - var outerHTML = [doctype, ''] - - var includedCSS = []; - var $$INCLUDE_CSS = function(filename) {includedCSS.push(filename)}; - $$INCLUDE_CSS("../static/css/iframe_editor.css"); - $$INCLUDE_CSS("../static/css/pad.css"); - $$INCLUDE_CSS("../static/custom/pad.css"); - - - var additionalCSS = _(hooks.callAll("aceEditorCSS")).map(function(path){ return '../static/plugins/' + path }); - includedCSS = includedCSS.concat(additionalCSS); - - pushStyleTagsFor(outerHTML, includedCSS); - - // bizarrely, in FF2, a file with no "external" dependencies won't finish loading properly - // (throbs busy while typing) - outerHTML.push('', '', scriptTag(outerScript), '
x
'); - - var outerFrame = document.createElement("IFRAME"); - outerFrame.name = "ace_outer"; - outerFrame.frameBorder = 0; // for IE - outerFrame.title = "Ether"; - info.frame = outerFrame; - document.getElementById(containerId).appendChild(outerFrame); - - var editorDocument = outerFrame.contentWindow.document; - - editorDocument.open(); - editorDocument.write(outerHTML.join('')); - editorDocument.close(); - })(); + var Ace2Inner = require("ep_etherpad-lite/static/js/ace2_inner"); + var editorId = info.id; + var editorInfo = Ace2Editor.registry[editorId]; + Ace2Inner.init(editorInfo); }; return editor; diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 555512118..2f3dd9888 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -47,7 +47,7 @@ var isNodeText = Ace2Common.isNodeText, noop = Ace2Common.noop; var hooks = require('./pluginfw/hooks'); -function Ace2Inner(){ +function Ace2Inner(editorInfo){ var makeChangesetTracker = require('./changesettracker').makeChangesetTracker; var colorutils = require('./colorutils').colorutils; @@ -80,13 +80,9 @@ function Ace2Inner(){ var thisAuthor = ''; var disposed = false; - var editorInfo = parent.editorInfo; - - var iframe = window.frameElement; - var outerWin = iframe.ace_outerWin; - iframe.ace_outerWin = null; // prevent IE 6 memory leak - var sideDiv = iframe.nextSibling; - var lineMetricsDiv = sideDiv.nextSibling; + var sideDiv = $('#sidediv')[0]; + var lineMetricsDiv = $('#linemetricsdiv')[0]; + var innerdocbody = $('#innerdocbody')[0]; initLineNumbers(); var outsideKeyDown = noop; @@ -961,7 +957,7 @@ function Ace2Inner(){ setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers); fixView(); }, - grayedout: setClassPresenceNamed(outerWin.document.body, "grayedout"), + grayedout: setClassPresenceNamed(window.document.body, "grayedout"), dmesg: function(){ dmesg = window.dmesg = value; }, userauthor: function(value){ thisAuthor = String(value); @@ -3263,7 +3259,7 @@ function Ace2Inner(){ function getViewPortTopBottom() { var theTop = getScrollY(); - var doc = outerWin.document; + var doc = window.document; var height = doc.documentElement.clientHeight; return { top: theTop, @@ -3809,7 +3805,7 @@ function Ace2Inner(){ //scrollSelectionIntoView(); scheduler.setTimeout(function() { - outerWin.scrollBy(-100, 0); + window.scrollBy(-100, 0); }, 0); specialHandled = true; } @@ -4721,6 +4717,7 @@ function Ace2Inner(){ function fixView() { + //return; // TODO: look into this later // calling this method repeatedly should be fast if (getInnerWidth() === 0 || getInnerHeight() === 0) { @@ -4740,7 +4737,7 @@ function Ace2Inner(){ if (newSideDivWidth < MIN_LINEDIV_WIDTH) newSideDivWidth = MIN_LINEDIV_WIDTH; iframePadLeft = EDIT_BODY_PADDING_LEFT; if (hasLineNumbers) iframePadLeft += newSideDivWidth + LINE_NUMBER_PADDING_RIGHT; - setIfNecessary(iframe.style, "left", iframePadLeft + "px"); + setIfNecessary(innerdocbody.style, "left", iframePadLeft + "px"); setIfNecessary(sideDiv.style, "width", newSideDivWidth + "px"); for (var i = 0; i < 2; i++) @@ -4752,11 +4749,11 @@ function Ace2Inner(){ if (newHeight < viewHeight) { newHeight = viewHeight; - if (browser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'auto'); + if (browser.msie) setIfNecessary(window.document.documentElement.style, 'overflowY', 'auto'); } else { - if (browser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'scroll'); + if (browser.msie) setIfNecessary(window.document.documentElement.style, 'overflowY', 'scroll'); } if (doesWrap) { @@ -4766,8 +4763,8 @@ function Ace2Inner(){ { if (newWidth < viewWidth) newWidth = viewWidth; } - setIfNecessary(iframe.style, "height", newHeight + "px"); - setIfNecessary(iframe.style, "width", newWidth + "px"); + setIfNecessary(innerdocbody.style, "height", newHeight + "px"); + setIfNecessary(innerdocbody.style, "width", newWidth + "px"); setIfNecessary(sideDiv.style, "height", newHeight + "px"); } if (browser.firefox) @@ -4792,7 +4789,7 @@ function Ace2Inner(){ // if near edge, scroll to edge var scrollX = getScrollX(); var scrollY = getScrollY(); - var win = outerWin; + var win = window; var r = 20; enforceEditability(); @@ -4802,8 +4799,8 @@ function Ace2Inner(){ function getScrollXY() { - var win = outerWin; - var odoc = outerWin.document; + var win = window; + var odoc = window.document; if (typeof(win.pageYOffset) == "number") { return { @@ -4833,17 +4830,17 @@ function Ace2Inner(){ function setScrollX(x) { - outerWin.scrollTo(x, getScrollY()); + window.scrollTo(x, getScrollY()); } function setScrollY(y) { - outerWin.scrollTo(getScrollX(), y); + window.scrollTo(getScrollX(), y); } function setScrollXY(x, y) { - outerWin.scrollTo(x, y); + window.scrollTo(x, y); } var _teardownActions = []; @@ -5077,7 +5074,7 @@ function Ace2Inner(){ function getPageHeight() { - var win = outerWin; + var win = window; var odoc = win.document; if (win.innerHeight && win.scrollMaxY) return win.innerHeight + win.scrollMaxY; else if (odoc.body.scrollHeight > odoc.body.offsetHeight) return odoc.body.scrollHeight; @@ -5086,7 +5083,7 @@ function Ace2Inner(){ function getPageWidth() { - var win = outerWin; + var win = window; var odoc = win.document; if (win.innerWidth && win.scrollMaxX) return win.innerWidth + win.scrollMaxX; else if (odoc.body.scrollWidth > odoc.body.offsetWidth) return odoc.body.scrollWidth; @@ -5095,7 +5092,7 @@ function Ace2Inner(){ function getInnerHeight() { - var win = outerWin; + var win = window; var odoc = win.document; var h; if (browser.opera) h = win.innerHeight; @@ -5109,7 +5106,7 @@ function Ace2Inner(){ function getInnerWidth() { - var win = outerWin; + var win = window; var odoc = win.document; return odoc.documentElement.clientWidth; } @@ -5119,8 +5116,8 @@ function Ace2Inner(){ // requires element (non-text) node; // if node extends above top of viewport or below bottom of viewport (or top of scrollbar), // scroll it the minimum distance needed to be completely in view. - var win = outerWin; - var odoc = outerWin.document; + var win = window; + var odoc = window.document; var distBelowTop = node.offsetTop + iframePadTop - win.scrollY; var distAboveBottom = win.scrollY + getInnerHeight() - (node.offsetTop + iframePadTop + node.offsetHeight); @@ -5136,8 +5133,8 @@ function Ace2Inner(){ function scrollXHorizontallyIntoView(pixelX) { - var win = outerWin; - var odoc = outerWin.document; + var win = window; + var odoc = window.document; pixelX += iframePadLeft; var distInsideLeft = pixelX - win.scrollX; var distInsideRight = win.scrollX + getInnerWidth() - pixelX; @@ -5331,7 +5328,7 @@ function Ace2Inner(){ { lineNumbersShown = 1; sideDiv.innerHTML = '
1
'; - sideDivInner = outerWin.document.getElementById("sidedivinner"); + sideDivInner = window.document.getElementById("sidedivinner"); } function updateLineNumbers() @@ -5377,7 +5374,7 @@ function Ace2Inner(){ if (newNumLines != lineNumbersShown) { var container = sideDivInner; - var odoc = outerWin.document; + var odoc = window.document; var fragment = odoc.createDocumentFragment(); while (lineNumbersShown < newNumLines) { @@ -5457,7 +5454,7 @@ function Ace2Inner(){ scheduler.setTimeout(function() { - parent.readyFunc(); // defined in code that sets up the inner iframe + editorInfo.onEditorReady(); // defined in code that sets up the inner iframe }, 0); isSetUp = true; @@ -5466,7 +5463,7 @@ function Ace2Inner(){ } -exports.init = function () { - var editor = new Ace2Inner() +exports.init = function (editorInfo) { + var editor = new Ace2Inner(editorInfo) editor.init(); }; diff --git a/src/templates/pad.html b/src/templates/pad.html index dd260414e..69479cda9 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -41,6 +41,8 @@ <% e.begin_block("styles"); %> + + <% e.begin_block("customStyles"); %> @@ -100,7 +102,13 @@
-
+
+
+
+
x
+
+
 
+

You need a password to access this pad

From 4f888190ae7791e3d46be5fd34d67439f08395ce Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sun, 12 Apr 2015 17:19:01 +0100 Subject: [PATCH 2/8] line numbers have correct height --- src/static/js/ace2_inner.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 2f3dd9888..deb8d5c94 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -5338,7 +5338,7 @@ function Ace2Inner(editorInfo){ //update height of all current line numbers var a = sideDivInner.firstChild; - var b = doc.body.firstChild; + var b = innerdocbody.firstChild; var n = 0; if (currentCallStack && currentCallStack.domClean) @@ -5376,6 +5376,7 @@ function Ace2Inner(editorInfo){ var container = sideDivInner; var odoc = window.document; var fragment = odoc.createDocumentFragment(); + while (lineNumbersShown < newNumLines) { lineNumbersShown++; From ea7f4079fba1122ab1ec6651350b4999ee5ea550 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sun, 12 Apr 2015 17:29:17 +0100 Subject: [PATCH 3/8] some more css fixes --- src/static/css/iframe_editor.css | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/static/css/iframe_editor.css b/src/static/css/iframe_editor.css index 5b980e74e..49349c150 100644 --- a/src/static/css/iframe_editor.css +++ b/src/static/css/iframe_editor.css @@ -16,13 +16,13 @@ a { white-space:pre-wrap; } -ul, ol, li { +#innerdocbody ul, #innerdocbody ol, #innerdocbody li { padding: 0; margin: 0; } -ul { margin-left: 1.5em; } -ul ul { margin-left: 0 !important; } +#innerdocbody ul { margin-left: 1.5em; } +#innerdocbody ul ul { margin-left: 0 !important; } ul.list-bullet1 { margin-left: 1.5em; } ul.list-bullet2 { margin-left: 3em; } ul.list-bullet3 { margin-left: 4.5em; } @@ -121,7 +121,6 @@ body.doesWrap > div{ #innerdocbody { position: absolute; top: 8px; - overflow: hidden; /* blank 1x1 gif, so that IE8 doesn't consider the body transparent */ background-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==); } From 06aa9e4db680ea339f6594b2a40c764f216e83bd Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 12 Apr 2015 19:02:49 +0100 Subject: [PATCH 4/8] fix editbar position, stop popups from closing on open --- src/static/css/pad.css | 3 +++ src/static/js/ace2_inner.js | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/static/css/pad.css b/src/static/css/pad.css index de314e172..b56e41f1d 100644 --- a/src/static/css/pad.css +++ b/src/static/css/pad.css @@ -54,6 +54,9 @@ a img { width: 100%; white-space: nowrap; height: 32px; + position:fixed; + top:0; + z-index:9; } .toolbar ul { position: absolute; diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index deb8d5c94..f650e34bb 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -373,7 +373,7 @@ function Ace2Inner(editorInfo){ if (currentCallStack) { - console.error("Can't enter callstack " + type + ", already in " + currentCallStack.type); + console.log("Can't enter callstack " + type + ", already in " + currentCallStack.type); } var profiling = false; @@ -3335,10 +3335,6 @@ function Ace2Inner(editorInfo){ evt.preventDefault(); } } - //hide the dropdownso - if(window.parent.parent.padeditbar){ // required in case its in an iframe should probably use parent.. See Issue 327 https://github.com/ether/etherpad-lite/issues/327 - window.parent.parent.padeditbar.toggleDropDown("none"); - } } function doReturnKey() From b2c312e72e3c7a61d96b79ff6418879d168ad5fb Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Sun, 12 Apr 2015 19:22:00 +0100 Subject: [PATCH 5/8] replaced some parent --- src/static/js/ace2_inner.js | 30 +++++++++++++++--------------- src/static/js/changesettracker.js | 2 +- src/static/js/chat.js | 4 ++-- src/static/js/collab_client.js | 8 ++++---- src/static/js/pad_editbar.js | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index deb8d5c94..8367ffb7b 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -3336,8 +3336,8 @@ function Ace2Inner(editorInfo){ } } //hide the dropdownso - if(window.parent.parent.padeditbar){ // required in case its in an iframe should probably use parent.. See Issue 327 https://github.com/ether/etherpad-lite/issues/327 - window.parent.parent.padeditbar.toggleDropDown("none"); + if(window.padeditbar){ // required in case its in an iframe should probably use parent.. See Issue 327 https://github.com/ether/etherpad-lite/issues/327 + window.padeditbar.toggleDropDown("none"); } } @@ -3632,15 +3632,15 @@ function Ace2Inner(editorInfo){ }else{ var lineHeight = myselection.focusNode.offsetHeight; // line height of blank lines } - var heightOfChatIcon = parent.parent.$('#chaticon').height(); // height of the chat icon button + var heightOfChatIcon = $('#chaticon').height(); // height of the chat icon button lineHeight = (lineHeight *2) + heightOfChatIcon; var viewport = getViewPortTopBottom(); var viewportHeight = viewport.bottom - viewport.top - lineHeight; var relCaretOffsetTop = caretOffsetTop - viewport.top; // relative Caret Offset Top to viewport if (viewportHeight < relCaretOffsetTop){ - parent.parent.$("#chaticon").css("opacity",".3"); // make chaticon opacity low when user types near it + $("#chaticon").css("opacity",".3"); // make chaticon opacity low when user types near it }else{ - parent.parent.$("#chaticon").css("opacity","1"); // make chaticon opacity back to full (so fully visible) + $("#chaticon").css("opacity","1"); // make chaticon opacity back to full (so fully visible) } //dmesg("keyevent type: "+type+", which: "+which); @@ -3691,7 +3691,7 @@ function Ace2Inner(editorInfo){ // Note that while most editors use Alt F10 this is not desirable // As ubuntu cannot use Alt F10.... // Focus on the editbar. -- TODO: Move Focus back to previous state (we know it so we can use it) - var firstEditbarElement = parent.parent.$('#editbar').children("ul").first().children().first().children().first().children().first(); + var firstEditbarElement = $('#editbar').children("ul").first().children().first().children().first().children().first(); $(this).blur(); firstEditbarElement.focus(); evt.preventDefault(); @@ -3699,8 +3699,8 @@ function Ace2Inner(editorInfo){ if ((!specialHandled) && altKey && keyCode == 67){ // Alt c focuses on the Chat window $(this).blur(); - parent.parent.chat.show(); - parent.parent.chat.focus(); + window.chat.show(); + window.chat.focus(); evt.preventDefault(); } if ((!specialHandled) && evt.ctrlKey && shiftKey && keyCode == 50 && type === "keydown"){ @@ -3739,13 +3739,13 @@ function Ace2Inner(editorInfo){ } else{ // Known authors info, both current and historical - var padAuthors = parent.parent.pad.userList(); + var padAuthors = window.pad.userList(); var authorObj = {}; authors.forEach(function(authorId){ padAuthors.forEach(function(padAuthor){ // If the person doing the lookup is the author.. if(padAuthor.userId === authorId){ - if(parent.parent.clientVars.userId === authorId){ + if(window.clientVars.userId === authorId){ authorObj = { name: "Me" } @@ -3770,7 +3770,7 @@ function Ace2Inner(editorInfo){ var authorString = "The authors of this line are " + authorNames.join(" & "); } - parent.parent.$.gritter.add({ + $.gritter.add({ // (string | mandatory) the heading of the notification title: 'Line Authors', // (string | mandatory) the text inside the notification @@ -3812,12 +3812,12 @@ function Ace2Inner(editorInfo){ if ((!specialHandled) && isTypeForCmdKey && String.fromCharCode(which).toLowerCase() == "s" && (evt.metaKey || evt.ctrlKey) && !evt.altKey) /* Do a saved revision on ctrl S */ { evt.preventDefault(); - var originalBackground = parent.parent.$('#revisionlink').css("background") - parent.parent.$('#revisionlink').css({"background":"lightyellow"}); + var originalBackground = $('#revisionlink').css("background") + $('#revisionlink').css({"background":"lightyellow"}); scheduler.setTimeout(function(){ - parent.parent.$('#revisionlink').css({"background":originalBackground}); + $('#revisionlink').css({"background":originalBackground}); }, 1000); - parent.parent.pad.collabClient.sendMessage({"type":"SAVE_REVISION"}); /* The parent.parent part of this is BAD and I feel bad.. It may break something */ + window.pad.collabClient.sendMessage({"type":"SAVE_REVISION"}); /* The parent.parent part of this is BAD and I feel bad.. It may break something */ specialHandled = true; } if ((!specialHandled) && isTypeForSpecialKey && keyCode == 9 && !(evt.metaKey || evt.ctrlKey)) diff --git a/src/static/js/changesettracker.js b/src/static/js/changesettracker.js index fe362c4b7..e1e1c3f8d 100644 --- a/src/static/js/changesettracker.js +++ b/src/static/js/changesettracker.js @@ -173,7 +173,7 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider) } // Get my authorID - var authorId = parent.parent.pad.myUserInfo.userId; + var authorId = window.pad.myUserInfo.userId; // Sanitize authorship // We need to replace all author attribs with thisSession.author, in case they copy/pasted or otherwise inserted other peoples changes diff --git a/src/static/js/chat.js b/src/static/js/chat.js index 42cd50f4b..6e59e4b6c 100644 --- a/src/static/js/chat.js +++ b/src/static/js/chat.js @@ -229,8 +229,8 @@ var chat = (function() if (evt.altKey && evt.which == 67){ // Alt c focuses on the Chat window $(this).blur(); - parent.parent.chat.show(); - parent.parent.chat.focus(); + window.chat.show(); + window.chat.focus(); evt.preventDefault(); } }); diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js index e5c0ec8b2..b1ada6fb8 100644 --- a/src/static/js/collab_client.js +++ b/src/static/js/collab_client.js @@ -279,7 +279,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) if (newRev != (oldRev + 1)) { - parent.parent.console.warn("bad message revision on NEW_CHANGES: " + newRev + " not " + (oldRev + 1)); + console.warn("bad message revision on NEW_CHANGES: " + newRev + " not " + (oldRev + 1)); // setChannelState("DISCONNECTED", "badmessage_newchanges"); return; } @@ -289,7 +289,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) if (newRev != (rev + 1)) { - parent.parent.console.warn("bad message revision on NEW_CHANGES: " + newRev + " not " + (rev + 1)); + console.warn("bad message revision on NEW_CHANGES: " + newRev + " not " + (rev + 1)); // setChannelState("DISCONNECTED", "badmessage_newchanges"); return; } @@ -303,7 +303,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) { if (newRev != (msgQueue[msgQueue.length - 1].newRev + 1)) { - parent.parent.console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (msgQueue[msgQueue.length - 1][0] + 1)); + console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (msgQueue[msgQueue.length - 1][0] + 1)); // setChannelState("DISCONNECTED", "badmessage_acceptcommit"); return; } @@ -313,7 +313,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) if (newRev != (rev + 1)) { - parent.parent.console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (rev + 1)); + console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (rev + 1)); // setChannelState("DISCONNECTED", "badmessage_acceptcommit"); return; } diff --git a/src/static/js/pad_editbar.js b/src/static/js/pad_editbar.js index e418969ea..03b7a97ed 100644 --- a/src/static/js/pad_editbar.js +++ b/src/static/js/pad_editbar.js @@ -332,7 +332,7 @@ var padeditbar = (function() } }else{ // Focus on the editbar :) - var firstEditbarElement = parent.parent.$('#editbar').children("ul").first().children().first().children().first().children().first(); + var firstEditbarElement = $('#editbar').children("ul").first().children().first().children().first().children().first(); $(this).blur(); firstEditbarElement.focus(); evt.preventDefault(); From 5f71c899ab2a221e7f95ce34e4bbcf97f580183d Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 12 Apr 2015 19:23:06 +0100 Subject: [PATCH 6/8] proper targeting of css rules --- src/static/css/iframe_editor.css | 18 ++++++++---------- src/static/css/pad.css | 6 ++++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/static/css/iframe_editor.css b/src/static/css/iframe_editor.css index 49349c150..ecc6b48b0 100644 --- a/src/static/css/iframe_editor.css +++ b/src/static/css/iframe_editor.css @@ -1,8 +1,8 @@ /* These CSS rules are included in both the outer and inner ACE iframe. Also see inner.css, included only in the inner one. */ -html { cursor: text; } /* in Safari, produces text cursor for whole doc (inc. below body) */ -span { cursor: auto; } +#innerdocbody html { cursor: text; } /* in Safari, produces text cursor for whole doc (inc. below body) */ +#innerdocbody span { cursor: auto; } ::selection { background: #acf; @@ -11,7 +11,7 @@ span { cursor: auto; } background: #acf; } -a { +#innerdocbody a { cursor: pointer !important; white-space:pre-wrap; } @@ -80,21 +80,19 @@ ul.list-indent6, ul.list-indent7, ul.list-indent8, ul.list-indent9, ul.list-inde ul.list-indent11, ul.list-indent12, ul.list-indent13, ul.list-indent14, ul.list-indent15, ul.list-indent16 { list-style-type: none; } -body { - margin: 0; - white-space: nowrap; - word-wrap: normal; -} - #outerdocbody { background-color: #fff; } -body.grayedout { background-color: #eee !important } + +#innerdocbody.grayedout { background-color: #eee !important } #innerdocbody { font-size: 12px; /* overridden by body.style */ font-family:Arial, sans-serif; /* overridden by body.style */ line-height: 16px; /* overridden by body.style */ + margin: 0; + white-space: nowrap; + word-wrap: normal; } body.doesWrap { diff --git a/src/static/css/pad.css b/src/static/css/pad.css index b56e41f1d..9837cf6ff 100644 --- a/src/static/css/pad.css +++ b/src/static/css/pad.css @@ -547,6 +547,12 @@ table#otheruserstable { border-top-left-radius: 5px; border-top-right-radius: 5px; display: none; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } #chattext { background-color: white; From 20e899476ab09a49cdc133fd061570bd9fc215fc Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 12 Apr 2015 19:27:34 +0100 Subject: [PATCH 7/8] make chat go in right place --- src/static/css/pad.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/static/css/pad.css b/src/static/css/pad.css index 9837cf6ff..44697cad2 100644 --- a/src/static/css/pad.css +++ b/src/static/css/pad.css @@ -532,7 +532,7 @@ table#otheruserstable { } #chatbox { - position: absolute; + position: fixed; bottom: 0px; right: 20px; width: 180px; From 27d4686ff8a7181df83f56dd62c74421359dcca6 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 12 Apr 2015 19:30:06 +0100 Subject: [PATCH 8/8] readwrite should be on innerdoc --- src/static/js/pad.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/static/js/pad.js b/src/static/js/pad.js index a2c76c08c..fc04e3c2d 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -322,7 +322,7 @@ function handshake() pad._afterHandshake(); initalized = true; - $("body").addClass(clientVars.readonly ? "readonly" : "readwrite") + $("#innerdocbody").addClass(clientVars.readonly ? "readonly" : "readwrite") padeditor.ace.callWithAce(function (ace) { ace.ace_setEditable(!clientVars.readonly);