diff --git a/js/CommonFilters.js b/js/CommonFilters.js index 97a676c98..fb2061ea3 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -282,24 +282,10 @@ define(["dojo/_base/declare"], function (declare) { Filters.editFilterTest(query); }, selectRules: function (select) { - $$("#filterDlg_Matches input[type=checkbox]").each(function (e) { - e.checked = select; - if (select) - e.parentNode.addClassName("Selected"); - else - e.parentNode.removeClassName("Selected"); - }); + Lists.select("filterDlg_Matches", select); }, selectActions: function (select) { - $$("#filterDlg_Actions input[type=checkbox]").each(function (e) { - e.checked = select; - - if (select) - e.parentNode.addClassName("Selected"); - else - e.parentNode.removeClassName("Selected"); - - }); + Lists.select("filterDlg_Actions", select); }, editRule: function (e) { const li = e.parentNode; diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index f4fc8ecf2..4d4ee52ca 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -153,24 +153,10 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio Filters.editFilterTest(query); }, selectRules: function (select) { - $$("#filterDlg_Matches input[type=checkbox]").each(function (e) { - e.checked = select; - if (select) - e.parentNode.addClassName("Selected"); - else - e.parentNode.removeClassName("Selected"); - }); + Lists.select("filterDlg_Matches", select); }, selectActions: function (select) { - $$("#filterDlg_Actions input[type=checkbox]").each(function (e) { - e.checked = select; - - if (select) - e.parentNode.addClassName("Selected"); - else - e.parentNode.removeClassName("Selected"); - - }); + Lists.select("filterDlg_Actions", select); }, editRule: function (e) { const li = e.parentNode; diff --git a/js/common.js b/js/common.js index 427e3034c..150288bc2 100755 --- a/js/common.js +++ b/js/common.js @@ -56,7 +56,23 @@ const Lists = { if (row) checked ? row.addClassName("Selected") : row.removeClassName("Selected"); - } + }, + select: function(elemId, selected) { + $(elemId).select("li").each((row) => { + const checkNode = row.select(".dijitCheckBox,input[type=checkbox]")[0]; + if (checkNode) { + const widget = dijit.getEnclosingWidget(checkNode); + + if (widget) { + widget.attr("checked", selected); + } else { + checkNode.checked = selected; + } + + this.onRowChecked(widget); + } + }); + }, }; // noinspection JSUnusedGlobalSymbols