diff --git a/edit.js b/edit.js index 929c97fb..8fb886db 100644 --- a/edit.js +++ b/edit.js @@ -3,6 +3,7 @@ var styleId = null; var dirty = false; var lockScroll; // ensure the section doesn't jump when clicking selected text +var isSeparateWindow; var appliesToTemplate = document.createElement("li"); appliesToTemplate.innerHTML = ''; @@ -218,13 +219,19 @@ document.addEventListener("keydown", function(e) { } }); +chrome.tabs.query({currentWindow: true}, function(tabs) { + isSeparateWindow = tabs.length == 1; +}); + window.onbeforeunload = function() { - prefs.setPref('windowPosition', { - left: screenLeft, - top: screenTop, - width: outerWidth, - height: outerHeight - }); + if (isSeparateWindow) { + prefs.setPref('windowPosition', { + left: screenLeft, + top: screenTop, + width: outerWidth, + height: outerHeight + }); + } document.activeElement.blur(); return !isCleanGlobal() ? t('styleChangesNotSaved') : null; } @@ -308,7 +315,7 @@ function addSection(event, section) { setupCodeMirror(div.querySelector('.code')); if (section) { var index = Array.prototype.indexOf.call(sections.children, section); - var cm = editors.pop(); + var cm = editors.pop(); editors.splice(index, 0, cm); cm.focus(); }