Merge remote-tracking branch 'remotes/origin/iframes-must-die' into requirejs

Conflicts:
	src/static/js/ace.js
	src/static/js/chat.js
	src/static/js/collab_client.js
	src/static/js/pad.js
	src/static/js/pad_editbar.js
This commit is contained in:
Egil Moeller 2015-04-25 18:15:48 +02:00
commit 90b359c82b
10 changed files with 97 additions and 210 deletions

View file

@ -1,8 +1,8 @@
/* These CSS rules are included in both the outer and inner ACE iframe. /* These CSS rules are included in both the outer and inner ACE iframe.
Also see inner.css, included only in the inner one. Also see inner.css, included only in the inner one.
*/ */
html { cursor: text; } /* in Safari, produces text cursor for whole doc (inc. below body) */ #innerdocbody html { cursor: text; } /* in Safari, produces text cursor for whole doc (inc. below body) */
span { cursor: auto; } #innerdocbody span { cursor: auto; }
::selection { ::selection {
background: #acf; background: #acf;
@ -11,18 +11,18 @@ span { cursor: auto; }
background: #acf; background: #acf;
} }
a { #innerdocbody a {
cursor: pointer !important; cursor: pointer !important;
white-space:pre-wrap; white-space:pre-wrap;
} }
ul, ol, li { #innerdocbody ul, #innerdocbody ol, #innerdocbody li {
padding: 0; padding: 0;
margin: 0; margin: 0;
} }
ul { margin-left: 1.5em; } #innerdocbody ul { margin-left: 1.5em; }
ul ul { margin-left: 0 !important; } #innerdocbody ul ul { margin-left: 0 !important; }
ul.list-bullet1 { margin-left: 1.5em; } ul.list-bullet1 { margin-left: 1.5em; }
ul.list-bullet2 { margin-left: 3em; } ul.list-bullet2 { margin-left: 3em; }
ul.list-bullet3 { margin-left: 4.5em; } ul.list-bullet3 { margin-left: 4.5em; }
@ -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-indent11, ul.list-indent12, ul.list-indent13,
ul.list-indent14, ul.list-indent15, ul.list-indent16 { list-style-type: none; } ul.list-indent14, ul.list-indent15, ul.list-indent16 { list-style-type: none; }
body {
margin: 0;
white-space: nowrap;
word-wrap: normal;
}
#outerdocbody { #outerdocbody {
background-color: #fff; background-color: #fff;
} }
body.grayedout { background-color: #eee !important }
#innerdocbody.grayedout { background-color: #eee !important }
#innerdocbody { #innerdocbody {
font-size: 12px; /* overridden by body.style */ font-size: 12px; /* overridden by body.style */
font-family:Arial, sans-serif; /* overridden by body.style */ font-family:Arial, sans-serif; /* overridden by body.style */
line-height: 16px; /* overridden by body.style */ line-height: 16px; /* overridden by body.style */
margin: 0;
white-space: nowrap;
word-wrap: normal;
} }
body.doesWrap { body.doesWrap {
@ -119,11 +117,8 @@ body.doesWrap > div{
} }
#innerdocbody { #innerdocbody {
padding-top: 1px; /* important for some reason? */ position: absolute;
padding-right: 10px; top: 8px;
padding-bottom: 8px;
padding-left: 1px /* prevents characters from looking chopped off in FF3 -- Removed because it added too much whitespace */;
overflow: hidden;
/* blank 1x1 gif, so that IE8 doesn't consider the body transparent */ /* blank 1x1 gif, so that IE8 doesn't consider the body transparent */
background-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==); background-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==);
} }

View file

@ -16,9 +16,6 @@ body,
textarea { textarea {
font-family: Helvetica, Arial, sans-serif font-family: Helvetica, Arial, sans-serif
} }
iframe {
position: absolute
}
.readonly .acl-write { .readonly .acl-write {
display: none; display: none;
} }
@ -57,6 +54,9 @@ a img {
width: 100%; width: 100%;
white-space: nowrap; white-space: nowrap;
height: 32px; height: 32px;
position:fixed;
top:0;
z-index:9;
} }
.toolbar ul { .toolbar ul {
position: absolute; position: absolute;
@ -217,13 +217,6 @@ li[data-key=showusers] > a #online_count {
bottom: 0px; bottom: 0px;
z-index: 1; z-index: 1;
} }
#editorcontainer iframe {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
left: 0; /* Required for safari fixes RTL */
}
#editorloadingbox { #editorloadingbox {
padding-top: 100px; padding-top: 100px;
padding-bottom: 100px; padding-bottom: 100px;
@ -539,7 +532,7 @@ table#otheruserstable {
} }
#chatbox { #chatbox {
position: absolute; position: fixed;
bottom: 0px; bottom: 0px;
right: 20px; right: 20px;
width: 180px; width: 180px;
@ -554,6 +547,12 @@ table#otheruserstable {
border-top-left-radius: 5px; border-top-left-radius: 5px;
border-top-right-radius: 5px; border-top-right-radius: 5px;
display: none; 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 { #chattext {
background-color: white; background-color: white;

View file

@ -163,7 +163,6 @@ define(['ep_etherpad-lite/static/js/pluginfw/hooks', 'underscore'], function (ho
editor.init = function(containerId, initialCode, doneFunc) editor.init = function(containerId, initialCode, doneFunc)
{ {
editor.importText(initialCode); editor.importText(initialCode);
info.onEditorReady = function() info.onEditorReady = function()
@ -173,124 +172,11 @@ define(['ep_etherpad-lite/static/js/pluginfw/hooks', 'underscore'], function (ho
doneFunc(); doneFunc();
}; };
(function() requirejs(["ep_etherpad-lite/static/js/ace2_inner"], function (Ace2Inner) {
{ var editorId = info.id;
var doctype = "<!doctype html>"; var editorInfo = Ace2Editor.registry[editorId];
Ace2Inner.init(editorInfo);
var iframeHTML = []; });
iframeHTML.push(doctype);
iframeHTML.push("<html><head>");
var includedCSS = ["../static/css/iframe_editor.css",
"../static/css/pad.css",
"../static/custom/pad.css"]
var additionalCSS = _(hooks.callAll("aceEditorCSS")).map(function(path){ return '../static/plugins/' + path });
includedCSS = includedCSS.concat(additionalCSS);
pushStyleTagsFor(iframeHTML, includedCSS);
iframeHTML.push('<script type="text/javascript" src="../static/js/require-kernel.js"></script>');
iframeHTML.push(scriptTag('\n\
require.setRootURI("../javascripts/src");\n\
require.setLibraryURI("../javascripts/lib");\n\
require.setGlobalKeyPath("require");\n\
'));
iframeHTML.push('<script type="text/javascript" src="../static/plugins/requirejs/require.js"></script>');
iframeHTML.push(scriptTag('\n\
var pathComponents = parent.parent.location.pathname.split("/");\n\
var baseURL = pathComponents.slice(0,pathComponents.length-2).join("/") + "/";\n\
requirejs.config({\n\
baseUrl: baseURL + "static/plugins",\n\
paths: {underscore: baseURL + "static/plugins/underscore/underscore"}\n\
});\n\
\n\
requirejs(["ep_etherpad-lite/static/js/rjquery", "ep_etherpad-lite/static/js/pluginfw/client_plugins", "ep_etherpad-lite/static/js/ace2_inner"], function (j, plugins, Ace2Inner) {\n\
jQuery = $ = window.jQuery = window.$ = j; // Expose jQuery #HACK\n\
\n\
plugins.adoptPluginsFromAncestorsOf(window, function () {\n\
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");\n\
hooks.plugins = plugins;\n\
\n\
plugins.ensure(function () {\n\
Ace2Inner.init();\n\
});\n\
});\n\
});\n\
'));
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');
hooks.callAll("aceInitInnerdocbodyHead", {
iframeHTML: iframeHTML
});
iframeHTML.push('</head><body id="innerdocbody" role="application" class="syntax" spellcheck="false">&nbsp;</body></html>');
// 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, '<html><head>']
var includedCSS = [
"../static/css/iframe_editor.css",
"../static/css/pad.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('<style type="text/css" title="dynamicsyntax"></style>', '<link rel="stylesheet" type="text/css" href="data:text/css,"/>', scriptTag(outerScript), '</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div></body></html>');
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();
})();
}; };
return editor; return editor;

View file

@ -44,7 +44,7 @@ var isNodeText = Ace2Common.isNodeText,
htmlPrettyEscape = Ace2Common.htmlPrettyEscape, htmlPrettyEscape = Ace2Common.htmlPrettyEscape,
noop = Ace2Common.noop; noop = Ace2Common.noop;
function Ace2Inner(){ function Ace2Inner(editorInfo){
var makeChangesetTracker = require('./changesettracker').makeChangesetTracker; var makeChangesetTracker = require('./changesettracker').makeChangesetTracker;
var colorutils = require('./colorutils').colorutils; var colorutils = require('./colorutils').colorutils;
@ -77,13 +77,9 @@ function Ace2Inner(){
var thisAuthor = ''; var thisAuthor = '';
var disposed = false; var disposed = false;
var editorInfo = parent.editorInfo; var sideDiv = $('#sidediv')[0];
var lineMetricsDiv = $('#linemetricsdiv')[0];
var iframe = window.frameElement; var innerdocbody = $('#innerdocbody')[0];
var outerWin = iframe.ace_outerWin;
iframe.ace_outerWin = null; // prevent IE 6 memory leak
var sideDiv = iframe.nextSibling;
var lineMetricsDiv = sideDiv.nextSibling;
initLineNumbers(); initLineNumbers();
var outsideKeyDown = noop; var outsideKeyDown = noop;
@ -374,7 +370,7 @@ function Ace2Inner(){
if (currentCallStack) 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; var profiling = false;
@ -475,6 +471,7 @@ function Ace2Inner(){
//console.log("Just did action for: "+type); //console.log("Just did action for: "+type);
cleanExit = true; cleanExit = true;
} }
/*
catch (e) catch (e)
{ {
caughtErrors.push( caughtErrors.push(
@ -485,6 +482,7 @@ function Ace2Inner(){
dmesg(e.toString()); dmesg(e.toString());
throw e; throw e;
} }
*/
finally finally
{ {
var cs = currentCallStack; var cs = currentCallStack;
@ -958,7 +956,7 @@ function Ace2Inner(){
setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers); setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers);
fixView(); fixView();
}, },
grayedout: setClassPresenceNamed(outerWin.document.body, "grayedout"), grayedout: setClassPresenceNamed(window.document.body, "grayedout"),
dmesg: function(){ dmesg = window.dmesg = value; }, dmesg: function(){ dmesg = window.dmesg = value; },
userauthor: function(value){ userauthor: function(value){
thisAuthor = String(value); thisAuthor = String(value);
@ -3264,7 +3262,7 @@ function Ace2Inner(){
function getViewPortTopBottom() function getViewPortTopBottom()
{ {
var theTop = getScrollY(); var theTop = getScrollY();
var doc = outerWin.document; var doc = window.document;
var height = doc.documentElement.clientHeight; var height = doc.documentElement.clientHeight;
return { return {
top: theTop, top: theTop,
@ -3340,10 +3338,6 @@ function Ace2Inner(){
evt.preventDefault(); 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() function doReturnKey()
@ -3637,15 +3631,15 @@ function Ace2Inner(){
}else{ }else{
var lineHeight = myselection.focusNode.offsetHeight; // line height of blank lines 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; lineHeight = (lineHeight *2) + heightOfChatIcon;
var viewport = getViewPortTopBottom(); var viewport = getViewPortTopBottom();
var viewportHeight = viewport.bottom - viewport.top - lineHeight; var viewportHeight = viewport.bottom - viewport.top - lineHeight;
var relCaretOffsetTop = caretOffsetTop - viewport.top; // relative Caret Offset Top to viewport var relCaretOffsetTop = caretOffsetTop - viewport.top; // relative Caret Offset Top to viewport
if (viewportHeight < relCaretOffsetTop){ 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{ }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); //dmesg("keyevent type: "+type+", which: "+which);
@ -3696,7 +3690,7 @@ function Ace2Inner(){
// Note that while most editors use Alt F10 this is not desirable // Note that while most editors use Alt F10 this is not desirable
// As ubuntu cannot use Alt F10.... // 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) // 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(); $(this).blur();
firstEditbarElement.focus(); firstEditbarElement.focus();
evt.preventDefault(); evt.preventDefault();
@ -3704,8 +3698,8 @@ function Ace2Inner(){
if ((!specialHandled) && altKey && keyCode == 67){ if ((!specialHandled) && altKey && keyCode == 67){
// Alt c focuses on the Chat window // Alt c focuses on the Chat window
$(this).blur(); $(this).blur();
parent.parent.chat.show(); window.chat.show();
parent.parent.chat.focus(); window.chat.focus();
evt.preventDefault(); evt.preventDefault();
} }
if ((!specialHandled) && evt.ctrlKey && shiftKey && keyCode == 50 && type === "keydown"){ if ((!specialHandled) && evt.ctrlKey && shiftKey && keyCode == 50 && type === "keydown"){
@ -3744,13 +3738,13 @@ function Ace2Inner(){
} }
else{ else{
// Known authors info, both current and historical // Known authors info, both current and historical
var padAuthors = parent.parent.pad.userList(); var padAuthors = window.pad.userList();
var authorObj = {}; var authorObj = {};
authors.forEach(function(authorId){ authors.forEach(function(authorId){
padAuthors.forEach(function(padAuthor){ padAuthors.forEach(function(padAuthor){
// If the person doing the lookup is the author.. // If the person doing the lookup is the author..
if(padAuthor.userId === authorId){ if(padAuthor.userId === authorId){
if(parent.parent.clientVars.userId === authorId){ if(window.clientVars.userId === authorId){
authorObj = { authorObj = {
name: "Me" name: "Me"
} }
@ -3775,7 +3769,7 @@ function Ace2Inner(){
var authorString = "The authors of this line are " + authorNames.join(" & "); var authorString = "The authors of this line are " + authorNames.join(" & ");
} }
parent.parent.$.gritter.add({ $.gritter.add({
// (string | mandatory) the heading of the notification // (string | mandatory) the heading of the notification
title: 'Line Authors', title: 'Line Authors',
// (string | mandatory) the text inside the notification // (string | mandatory) the text inside the notification
@ -3810,19 +3804,19 @@ function Ace2Inner(){
//scrollSelectionIntoView(); //scrollSelectionIntoView();
scheduler.setTimeout(function() scheduler.setTimeout(function()
{ {
outerWin.scrollBy(-100, 0); window.scrollBy(-100, 0);
}, 0); }, 0);
specialHandled = true; specialHandled = true;
} }
if ((!specialHandled) && isTypeForCmdKey && String.fromCharCode(which).toLowerCase() == "s" && (evt.metaKey || evt.ctrlKey) && !evt.altKey) /* Do a saved revision on ctrl S */ if ((!specialHandled) && isTypeForCmdKey && String.fromCharCode(which).toLowerCase() == "s" && (evt.metaKey || evt.ctrlKey) && !evt.altKey) /* Do a saved revision on ctrl S */
{ {
evt.preventDefault(); evt.preventDefault();
var originalBackground = parent.parent.$('#revisionlink').css("background") var originalBackground = $('#revisionlink').css("background")
parent.parent.$('#revisionlink').css({"background":"lightyellow"}); $('#revisionlink').css({"background":"lightyellow"});
scheduler.setTimeout(function(){ scheduler.setTimeout(function(){
parent.parent.$('#revisionlink').css({"background":originalBackground}); $('#revisionlink').css({"background":originalBackground});
}, 1000); }, 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; specialHandled = true;
} }
if ((!specialHandled) && isTypeForSpecialKey && keyCode == 9 && !(evt.metaKey || evt.ctrlKey)) if ((!specialHandled) && isTypeForSpecialKey && keyCode == 9 && !(evt.metaKey || evt.ctrlKey))
@ -4722,6 +4716,7 @@ function Ace2Inner(){
function fixView() function fixView()
{ {
//return; // TODO: look into this later
// calling this method repeatedly should be fast // calling this method repeatedly should be fast
if (getInnerWidth() === 0 || getInnerHeight() === 0) if (getInnerWidth() === 0 || getInnerHeight() === 0)
{ {
@ -4741,7 +4736,7 @@ function Ace2Inner(){
if (newSideDivWidth < MIN_LINEDIV_WIDTH) newSideDivWidth = MIN_LINEDIV_WIDTH; if (newSideDivWidth < MIN_LINEDIV_WIDTH) newSideDivWidth = MIN_LINEDIV_WIDTH;
iframePadLeft = EDIT_BODY_PADDING_LEFT; iframePadLeft = EDIT_BODY_PADDING_LEFT;
if (hasLineNumbers) iframePadLeft += newSideDivWidth + LINE_NUMBER_PADDING_RIGHT; 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"); setIfNecessary(sideDiv.style, "width", newSideDivWidth + "px");
for (var i = 0; i < 2; i++) for (var i = 0; i < 2; i++)
@ -4753,11 +4748,11 @@ function Ace2Inner(){
if (newHeight < viewHeight) if (newHeight < viewHeight)
{ {
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 else
{ {
if (browser.msie) setIfNecessary(outerWin.document.documentElement.style, 'overflowY', 'scroll'); if (browser.msie) setIfNecessary(window.document.documentElement.style, 'overflowY', 'scroll');
} }
if (doesWrap) if (doesWrap)
{ {
@ -4767,8 +4762,8 @@ function Ace2Inner(){
{ {
if (newWidth < viewWidth) newWidth = viewWidth; if (newWidth < viewWidth) newWidth = viewWidth;
} }
setIfNecessary(iframe.style, "height", newHeight + "px"); setIfNecessary(innerdocbody.style, "height", newHeight + "px");
setIfNecessary(iframe.style, "width", newWidth + "px"); setIfNecessary(innerdocbody.style, "width", newWidth + "px");
setIfNecessary(sideDiv.style, "height", newHeight + "px"); setIfNecessary(sideDiv.style, "height", newHeight + "px");
} }
if (browser.firefox) if (browser.firefox)
@ -4793,7 +4788,7 @@ function Ace2Inner(){
// if near edge, scroll to edge // if near edge, scroll to edge
var scrollX = getScrollX(); var scrollX = getScrollX();
var scrollY = getScrollY(); var scrollY = getScrollY();
var win = outerWin; var win = window;
var r = 20; var r = 20;
enforceEditability(); enforceEditability();
@ -4803,8 +4798,8 @@ function Ace2Inner(){
function getScrollXY() function getScrollXY()
{ {
var win = outerWin; var win = window;
var odoc = outerWin.document; var odoc = window.document;
if (typeof(win.pageYOffset) == "number") if (typeof(win.pageYOffset) == "number")
{ {
return { return {
@ -4834,17 +4829,17 @@ function Ace2Inner(){
function setScrollX(x) function setScrollX(x)
{ {
outerWin.scrollTo(x, getScrollY()); window.scrollTo(x, getScrollY());
} }
function setScrollY(y) function setScrollY(y)
{ {
outerWin.scrollTo(getScrollX(), y); window.scrollTo(getScrollX(), y);
} }
function setScrollXY(x, y) function setScrollXY(x, y)
{ {
outerWin.scrollTo(x, y); window.scrollTo(x, y);
} }
var _teardownActions = []; var _teardownActions = [];
@ -5078,7 +5073,7 @@ function Ace2Inner(){
function getPageHeight() function getPageHeight()
{ {
var win = outerWin; var win = window;
var odoc = win.document; var odoc = win.document;
if (win.innerHeight && win.scrollMaxY) return win.innerHeight + win.scrollMaxY; if (win.innerHeight && win.scrollMaxY) return win.innerHeight + win.scrollMaxY;
else if (odoc.body.scrollHeight > odoc.body.offsetHeight) return odoc.body.scrollHeight; else if (odoc.body.scrollHeight > odoc.body.offsetHeight) return odoc.body.scrollHeight;
@ -5087,7 +5082,7 @@ function Ace2Inner(){
function getPageWidth() function getPageWidth()
{ {
var win = outerWin; var win = window;
var odoc = win.document; var odoc = win.document;
if (win.innerWidth && win.scrollMaxX) return win.innerWidth + win.scrollMaxX; if (win.innerWidth && win.scrollMaxX) return win.innerWidth + win.scrollMaxX;
else if (odoc.body.scrollWidth > odoc.body.offsetWidth) return odoc.body.scrollWidth; else if (odoc.body.scrollWidth > odoc.body.offsetWidth) return odoc.body.scrollWidth;
@ -5096,7 +5091,7 @@ function Ace2Inner(){
function getInnerHeight() function getInnerHeight()
{ {
var win = outerWin; var win = window;
var odoc = win.document; var odoc = win.document;
var h; var h;
if (browser.opera) h = win.innerHeight; if (browser.opera) h = win.innerHeight;
@ -5110,7 +5105,7 @@ function Ace2Inner(){
function getInnerWidth() function getInnerWidth()
{ {
var win = outerWin; var win = window;
var odoc = win.document; var odoc = win.document;
return odoc.documentElement.clientWidth; return odoc.documentElement.clientWidth;
} }
@ -5120,8 +5115,8 @@ function Ace2Inner(){
// requires element (non-text) node; // requires element (non-text) node;
// if node extends above top of viewport or below bottom of viewport (or top of scrollbar), // 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. // scroll it the minimum distance needed to be completely in view.
var win = outerWin; var win = window;
var odoc = outerWin.document; var odoc = window.document;
var distBelowTop = node.offsetTop + iframePadTop - win.scrollY; var distBelowTop = node.offsetTop + iframePadTop - win.scrollY;
var distAboveBottom = win.scrollY + getInnerHeight() - (node.offsetTop + iframePadTop + node.offsetHeight); var distAboveBottom = win.scrollY + getInnerHeight() - (node.offsetTop + iframePadTop + node.offsetHeight);
@ -5137,8 +5132,8 @@ function Ace2Inner(){
function scrollXHorizontallyIntoView(pixelX) function scrollXHorizontallyIntoView(pixelX)
{ {
var win = outerWin; var win = window;
var odoc = outerWin.document; var odoc = window.document;
pixelX += iframePadLeft; pixelX += iframePadLeft;
var distInsideLeft = pixelX - win.scrollX; var distInsideLeft = pixelX - win.scrollX;
var distInsideRight = win.scrollX + getInnerWidth() - pixelX; var distInsideRight = win.scrollX + getInnerWidth() - pixelX;
@ -5332,7 +5327,7 @@ function Ace2Inner(){
{ {
lineNumbersShown = 1; lineNumbersShown = 1;
sideDiv.innerHTML = '<table border="0" cellpadding="0" cellspacing="0" align="right"><tr><td id="sidedivinner"><div>1</div></td></tr></table>'; sideDiv.innerHTML = '<table border="0" cellpadding="0" cellspacing="0" align="right"><tr><td id="sidedivinner"><div>1</div></td></tr></table>';
sideDivInner = outerWin.document.getElementById("sidedivinner"); sideDivInner = window.document.getElementById("sidedivinner");
} }
function updateLineNumbers() function updateLineNumbers()
@ -5342,7 +5337,7 @@ function Ace2Inner(){
//update height of all current line numbers //update height of all current line numbers
var a = sideDivInner.firstChild; var a = sideDivInner.firstChild;
var b = doc.body.firstChild; var b = innerdocbody.firstChild;
var n = 0; var n = 0;
if (currentCallStack && currentCallStack.domClean) if (currentCallStack && currentCallStack.domClean)
@ -5378,8 +5373,9 @@ function Ace2Inner(){
if (newNumLines != lineNumbersShown) if (newNumLines != lineNumbersShown)
{ {
var container = sideDivInner; var container = sideDivInner;
var odoc = outerWin.document; var odoc = window.document;
var fragment = odoc.createDocumentFragment(); var fragment = odoc.createDocumentFragment();
while (lineNumbersShown < newNumLines) while (lineNumbersShown < newNumLines)
{ {
lineNumbersShown++; lineNumbersShown++;
@ -5458,7 +5454,7 @@ function Ace2Inner(){
scheduler.setTimeout(function() 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); }, 0);
isSetUp = true; isSetUp = true;
@ -5467,8 +5463,8 @@ function Ace2Inner(){
} }
exports.init = function () { exports.init = function (editorInfo) {
var editor = new Ace2Inner() var editor = new Ace2Inner(editorInfo)
editor.init(); editor.init();
}; };

View file

@ -173,7 +173,7 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
} }
// Get my authorID // Get my authorID
var authorId = parent.parent.pad.myUserInfo.userId; var authorId = window.pad.myUserInfo.userId;
// Sanitize authorship // Sanitize authorship
// We need to replace all author attribs with thisSession.author, in case they copy/pasted or otherwise inserted other peoples changes // We need to replace all author attribs with thisSession.author, in case they copy/pasted or otherwise inserted other peoples changes

View file

@ -237,8 +237,8 @@ define([
if (evt.altKey && evt.which == 67){ if (evt.altKey && evt.which == 67){
// Alt c focuses on the Chat window // Alt c focuses on the Chat window
$(this).blur(); $(this).blur();
parent.parent.chat.show(); window.chat.show();
parent.parent.chat.focus(); window.chat.focus();
evt.preventDefault(); evt.preventDefault();
} }
}); });

View file

@ -294,7 +294,7 @@ define([
if (newRev != (rev + 1)) 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 " + (oldRev + 1));
// setChannelState("DISCONNECTED", "badmessage_newchanges"); // setChannelState("DISCONNECTED", "badmessage_newchanges");
return; return;
} }
@ -318,7 +318,7 @@ define([
if (newRev != (rev + 1)) 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 " + (msgQueue[msgQueue.length - 1][0] + 1));
// setChannelState("DISCONNECTED", "badmessage_acceptcommit"); // setChannelState("DISCONNECTED", "badmessage_acceptcommit");
return; return;
} }
@ -343,6 +343,9 @@ define([
setStateIdle(); setStateIdle();
handleUserChanges(); handleUserChanges();
} }
console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (rev + 1));
// setChannelState("DISCONNECTED", "badmessage_acceptcommit");
return;
} }
else if (msg.type == "USER_NEWINFO") else if (msg.type == "USER_NEWINFO")
{ {

View file

@ -276,7 +276,7 @@ define([
pad._afterHandshake(); pad._afterHandshake();
initalized = true; initalized = true;
$("body").addClass(clientVars.readonly ? "readonly" : "readwrite") $("#innerdocbody").addClass(clientVars.readonly ? "readonly" : "readwrite")
padeditor.ace.callWithAce(function (ace) { padeditor.ace.callWithAce(function (ace) {
ace.ace_setEditable(!clientVars.readonly); ace.ace_setEditable(!clientVars.readonly);

View file

@ -338,7 +338,7 @@ define([
} }
}else{ }else{
// Focus on the editbar :) // 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(); $(this).blur();
firstEditbarElement.focus(); firstEditbarElement.focus();
evt.preventDefault(); evt.preventDefault();

View file

@ -41,6 +41,8 @@
<% e.begin_block("styles"); %> <% e.begin_block("styles"); %>
<link href="../static/css/pad.css" rel="stylesheet"> <link href="../static/css/pad.css" rel="stylesheet">
<link href="../static/css/iframe_editor.css" rel="stylesheet">
<link href="../static/custom/pad.css" rel="stylesheet">
<% e.begin_block("customStyles"); %> <% e.begin_block("customStyles"); %>
<link href="../static/custom/pad.css" rel="stylesheet"> <link href="../static/custom/pad.css" rel="stylesheet">
@ -100,7 +102,13 @@
</div> </div>
<div id="editorcontainerbox"> <div id="editorcontainerbox">
<div id="editorcontainer"></div> <div id="editorcontainer">
<div id="outerdocbody">
<div id="sidediv"><!-- --></div>
<div id="linemetricsdiv">x</div>
</div>
<div id="innerdocbody" role="application" class="syntax" spellcheck="false">&nbsp;</div>
</div>
<div id="editorloadingbox"> <div id="editorloadingbox">
<div id="passwordRequired"> <div id="passwordRequired">
<p data-l10n-id="pad.passwordRequired">You need a password to access this pad</p> <p data-l10n-id="pad.passwordRequired">You need a password to access this pad</p>