[Pkg-mozext-commits] [requestpolicy] 07/100: Update Manage Policies page to use jQuery to create the table rows. It is already included so we might as well use it.

David Prévot taffit at moszumanska.debian.org
Fri Dec 12 22:56:46 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 7b6878a8fcde20fee4600c03c20103f38641d432
Author: Christopher Bura <christopher.bura at gmail.com>
Date:   Tue Sep 2 02:34:55 2014 -0400

    Update Manage Policies page to use jQuery to create the table rows. It is already included so we might as well use it.
---
 src/content/settings/settings.css         | 142 +++++++++++++-----------------
 src/content/settings/yourpolicy.html      |  38 ++++----
 src/content/settings/yourpolicy.js        |  68 ++++++--------
 src/locale/de/requestpolicy.properties    |   3 +
 src/locale/en-US/requestpolicy.properties |   3 +
 src/locale/eo/requestpolicy.properties    |   4 +-
 src/locale/es-MX/requestpolicy.properties |   3 +
 src/locale/eu/requestpolicy.properties    |   3 +
 src/locale/fr/requestpolicy.properties    |   3 +
 src/locale/it/requestpolicy.properties    |   3 +
 src/locale/ja/requestpolicy.properties    |   3 +
 src/locale/ko-KR/requestpolicy.properties |   3 +
 src/locale/lv-LV/requestpolicy.properties |   3 +
 src/locale/nl/requestpolicy.properties    |   3 +
 src/locale/pt-BR/requestpolicy.properties |   3 +
 src/locale/ru-RU/requestpolicy.properties |   3 +
 src/locale/sk-SK/requestpolicy.properties |   3 +
 src/locale/sv-SE/requestpolicy.properties |   3 +
 src/locale/tr/requestpolicy.properties    |   3 +
 src/locale/uk-UA/requestpolicy.properties |   3 +
 src/locale/zh-CN/requestpolicy.properties |   3 +
 src/locale/zh-TW/requestpolicy.properties |   3 +
 22 files changed, 163 insertions(+), 143 deletions(-)

diff --git a/src/content/settings/settings.css b/src/content/settings/settings.css
index 89b25cd..a0f36ca 100644
--- a/src/content/settings/settings.css
+++ b/src/content/settings/settings.css
@@ -150,86 +150,6 @@ table.settings tr:not(:first-child) {
   margin-top: 10px;
 }
 
-table.policy {
-  table-layout: fixed;
-}
-.policyheader #policysearch {
-  float: right;
-}
-table.policy th {
-  text-align: left;
-  vertical-align: bottom;
-  font-weight: bold;
-  font-size: 0.95em;
-  padding-bottom: 10px;
-  padding-left: 10px;
-  padding-top: 10px;
-}
-table.policy th:first-child {
-  padding-left: 10px;
-}
-table.policy th:last-child input {
-  margin-bottom: 0;
-}
-table.policy td {
-  padding-top: 11px;
-  padding-bottom: 11px;
-  overflow: hidden;
-  word-wrap: break-word;
-  padding-left: 10px;
-}
-table.policy td:first-child {
-  padding-left: 10px;
-  padding-right: 10px;
-}
-table.policy td:nth-child(2) {
-  padding-right: 10px;
-}
-table.policy td:nth-child(3) {
-  padding-right: 10px;
-}
-table.policy td:first-child {
-  padding-left: 10px;
-}
-table.policy td:last-child {
-  text-align: right;
-  width: 30px;
-}
-.policydata table.policy tr:hover {
-  background-color: #EAF2FC;
-  cursor: default;
-}
-table.policy col.type {
-  width: 100px;
-}
-table.policy col.origin {
-  width: 300px;
-}
-table.policy col.destination {
-}
-table.policy a.deleterule {
-  color: rgba(255, 255, 255, 0);
-  text-decoration: none;
-  padding: 10px;
-  font-weight: bold;
-  font-size: 0.95em;
-  outline: none;
-}
-table.policy tr:hover a.deleterule {
-  display: inline;
-  color: #aaa;
-}
-table.policy tr:hover a.deleterule:hover {
-  color: #000;
-}
-
-.policydata {
-  overflow-y: auto;
-  overflow-x: auto;
-  max-height: 400px;
-  border: 1px solid #ddd;
-}
-
 #addrule {
   border: 1px solid #ddd;
   border-radius: 4px;
