diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index b594d71f..580ef244 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -100,6 +100,18 @@
"message": "Theme",
"description": "Label for the style editor's CSS theme."
},
+ "confirmNo": {
+ "message": "No",
+ "description": "'No' button in a confirm dialog"
+ },
+ "confirmStop": {
+ "message": "Stop",
+ "description": "'Stop' button in a confirm dialog"
+ },
+ "confirmYes": {
+ "message": "Yes",
+ "description": "'Yes' button in a confirm dialog"
+ },
"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"
@@ -229,6 +241,18 @@
"message": "Show number of styles active for the current site on the toolbar button",
"description": "Label for the checkbox controlling toolbar badge text."
},
+ "replace": {
+ "message": "Replace",
+ "description": "Label before the replace input field in the editor shown on Ctrl-H"
+ },
+ "replaceAll": {
+ "message": "Replace all",
+ "description": "Label before the replace input field in the editor shown on 'replaceAll' hotkey"
+ },
+ "replaceWith": {
+ "message": "Replace with",
+ "description": "Label before the replace-with input field in the editor shown on Ctrl-H etc."
+ },
"search": {
"message": "Search",
"description": "Label before the search input field in the editor shown on Ctrl-F"
diff --git a/edit.html b/edit.html
index 680fb56e..8542773c 100644
--- a/edit.html
+++ b/edit.html
@@ -125,7 +125,7 @@
display: none;
}
#sections > div > button:not(:first-of-type) {
- margin-left: 0.4rem;
+ margin-left: 0.2rem;
}
.dirty > label::before {
content: "*";
@@ -153,19 +153,28 @@
.CodeMirror-vscrollbar {
margin-bottom: 8px; /* make space for resize-grip */
}
- .CodeMirror-search-field, .CodeMirror-jump-field {
+ .CodeMirror-dialog {
-webkit-animation: highlight 3s ease-out;
}
.CodeMirror-focused {
outline: -webkit-focus-ring-color auto 5px;
outline-offset: -2px;
}
+ .CodeMirror-search-field {
+ width: 10em;
+ }
+ .CodeMirror-jump-field {
+ width: 5em;
+ }
+ .CodeMirror-search-hint {
+ color: #888;
+ }
@-webkit-keyframes highlight {
from {
background-color: #ff9;
}
to {
- background-color: transparent;
+ background-color: none;
}
}
.resize-grip {
@@ -434,6 +443,71 @@
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ :
+ ()
+
+
+
+ :
+ ()
+
+
+
+ :
+ ()
+
+
+
+ :
+
+
+
+ ?
+
+
+
+
+
+
+ :
+
+
diff --git a/edit.js b/edit.js
index d1cf8b61..894e463d 100644
--- a/edit.js
+++ b/edit.js
@@ -10,49 +10,6 @@ var useHistoryBack; // use browser history back when "back to manage" is click
var propertyToCss = {urls: "url", urlPrefixes: "url-prefix", domains: "domain", regexps: "regexp"};
var CssToProperty = {"url": "urls", "url-prefix": "urlPrefixes", "domain": "domains", "regexp": "regexps"};
-// templates
-var appliesToTemplate = tHTML('\
-
\
- \
- \
- \
- \
- \
-');
-
-var appliesToEverythingTemplate = tHTML('\
- \
- \
- \
-');
-
-var sectionTemplate = tHTML('\
- \
-
\
-
\
-
\
-
\
-
\
-
\
-
\
-
\
-
\
-
\
-
\
-');
-
-var findTemplate = t("search") + ': ' +
- '(' + t("searchRegexp") + ')';
-
-var jumpToLineTemplate = t('editGotoLine') + ': ';
-
// make querySelectorAll enumeration code readable
["forEach", "some", "indexOf"].forEach(function(method) {
NodeList.prototype[method]= Array.prototype[method];
@@ -61,6 +18,12 @@ var jumpToLineTemplate = t('editGotoLine') + ': = 0) {
+ if (dlg) {
+ dlg.remove();
+ }
+ doReplace();
+ }
+ }
+ });
+ originalOpenConfirm.call(cm, template.replaceConfirm.innerHTML, ovrCallbacks, opt);
+ };
+ }
+ }
+
+ function replaceAll(cm) {
+ replace(cm, true);
+ }
+
CodeMirror.commands.find = find;
CodeMirror.commands.findNext = findNext;
CodeMirror.commands.findPrev = findPrev;
+ CodeMirror.commands.replace = replace;
+ CodeMirror.commands.replaceAll = replaceAll;
}
function jumpToLine(cm) {
var cur = cm.getCursor();
- cm.openDialog(jumpToLineTemplate, function(str) {
+ cm.openDialog(template.jumpToLine.innerHTML, function(str) {
var m = str.match(/^\s*(\d+)(?:\s*:\s*(\d+))?\s*$/);
if (m) {
cm.setCursor(m[1] - 1, m[2] ? m[2] - 1 : cur.ch);
@@ -961,6 +1013,7 @@ function init() {
return;
}
// This is an edit
+ tE("heading", "editStyleHeading", null, false);
requestStyle();
function requestStyle() {
chrome.extension.sendMessage({method: "getStyles", id: params.id}, function callback(styles) {
@@ -979,7 +1032,6 @@ function initWithStyle(style) {
document.getElementById("name").value = style.name;
document.getElementById("enabled").checked = style.enabled == "true";
document.getElementById("url").href = style.url;
- tE("heading", "editStyleHeading", null, false);
// if this was done in response to an update, we need to clear existing sections
document.querySelectorAll("#sections > div").forEach(function(div) {
div.parentNode.removeChild(div);
@@ -1087,7 +1139,7 @@ function validate() {
// validate the regexps
if (document.querySelectorAll(".applies-to-list").some(function(list) {
return list.childNodes.some(function(li) {
- if (li.className == appliesToEverythingTemplate.className) {
+ if (li.className == template.appliesToEverything.className) {
return false;
}
var valueElement = li.querySelector("[name=applies-value]");
@@ -1153,7 +1205,7 @@ function getSections() {
function getMeta(e) {
var meta = {};
e.querySelector(".applies-to-list").childNodes.forEach(function(li) {
- if (li.className == appliesToEverythingTemplate.className) {
+ if (li.className == template.appliesToEverything.className) {
return;
}
var type = li.querySelector("[name=applies-type]").value;
@@ -1173,6 +1225,7 @@ function saveComplete(style) {
// Go from new style URL to edit style URL
if (location.href.indexOf("id=") == -1) {
history.replaceState({}, document.title, "edit.html?id=" + style.id);
+ tE("heading", "editStyleHeading", null, false);
}
updateTitle();
}
diff --git a/localization.js b/localization.js
index e758fdc2..23871ab6 100644
--- a/localization.js
+++ b/localization.js
@@ -1,3 +1,4 @@
+var template = {};
tDocLoader();
function t(key, params) {
@@ -35,6 +36,11 @@ function tNodeList(nodes) {
if (node.nodeType != 1) { // not an ELEMENT_NODE
continue;
}
+ if (node.localName == "template") {
+ tNodeList(node.content.querySelectorAll("*"));
+ template[node.dataset.id] = node.content.firstElementChild;
+ continue;
+ }
for (var a = node.attributes.length - 1; a >= 0; a--) {
var attr = node.attributes[a];
var name = attr.nodeName;
diff --git a/manage.html b/manage.html
index 58da0dec..735b3056 100644
--- a/manage.html
+++ b/manage.html
@@ -46,9 +46,6 @@
.applies-to, .actions {
padding-left: 15px;
}
- .actions > * {
- margin-right: 5px;
- }
.applies-to-extra {
font-weight: bold;
}
@@ -129,6 +126,23 @@
}
+
+
+
+
+
diff --git a/manage.js b/manage.js
index 3e67b9d4..2814ba6e 100644
--- a/manage.js
+++ b/manage.js
@@ -1,19 +1,3 @@
-var styleTemplate = tHTML('\
- \
-
\
-
\
-
\
- \
- \
- \
- \
- \
- \
- \
-
\
-
\
-');
-
var lastUpdatedStyleId = null;
var installed;
@@ -44,7 +28,7 @@ function showStyles(styles) {
}
function createStyleElement(style) {
- var e = styleTemplate.cloneNode(true);
+ var e = template.style.cloneNode(true);
e.setAttribute("class", style.enabled == "true" ? "enabled" : "disabled");
e.setAttribute("style-id", style.id);
if (style.updateUrl) {
diff --git a/popup.html b/popup.html
index 0c04796b..1ca5579d 100644
--- a/popup.html
+++ b/popup.html
@@ -61,7 +61,7 @@
text-decoration: line-through;
}
#installed .actions a {
- margin-right: 0.5em;
+ margin-right: 0.2em;
}
body > .actions {
margin-top: 0.5em;
@@ -115,7 +115,7 @@
.breadcrumbs > .write-style-link:last-child::before {content: "\200b/"}
.breadcrumbs > .write-style-link:last-child:first-child::before,
.breadcrumbs > .write-style-link[subdomain=""] + .write-style-link::before {content: none}
-
+
/* suppress TLD-only link */
.breadcrumbs > .write-style-link[subdomain=""] {display: none}
@@ -130,6 +130,23 @@
}
+
+
+
+
diff --git a/popup.js b/popup.js
index 761b25ec..7b02eeda 100644
--- a/popup.js
+++ b/popup.js
@@ -1,20 +1,3 @@
-var styleTemplate = tHTML('\
- \
-');
-
var writeStyleTemplate = document.createElement("a");
writeStyleTemplate.className = "write-style-link";
@@ -102,7 +85,7 @@ function showStyles(styles) {
}
function createStyleElement(style) {
- var e = styleTemplate.cloneNode(true);
+ var e = template.style.cloneNode(true);
var checkbox = e.querySelector(".checker");
checkbox.id = "style-" + style.id;
checkbox.checked = style.enabled == "true";