From 374244fcebc1820bb419185491b7d4bc9cb5454c Mon Sep 17 00:00:00 2001 From: tophf Date: Sat, 14 Mar 2015 01:26:26 +0300 Subject: [PATCH] Editor: remember size/pos only for detached windows --- edit.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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(); }