diff --git a/edit.html b/edit.html index 54e07390..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: "*"; @@ -443,6 +443,71 @@ } + + + + + + + + + + + diff --git a/edit.js b/edit.js index 7ad00314..4dd08fa9 100644 --- a/edit.js +++ b/edit.js @@ -10,79 +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"}; -var template = { -appliesTo: '\ -
  • \ - \ - \ - \ - \ -
  • \ - ', -appliesToEverything: '\ -
  • \ - \ -
  • \ - ', -section: '\ -
    \ - \ - \ -
    \ -
    \ - \ - \ -
    \ - \ - \ - \ -
    \ - ', -find: '\ - : \ -  \ - ()\ - \ - ', -replace: '\ - : \ -  \ - ()\ - \ - ', -replaceAll: '\ - : \ -  \ - ()\ - \ - ', -replaceWith: '\ - : \ - \ - \ - ', -replaceConfirm: '\ - ? \ -  \ -  \ - \ - \ - ', -jumpToLine: '\ - : \ - \ - \ - ' -} -Object.keys(template).forEach(function(name) { template[name] = tHTML(template[name]); }); - // make querySelectorAll enumeration code readable ["forEach", "some", "indexOf"].forEach(function(method) { NodeList.prototype[method]= Array.prototype[method]; 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";