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

Side by Side Diff: chrome/content/ui/composer.js

Issue 29329473: Issue 3222 - Don`t do localization in the contentPolicy module (Closed)
Patch Set: Created Oct. 29, 2015, 1:25 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/content/ui/sidebar.js » ('j') | chrome/content/ui/sidebar.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = [];
122 for (let type of Policy.localizedDescr.keys()) 122 for (let type of Policy.contentTypes)
123 types.push(type); 123 types.push([type, Utils.getString("type_label_" + type.toLowerCase())]);
124 types.sort(); 124 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 125
126 let docDomain = item.docDomain; 126 let docDomain = item.docDomain;
127 let thirdParty = item.thirdParty; 127 let thirdParty = item.thirdParty;
128 128
129 if (docDomain) 129 if (docDomain)
130 docDomain = docDomain.replace(/^www\./i, "").replace(/\.+$/, ""); 130 docDomain = docDomain.replace(/^www\./i, "").replace(/\.+$/, "");
131 if (docDomain) 131 if (docDomain)
132 E("domainRestriction").value = docDomain; 132 E("domainRestriction").value = docDomain;
133 133
134 E("thirdParty").hidden = !thirdParty; 134 E("thirdParty").hidden = !thirdParty;
135 E("firstParty").hidden = thirdParty; 135 E("firstParty").hidden = thirdParty;
136 136
137 let typeGroup = E("typeGroup"); 137 let typeGroup = E("typeGroup");
138 let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap. DOCUMENT; 138 let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap. DOCUMENT;
139 let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) != 0 ; 139 let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) != 0 ;
140 for (let type of types) 140 for (let [type, label] of types)
141 { 141 {
142 if (type == "ELEMHIDE") 142 if (type == "ELEMHIDE")
143 continue; 143 continue;
144 144
145 let typeNode = document.createElement("checkbox"); 145 let typeNode = document.createElement("checkbox");
146 typeNode.setAttribute("value", type.toLowerCase().replace(/\_/g, "-")); 146 typeNode.setAttribute("value", type.toLowerCase().replace(/\_/g, "-"));
147 typeNode.setAttribute("label", Policy.localizedDescr.get(type).toLowerCase() ); 147 typeNode.setAttribute("label", label);
148 148
149 let typeMask = RegExpFilter.typeMap[type]; 149 let typeMask = RegExpFilter.typeMap[type];
150 typeNode._defaultType = (typeMask & defaultTypes) != 0; 150 typeNode._defaultType = (typeMask & defaultTypes) != 0;
151 if ((isDefaultType && typeNode._defaultType) || (!isDefaultType && item.type == type)) 151 if ((isDefaultType && typeNode._defaultType) || (!isDefaultType && item.type == type))
152 typeNode.setAttribute("checked", "true"); 152 typeNode.setAttribute("checked", "true");
153 153
154 if (item.type == type) 154 if (item.type == type)
155 typeNode.setAttribute("disabled", "true"); 155 typeNode.setAttribute("disabled", "true");
156 typeNode.addEventListener("command", () => checkboxUpdated(typeNode), false) ; 156 typeNode.addEventListener("command", () => checkboxUpdated(typeNode), false) ;
157 typeGroup.appendChild(typeNode); 157 typeGroup.appendChild(typeNode);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 * Selects or unselects all type checkboxes except those 394 * Selects or unselects all type checkboxes except those
395 * that are disabled. 395 * that are disabled.
396 */ 396 */
397 function selectAllTypes(/**Boolean*/ select) 397 function selectAllTypes(/**Boolean*/ select)
398 { 398 {
399 for (let typeNode = E("typeGroup").firstChild; typeNode; typeNode = typeNode.n extSibling) 399 for (let typeNode = E("typeGroup").firstChild; typeNode; typeNode = typeNode.n extSibling)
400 if (typeNode.getAttribute("disabled") != "true") 400 if (typeNode.getAttribute("disabled") != "true")
401 typeNode.checked = select; 401 typeNode.checked = select;
402 updateFilter(); 402 updateFilter();
403 } 403 }
OLDNEW
« no previous file with comments | « no previous file | chrome/content/ui/sidebar.js » ('j') | chrome/content/ui/sidebar.js » ('J')

Powered by Google App Engine
This is Rietveld