From 328b992969057cb643ac6e68ad76f7a98b064ba2 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Thu, 14 Jul 2011 22:01:44 +1000 Subject: [PATCH] Restore most of :style list filtering and clarify docs. Closes issue #540. --- common/locale/en-US/styling.xml | 11 ++++++++--- common/modules/styles.jsm | 6 ++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/common/locale/en-US/styling.xml b/common/locale/en-US/styling.xml index f8ef5b54..fd6e1ffd 100644 --- a/common/locale/en-US/styling.xml +++ b/common/locale/en-US/styling.xml @@ -282,7 +282,11 @@ :sty :style - :style -name=name -append filter css + + :style -name=name -group=name -agent filter css + :style -name=name -append filter css + :style -name=name -group=name filter +

Add CSS styles to the browser or to web pages. filter is a @@ -295,8 +299,9 @@

The following options are available:

-append
-
If provided along with -name, css and - filter are appended to its current value. (short name -a)
+
If provided along with -name, css and + filter are appended to its current value. (short name + -a)
-agent
If provided, the style is installed as an Agent sheet, which diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm index 469d6a5d..d5a4df98 100644 --- a/common/modules/styles.jsm +++ b/common/modules/styles.jsm @@ -299,13 +299,15 @@ var Styles = Module("Styles", { systemNames: Class.Property({ get: deprecated("Styles#system.names", function systemNames() this.system.names) }), sites: Class.Property({ get: deprecated("Styles#user.sites", function sites() this.user.sites) }), - list: function list(content, filter, name, hives) { + list: function list(content, sites, name, hives) { const { commandline, dactyl } = this.modules; hives = hives || styles.hives.filter(function (h) h.modifiable && h.sheets.length); function sheets(group) group.sheets.slice() + .filter(function (sheet) (!name || sheet.name === name) && + (!sites || sites.every(function (s) sheet.sites.indexOf(s) >= 0))) .sort(function (a, b) a.name && b.name ? String.localeCompare(a.name, b.name) : !!b.name - !!a.name || a.id - b.id); @@ -560,7 +562,7 @@ var Styles = Module("Styles", { let [filter, css] = args; if (!css) - styles.list(window.content, filter, args["-name"], args.explicitOpts["-group"] ? [args["-group"]] : null); + styles.list(window.content, filter ? filter.split(",") : null, args["-name"], args.explicitOpts["-group"] ? [args["-group"]] : null); else { util.assert(args["-group"].modifiable && args["-group"].hive.modifiable, _("group.cantChangeBuiltin", _("style.styles")));