Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: chrome/content/ui/composer.js

Issue 29329473: Issue 3222 - Don`t do localization in the contentPolicy module (Closed)
Left Patch Set: Created Oct. 29, 2015, 1:25 p.m.
Right Patch Set: Addressed comments Created Nov. 5, 2015, 3:45 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | chrome/content/ui/sidebar.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 { 111 {
112 // IOService returned nsIURI - not much we can do with it 112 // IOService returned nsIURI - not much we can do with it
113 addSuggestion(item.location); 113 addSuggestion(item.location);
114 E("patternGroup").value = ""; 114 E("patternGroup").value = "";
115 } 115 }
116 if (Prefs.composer_default == 0) 116 if (Prefs.composer_default == 0)
117 E("customPattern").focus(); 117 E("customPattern").focus();
118 else 118 else
119 E("patternGroup").focus(); 119 E("patternGroup").focus();
120 120
121 let types = []; 121 let types = Array.from(Policy.contentTypes);
122 for (let type of Policy.contentTypes)
123 types.push([type, Utils.getString("type_label_" + type.toLowerCase())]);
124 types.sort(); 122 types.sort();
tschuster 2015/11/05 15:06:15 Seems like sorting [type, label] could be differen
Wladimir Palant 2015/11/05 15:47:11 It actually is the same, due to the way arrays are
125 123
126 let docDomain = item.docDomain; 124 let docDomain = item.docDomain;
127 let thirdParty = item.thirdParty; 125 let thirdParty = item.thirdParty;
128 126
129 if (docDomain) 127 if (docDomain)
130 docDomain = docDomain.replace(/^www\./i, "").replace(/\.+$/, ""); 128 docDomain = docDomain.replace(/^www\./i, "").replace(/\.+$/, "");
131 if (docDomain) 129 if (docDomain)
132 E("domainRestriction").value = docDomain; 130 E("domainRestriction").value = docDomain;
133 131
134 E("thirdParty").hidden = !thirdParty; 132 E("thirdParty").hidden = !thirdParty;
135 E("firstParty").hidden = thirdParty; 133 E("firstParty").hidden = thirdParty;
136 134
137 let typeGroup = E("typeGroup"); 135 let typeGroup = E("typeGroup");
138 let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap. DOCUMENT; 136 let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap. DOCUMENT;
139 let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) != 0 ; 137 let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) != 0 ;
140 for (let [type, label] of types) 138 for (let type of types)
141 { 139 {
142 if (type == "ELEMHIDE") 140 if (type == "ELEMHIDE")
143 continue; 141 continue;
144 142
145 let typeNode = document.createElement("checkbox"); 143 let typeNode = document.createElement("checkbox");
146 typeNode.setAttribute("value", type.toLowerCase().replace(/\_/g, "-")); 144 typeNode.setAttribute("value", type.toLowerCase().replace(/\_/g, "-"));
147 typeNode.setAttribute("label", label); 145 typeNode.setAttribute("label", Utils.getString("type_label_" + type.toLowerC ase()));
148 146
149 let typeMask = RegExpFilter.typeMap[type]; 147 let typeMask = RegExpFilter.typeMap[type];
150 typeNode._defaultType = (typeMask & defaultTypes) != 0; 148 typeNode._defaultType = (typeMask & defaultTypes) != 0;
151 if ((isDefaultType && typeNode._defaultType) || (!isDefaultType && item.type == type)) 149 if ((isDefaultType && typeNode._defaultType) || (!isDefaultType && item.type == type))
152 typeNode.setAttribute("checked", "true"); 150 typeNode.setAttribute("checked", "true");
153 151
154 if (item.type == type) 152 if (item.type == type)
155 typeNode.setAttribute("disabled", "true"); 153 typeNode.setAttribute("disabled", "true");
156 typeNode.addEventListener("command", () => checkboxUpdated(typeNode), false) ; 154 typeNode.addEventListener("command", () => checkboxUpdated(typeNode), false) ;
157 typeGroup.appendChild(typeNode); 155 typeGroup.appendChild(typeNode);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 * Selects or unselects all type checkboxes except those 392 * Selects or unselects all type checkboxes except those
395 * that are disabled. 393 * that are disabled.
396 */ 394 */
397 function selectAllTypes(/**Boolean*/ select) 395 function selectAllTypes(/**Boolean*/ select)
398 { 396 {
399 for (let typeNode = E("typeGroup").firstChild; typeNode; typeNode = typeNode.n extSibling) 397 for (let typeNode = E("typeGroup").firstChild; typeNode; typeNode = typeNode.n extSibling)
400 if (typeNode.getAttribute("disabled") != "true") 398 if (typeNode.getAttribute("disabled") != "true")
401 typeNode.checked = select; 399 typeNode.checked = select;
402 updateFilter(); 400 updateFilter();
403 } 401 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld