[Pkg-mozext-commits] [requestpolicy] 14/100: Revert back to having single deleteRule function instead of attaching a new one to each click()
David Prévot
taffit at moszumanska.debian.org
Fri Dec 12 22:56:48 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit f89fe2ff0aa5a3e027f8a9c8082dfca2aafb6f9b
Author: Christopher Bura <christopher.bura at gmail.com>
Date: Wed Sep 3 16:01:08 2014 -0400
Revert back to having single deleteRule function instead of attaching a new one to each click()
See
https://github.com/RequestPolicyContinued/requestpolicy/pull/459#issuecomment-54340418
---
src/content/settings/yourpolicy.js | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/content/settings/yourpolicy.js b/src/content/settings/yourpolicy.js
index eec6dea..9015dd3 100644
--- a/src/content/settings/yourpolicy.js
+++ b/src/content/settings/yourpolicy.js
@@ -79,6 +79,18 @@ function addPolicies(entries, source, filter, read_only) {
}
}
+function deleteRule(event) {
+ var anchor = $(event.target);
+ var ruleType = anchor.data('requestpolicyRuleType');
+ var ruleData = anchor.data('requestpolicyRuleData');
+ if (ruleType == 'allow') {
+ rpService.removeAllowRule(ruleData);
+ } else {
+ rpService.removeDenyRule(ruleData);
+ }
+ anchor.closest('tr').remove();
+}
+
function clearPolicyTable(table) {
var children = table.getElementsByTagName('tr');
while (children.length) {
@@ -104,15 +116,9 @@ function addPolicyTableRow(table, type, origin, dest, ruleData, source, read_onl
if (!read_only) {
var anchor = $('<a>');
anchor.text('x').addClass('deleterule');
- anchor.click(function () {
- if (type == 'allow') {
- rpService.removeAllowRule(ruleData);
- } else {
- rpService.removeDenyRule(ruleData);
- }
- row.remove();
- });
-
+ anchor.data('requestpolicyRuleType', type);
+ anchor.data('requestpolicyRuleData', ruleData);
+ anchor.click(deleteRule);
row.append($('<td>').append(anchor));
} else {
row.append($('<td>'));
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list