commit
761b5bd7d9
31
edit.js
31
edit.js
|
@ -3,7 +3,7 @@
|
||||||
var styleId = null;
|
var styleId = null;
|
||||||
var dirty = {}; // only the actually dirty items here
|
var dirty = {}; // only the actually dirty items here
|
||||||
var editors = []; // array of all CodeMirror instances
|
var editors = []; // array of all CodeMirror instances
|
||||||
var isSeparateWindow; // used currrently to determine if the window size/pos should be remembered
|
var saveSizeOnClose;
|
||||||
|
|
||||||
// direct & reverse mapping of @-moz-document keywords and internal property names
|
// direct & reverse mapping of @-moz-document keywords and internal property names
|
||||||
var propertyToCss = {urls: "url", urlPrefixes: "url-prefix", domains: "domain", regexps: "regexp"};
|
var propertyToCss = {urls: "url", urlPrefixes: "url-prefix", domains: "domain", regexps: "regexp"};
|
||||||
|
@ -404,13 +404,26 @@ document.addEventListener("wheel", function(event) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.tabs.query({currentWindow: true}, function(tabs) {
|
if (prefs.getPref("openEditInWindow")) {
|
||||||
isSeparateWindow = tabs.length == 1;
|
chrome.tabs.query({currentWindow: true}, function(tabs) {
|
||||||
});
|
var windowId = tabs[0].windowId;
|
||||||
|
if (tabs.length == 1 && window.history.length == 1) {
|
||||||
|
sessionStorageHash("saveSizeOnClose").set(windowId, true);
|
||||||
|
saveSizeOnClose = true;
|
||||||
|
} else {
|
||||||
|
saveSizeOnClose = sessionStorageHash("saveSizeOnClose").value[windowId];
|
||||||
|
}
|
||||||
|
chrome.tabs.onRemoved.addListener(function(tabId, info) {
|
||||||
|
if (info.windowId == windowId && info.isWindowClosing) {
|
||||||
|
sessionStorageHash("saveSizeOnClose").unset(windowId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
window.onbeforeunload = function() {
|
window.onbeforeunload = function() {
|
||||||
if (isSeparateWindow) {
|
if (saveSizeOnClose) {
|
||||||
prefs.setPref('windowPosition', {
|
prefs.setPref("windowPosition", {
|
||||||
left: screenLeft,
|
left: screenLeft,
|
||||||
top: screenTop,
|
top: screenTop,
|
||||||
width: outerWidth,
|
width: outerWidth,
|
||||||
|
@ -928,11 +941,9 @@ function saveComplete(style) {
|
||||||
|
|
||||||
// Go from new style URL to edit style URL
|
// Go from new style URL to edit style URL
|
||||||
if (location.href.indexOf("id=") == -1) {
|
if (location.href.indexOf("id=") == -1) {
|
||||||
// give the code above a moment before we kill the page
|
history.replaceState({}, document.title, "edit.html?id=" + style.id);
|
||||||
setTimeout(function() {location.href = "edit.html?id=" + style.id;}, 200);
|
|
||||||
} else {
|
|
||||||
updateTitle();
|
|
||||||
}
|
}
|
||||||
|
updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMozillaFormat() {
|
function showMozillaFormat() {
|
||||||
|
|
17
storage.js
17
storage.js
|
@ -161,6 +161,7 @@ var prefs = {
|
||||||
|
|
||||||
// defaults
|
// defaults
|
||||||
"openEditInWindow": false, // new editor opens in a own browser window
|
"openEditInWindow": false, // new editor opens in a own browser window
|
||||||
|
"windowPosition": {}, // detached window position
|
||||||
"show-badge": true, // display text on popup menu icon
|
"show-badge": true, // display text on popup menu icon
|
||||||
"disableAll": false, // boss key
|
"disableAll": false, // boss key
|
||||||
|
|
||||||
|
@ -171,7 +172,7 @@ var prefs = {
|
||||||
|
|
||||||
"manage.onlyEnabled": false, // display only enabled styles
|
"manage.onlyEnabled": false, // display only enabled styles
|
||||||
"manage.onlyEdited": false, // display only styles created locally
|
"manage.onlyEdited": false, // display only styles created locally
|
||||||
|
|
||||||
"editor.options": null, // CodeMirror.defaults.*
|
"editor.options": null, // CodeMirror.defaults.*
|
||||||
"editor.lineWrapping": true, // word wrap
|
"editor.lineWrapping": true, // word wrap
|
||||||
"editor.smartIndent": true, // "smart" indent
|
"editor.smartIndent": true, // "smart" indent
|
||||||
|
@ -242,3 +243,17 @@ function getCodeMirrorThemes(callback) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sessionStorageHash(name) {
|
||||||
|
var hash = {
|
||||||
|
value: {},
|
||||||
|
set: function(k, v) { this.value[k] = v; this.updateStorage(); },
|
||||||
|
unset: function(k) { delete this.value[k]; this.updateStorage(); },
|
||||||
|
updateStorage: function() {
|
||||||
|
sessionStorage[this.name] = JSON.stringify(this.value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try { hash.value = JSON.parse(sessionStorage[name]); } catch(e) {}
|
||||||
|
Object.defineProperty(hash, "name", {value: name});
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user