diff --git a/_locales/en/messages.json b/_locales/en/messages.json index bf57d82a..a5b09863 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -96,10 +96,18 @@ "message": "Tab size", "description": "Label for the text box controlling tab size option for the style editor." }, + "cm_theme": { + "message": "Theme", + "description": "Label for the style editor's CSS theme." + }, "dbError": { "message": "An error has occurred using the Stylish database. Would you like to visit a web page with possible solutions?", "description": "Prompt when a DB error is encountered" }, + "defaultTheme": { + "message": "default", + "description": "Default CodeMirror CSS theme option on the edit style page" + }, "deleteStyleLabel": { "message": "Delete", "description": "Label for the button to delete a style" diff --git a/apply.js b/apply.js index 64fe523e..cc8fc8a0 100644 --- a/apply.js +++ b/apply.js @@ -1,7 +1,18 @@ -var request = {method: "getStyles", matchUrl: location.href, enabled: true, asHash: true}; -if (location.href.indexOf(chrome.extension.getURL("")) == 0) { - chrome.extension.getBackgroundPage().getStyles(request, applyStyles); -} else { +requestStyles(); + +function requestStyles() { + // If this is a Stylish page (Edit Style or Manage Styles), + // we'll request the styles directly to minimize delay and flicker, + // unless Chrome still starts up and the background page isn't fully loaded. + // (Note: in this case the function may be invoked again from applyStyles.) + var request = {method: "getStyles", matchUrl: location.href, enabled: true, asHash: true}; + if (location.href.indexOf(chrome.extension.getURL("")) == 0) { + var bg = chrome.extension.getBackgroundPage(); + if (bg && bg.getStyles) { + bg.getStyles(request, applyStyles); + return; + } + } chrome.extension.sendMessage(request, applyStyles); } @@ -63,6 +74,10 @@ function removeStyle(id, doc) { } function applyStyles(styleHash) { + if (!styleHash) { // Chrome is starting up + requestStyles(); + return; + } if ("disableAll" in styleHash) { disableAll(styleHash.disableAll); delete styleHash.disableAll; diff --git a/background.js b/background.js index fe199f13..8ad9d131 100644 --- a/background.js +++ b/background.js @@ -392,3 +392,8 @@ function openURL(options) { } }); } + +var codeMirrorThemes; +getCodeMirrorThemes(function(themes) { + codeMirrorThemes = themes; +}); diff --git a/edit.html b/edit.html index 60f6100f..f26b2521 100644 --- a/edit.html +++ b/edit.html @@ -276,12 +276,25 @@ #sections > *:not(h2) { padding-left: 0.4rem; } + .applies-type { + width: 30%; + } + } + @media(max-width:500px) { + #options { + -webkit-column-count: 1; + } + #options #tabSize-label { + position: static; + } } + +