@@ -268,6 +188,68 @@ table.policy tr:hover a.deleterule:hover {
 
 /* yourpolicy.html */
 
+#policysearch {
+  text-align: right;
+  color: #A6B2A9;
+}
+
+#policy-user {
+  table-layout: fixed;
+}
+
+#policy-user th {
+  text-align: left;
+}
+
+#policy-user tbody {
+  max-height: 400px;
+  border: 1px solid #ddd;
+}
+
+#policy-user tbody td,
+#policy-user thead th {
+  padding: 10px;
+  overflow: hidden;
+  word-wrap: break-word;
+}
+
+#policy-user col.type {
+  width: 100px;
+}
+
+#policy-user col.source {
+  width: 150px;
+}
+
+#policy-user col.remove {
+  width: 50px;
+}
+
+#policy-user tbody td.remove {
+  text-align: right;
+}
+
+a.deleterule {
+  color: rgba(255, 255, 255, 0);
+  text-decoration: none;
+  font-weight: bold;
+  font-size: 0.95em;
+  outline: none;
+}
+
+#policy-user tbody tr:hover {
+  background-color: #EAF2FC;
+}
+
+#policy-user tr:hover a.deleterule {
+  display: inline;
+  color: #aaa;
+}
+
+#policy-user tr:hover a.deleterule:hover {
+  color: #000;
+}
+
 .policy-table-options {
   padding: 10px;
   color: #A6B2A9;
diff --git a/src/content/settings/yourpolicy.html b/src/content/settings/yourpolicy.html
index 5dbcd17..c007d57 100644
--- a/src/content/settings/yourpolicy.html
+++ b/src/content/settings/yourpolicy.html
@@ -39,34 +39,28 @@
         <div>
           <div class="policyheader">
             <div id="policysearch">
+              <label for="rulesearch" data-string="filterRules"></label>
               <input type="search" id="rulesearch"/>
             </div>
-            <table class="policy">
-              <colgroup>
-                <col class="type"/>
-                <col class="origin"/>
-                <col class="destination"/>
-                <col class="source"/>
-                <col class="remove"/>
-              </colgroup>
-              <tr>
-                <th data-string="type"></th>
-                <th data-string="origin"></th>
-                <th data-string="destination"></th>
-                <th data-string="source"></th>
-                <th data-string="remove"></th>
-              </tr>
-            </table>
           </div>
           <div class="policydata">
             <table id="policy-user" class="policy">
               <colgroup>
-                <col class="type"/>
-                <col class="origin"/>
-                <col class="destination"/>
-                <col class="source"/>
-                <col class="remove"/>
+                <col class="type">
+                <col class="origin">
+                <col class="destination">
+                <col class="source">
+                <col class="remove">
               </colgroup>
+              <thead>
+                <tr>
+                  <th data-string="type"></th>
+                  <th data-string="origin"></th>
+                  <th data-string="destination"></th>
+                  <th data-string="source"></th>
+                  <th data-string="remove"></th>
+                </tr>
+              </thead>
               <tbody id="rules"></tbody>
             </table>
           </div>
@@ -75,7 +69,7 @@
 
       <div class="policy-table-options">
         <form>
-          <label for="highlight_rows">Highlight Rule Types</label>
+          <label for="highlight_rows" data-string="highlightRules"></label>
           <input type="checkbox" id="highlight_rows">
         </form>
       </div>
diff --git a/src/content/settings/yourpolicy.js b/src/content/settings/yourpolicy.js
index 1dc1a46..284a3ed 100644
--- a/src/content/settings/yourpolicy.js
+++ b/src/content/settings/yourpolicy.js
@@ -10,7 +10,10 @@ PAGE_STRINGS = [
   'temporary',
   'addRule',
   'learnMoreAboutRules',
-  'removeOldRules'
+  'removeOldRules',
+  'source',
+  'highlightRules',
+  'filterRules'
 ];
 
 $(function () {
@@ -46,7 +49,7 @@ function populateRuleTable(filter) {
 
   var policyMgr = rpService._policyMgr;
 
-  var table = document.getElementById('policy-user');
+  var table = document.getElementById('rules');
 
   clearPolicyTable(table);
 
@@ -63,7 +66,7 @@ function populateRuleTable(filter) {
 }
 
 function addPolicies(entries, source, filter) {
-  var table = document.getElementById('policy-user');
+  var table = $('#rules');
   for (var entry_type in entries) {
     for (var i = 0; i < entries[entry_type].length; i++) {
       var entry = entries[entry_type][i];
@@ -79,19 +82,6 @@ function addPolicies(entries, source, filter) {
   }
 }
 
-function deleteRule(event) {
-  var anchor = event.target;
-  var ruleType = anchor.requestpolicyRuleType;
-  var ruleData = anchor.requestpolicyRuleData;
-  if (ruleType == 'allow') {
-    rpService.removeAllowRule(ruleData);
-  } else {
-    rpService.removeDenyRule(ruleData);
-  }
-  var row = anchor.parentNode.parentNode;
-  row.parentNode.removeChild(row);
-}
-
 function clearPolicyTable(table) {
   var children = table.getElementsByTagName('tr');
   while (children.length) {
@@ -101,33 +91,31 @@ function clearPolicyTable(table) {
 }
 
 function addPolicyTableRow(table, type, origin, dest, ruleData, source) {
-  var rowCount = table.rows.length;
-  var row = table.insertRow(rowCount);
 
   var type_class = type == 'allow' ? 'allow' : 'block';
-  row.setAttribute('class', type_class);
-
-  var typeCell = row.insertCell(0);
-  typeCell.textContent = type == 'allow' ? 'Allow' : 'Block';
-
-  var originCell = row.insertCell(1);
-  originCell.textContent = origin;
-
-  var destCell = row.insertCell(2);
-  destCell.textContent = dest;
-
-  // Source Cell
-  var sourceCell = row.insertCell(3);
-  sourceCell.textContent = source;
+  var rule_type = type == 'allow' ? _('allow') : _('block');
+
+  var row = $('<tr>').addClass(type_class).appendTo(table);
+
+  row.append(
+    $('<td>').text(rule_type).addClass('type'),
+    $('<td>').text(origin),
+    $('<td>').text(dest),
+    $('<td>').text(source)
+  );
+
+  var anchor = $('<a>');
+  anchor.text('X').addClass('deleterule');
+  anchor.click(function () {
+    if (type == 'allow') {
+      rpService.removeAllowRule(ruleData);
+    } else {
+      rpService.removeDenyRule(ruleData);
+    }
+    row.remove();
+  });
 
-  var removeCell = row.insertCell(4);
-  var anchor = document.createElement('a');
-  anchor.appendChild(document.createTextNode('X'));
-  anchor.setAttribute('class', 'deleterule');
-  anchor.setAttribute('onclick', 'deleteRule(event);');
-  anchor.requestpolicyRuleType = type;
-  anchor.requestpolicyRuleData = ruleData;
-  removeCell.appendChild(anchor);
+  row.append($('<td>').append(anchor).addClass('remove'));
 }
 
 // TODO: remove code duplication with menu.js
diff --git a/src/locale/de/requestpolicy.properties b/src/locale/de/requestpolicy.properties
index f4bab62..9eeb7a6 100644
--- a/src/locale/de/requestpolicy.properties
+++ b/src/locale/de/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/en-US/requestpolicy.properties b/src/locale/en-US/requestpolicy.properties
index 7f4ffc4..c9c4ee1 100644
--- a/src/locale/en-US/requestpolicy.properties
+++ b/src/locale/en-US/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/eo/requestpolicy.properties b/src/locale/eo/requestpolicy.properties
index 33a8f86..a3b3736 100644
--- a/src/locale/eo/requestpolicy.properties
+++ b/src/locale/eo/requestpolicy.properties
@@ -102,4 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
-s
\ No newline at end of file
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/es-MX/requestpolicy.properties b/src/locale/es-MX/requestpolicy.properties
index c671c94..212170d 100644
--- a/src/locale/es-MX/requestpolicy.properties
+++ b/src/locale/es-MX/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/eu/requestpolicy.properties b/src/locale/eu/requestpolicy.properties
index 153c385..ca4fb25 100644
--- a/src/locale/eu/requestpolicy.properties
+++ b/src/locale/eu/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/fr/requestpolicy.properties b/src/locale/fr/requestpolicy.properties
index 3d4b13b..36ac83e 100644
--- a/src/locale/fr/requestpolicy.properties
+++ b/src/locale/fr/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/it/requestpolicy.properties b/src/locale/it/requestpolicy.properties
index a7c31aa..3c38192 100644
--- a/src/locale/it/requestpolicy.properties
+++ b/src/locale/it/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/ja/requestpolicy.properties b/src/locale/ja/requestpolicy.properties
index c5163a8..8731c07 100644
--- a/src/locale/ja/requestpolicy.properties
+++ b/src/locale/ja/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/ko-KR/requestpolicy.properties b/src/locale/ko-KR/requestpolicy.properties
index 6cec756..f4cc018 100644
--- a/src/locale/ko-KR/requestpolicy.properties
+++ b/src/locale/ko-KR/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/lv-LV/requestpolicy.properties b/src/locale/lv-LV/requestpolicy.properties
index 9060e79..67408ee 100644
--- a/src/locale/lv-LV/requestpolicy.properties
+++ b/src/locale/lv-LV/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/nl/requestpolicy.properties b/src/locale/nl/requestpolicy.properties
index e79a102..8c4bddd 100644
--- a/src/locale/nl/requestpolicy.properties
+++ b/src/locale/nl/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/pt-BR/requestpolicy.properties b/src/locale/pt-BR/requestpolicy.properties
index 9720954..47c432e 100644
--- a/src/locale/pt-BR/requestpolicy.properties
+++ b/src/locale/pt-BR/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/ru-RU/requestpolicy.properties b/src/locale/ru-RU/requestpolicy.properties
index b379f48..444c975 100644
--- a/src/locale/ru-RU/requestpolicy.properties
+++ b/src/locale/ru-RU/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/sk-SK/requestpolicy.properties b/src/locale/sk-SK/requestpolicy.properties
index 34804cc..7935c70 100644
--- a/src/locale/sk-SK/requestpolicy.properties
+++ b/src/locale/sk-SK/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/sv-SE/requestpolicy.properties b/src/locale/sv-SE/requestpolicy.properties
index 13a6217..f7df7a3 100644
--- a/src/locale/sv-SE/requestpolicy.properties
+++ b/src/locale/sv-SE/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/tr/requestpolicy.properties b/src/locale/tr/requestpolicy.properties
index 7f5ce70..789da47 100644
--- a/src/locale/tr/requestpolicy.properties
+++ b/src/locale/tr/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/uk-UA/requestpolicy.properties b/src/locale/uk-UA/requestpolicy.properties
index 9b91025..a3307a5 100644
--- a/src/locale/uk-UA/requestpolicy.properties
+++ b/src/locale/uk-UA/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/zh-CN/requestpolicy.properties b/src/locale/zh-CN/requestpolicy.properties
index d136666..7bce560 100644
--- a/src/locale/zh-CN/requestpolicy.properties
+++ b/src/locale/zh-CN/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=导入旧规则
 deleteOldRules=删除旧规则
 showOldRuleReimportOptions=显示重新导入选项
 yourOldRulesHaveBeenDeleted=旧规则已删除.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules
diff --git a/src/locale/zh-TW/requestpolicy.properties b/src/locale/zh-TW/requestpolicy.properties
index 8d3370b..28de510 100644
--- a/src/locale/zh-TW/requestpolicy.properties
+++ b/src/locale/zh-TW/requestpolicy.properties
@@ -102,3 +102,6 @@ importOldRules=Import Old Rules
 deleteOldRules=Delete old rules
 showOldRuleReimportOptions=Show re-import options.
 yourOldRulesHaveBeenDeleted=Done! Your old rules have been deleted.
+source=Source
+highlightRules=Highlight Rules
+filterRules=Filter Rules

-- 
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