Remember position of edit window #7
This commit is contained in:
parent
e5d50b02e7
commit
01329b7835
|
@ -297,3 +297,16 @@ function saveFromJSONStyleReloaded(updateType, style, callback) {
|
||||||
|
|
||||||
// Get the DB so that any first run actions will be performed immediately when the background page loads.
|
// Get the DB so that any first run actions will be performed immediately when the background page loads.
|
||||||
getDatabase(function() {}, reportError);
|
getDatabase(function() {}, reportError);
|
||||||
|
|
||||||
|
// When an edit page gets attached or detached, remember its state so we can do the same to the next one to open.
|
||||||
|
var editFullUrl = chrome.extension.getURL("edit.html");
|
||||||
|
chrome.tabs.onAttached.addListener(function(tabId, data) {
|
||||||
|
chrome.tabs.get(tabId, function(tabData) {
|
||||||
|
if (tabData.url.indexOf(editFullUrl) == 0) {
|
||||||
|
chrome.windows.get(tabData.windowId, {populate: true}, function(win) {
|
||||||
|
// If there's only one tab in this window, it's been dragged to new window
|
||||||
|
localStorage['openEditInWindow'] = win.tabs.length == 1 ? "true" : "false";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
12
popup.js
12
popup.js
|
@ -46,7 +46,7 @@ chrome.tabs.getSelected(null, function(tab) {
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
writeStyle.appendChild(document.createTextNode(" "));
|
writeStyle.appendChild(document.createTextNode(" "));
|
||||||
}
|
}
|
||||||
link.addEventListener("click", openLink, false);
|
link.addEventListener("click", openLinkInTabOrWindow, false);
|
||||||
writeStyle.appendChild(link);
|
writeStyle.appendChild(link);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -117,10 +117,18 @@ function getId(event) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openLinkInTabOrWindow(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (localStorage['openEditInWindow'] == 'true') {
|
||||||
|
chrome.windows.create({url: event.target.href});
|
||||||
|
} else {
|
||||||
|
chrome.tabs.create({url: event.target.href});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function openLink(event) {
|
function openLink(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
chrome.tabs.create({url: event.target.href});
|
chrome.tabs.create({url: event.target.href});
|
||||||
//return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUpdate(style) {
|
function handleUpdate(style) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user