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

Delta Between Two Patch Sets: options.js

Issue 29329095: Issue 2747 - Added empty state for tables in options page (Closed)
Left Patch Set: Created Oct. 13, 2015, 2:24 p.m.
Right Patch Set: Created Dec. 11, 2015, 4:48 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 | « options.html ('k') | skin/options.css » ('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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 if (text) 72 if (text)
73 listItem.setAttribute("data-search", text.toLowerCase()); 73 listItem.setAttribute("data-search", text.toLowerCase());
74 74
75 var control = listItem.querySelector(".control"); 75 var control = listItem.querySelector(".control");
76 if (control) 76 if (control)
77 { 77 {
78 control.addEventListener("click", this.details[j].onClick, false); 78 control.addEventListener("click", this.details[j].onClick, false);
79 control.checked = item.disabled == false; 79 control.checked = item.disabled == false;
80 } 80 }
81 81
82 this._setEmpty(table, null); 82 this._setEmpty(table, null);
saroyanm 2015/11/30 11:24:21 Doesn't it make more sense to call the _setEmpty m
Thomas Greiner 2015/12/11 16:49:35 I see your line of reasoning but I'd argue that it
83 if (table.hasChildNodes()) 83 if (table.hasChildNodes())
84 table.insertBefore(listItem, table.childNodes[this.items.indexOf(item) ]); 84 table.insertBefore(listItem, table.childNodes[this.items.indexOf(item) ]);
85 else 85 else
86 table.appendChild(listItem); 86 table.appendChild(listItem);
87 } 87 }
88 } 88 }
89 return length; 89 return length;
90 }; 90 };
91 91
92 Collection.prototype.removeItem = function(item) 92 Collection.prototype.removeItem = function(item)
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 var elements = document.querySelectorAll("[data-access='" + access + " ']"); 224 var elements = document.querySelectorAll("[data-access='" + access + " ']");
225 for (var i = 0; i < elements.length; i++) 225 for (var i = 0; i < elements.length; i++)
226 { 226 {
227 var element = elements[i]; 227 var element = elements[i];
228 var control = element.querySelector(".control"); 228 var control = element.querySelector(".control");
229 if (control.localName == "input") 229 if (control.localName == "input")
230 control.checked = subscription.disabled == false; 230 control.checked = subscription.disabled == false;
231 if (subscriptionUrl in recommendationsMap) 231 if (subscriptionUrl in recommendationsMap)
232 { 232 {
233 var recommendation = recommendationsMap[subscriptionUrl]; 233 var recommendation = recommendationsMap[subscriptionUrl];
234 if (recommendation.isAdsType) 234 if (recommendation.type == "ads")
235 { 235 {
236 if (subscription.disabled == false) 236 if (subscription.disabled == false)
237 { 237 {
238 collections.allLangs.removeItem(subscription); 238 collections.allLangs.removeItem(subscription);
239 collections.langs.addItems(subscription); 239 collections.langs.addItems(subscription);
240 } 240 }
241 else 241 else
242 { 242 {
243 collections.allLangs.addItems(subscription); 243 collections.allLangs.addItems(subscription);
244 collections.langs.removeItem(subscription); 244 collections.langs.removeItem(subscription);
(...skipping 26 matching lines...) Expand all
271 } 271 }
272 else 272 else
273 { 273 {
274 Object.observe(subscription, onObjectChanged); 274 Object.observe(subscription, onObjectChanged);
275 } 275 }
276 276
277 var collection = null; 277 var collection = null;
278 if (subscriptionUrl in recommendationsMap) 278 if (subscriptionUrl in recommendationsMap)
279 { 279 {
280 var recommendation = recommendationsMap[subscriptionUrl]; 280 var recommendation = recommendationsMap[subscriptionUrl];
281 if (recommendation.isPopular) 281 if (recommendation.type != "ads")
282 collection = collections.popular; 282 collection = collections.popular;
283 else if (recommendation.isAdsType && subscription.disabled == false) 283 else if (subscription.disabled == false)
284 collection = collections.langs; 284 collection = collections.langs;
285 else 285 else
286 collection = collections.allLangs; 286 collection = collections.allLangs;
287 } 287 }
288 else if (subscriptionUrl == acceptableAdsUrl) 288 else if (subscriptionUrl == acceptableAdsUrl)
289 collection = collections.acceptableAds; 289 collection = collections.acceptableAds;
290 else 290 else
291 collection = collections.custom; 291 collection = collections.custom;
292 292
293 collection.addItems(subscription); 293 collection.addItems(subscription);
(...skipping 29 matching lines...) Expand all
323 { 323 {
324 var element = elements[i]; 324 var element = elements[i];
325 var subscription = Object.create(null); 325 var subscription = Object.create(null);
326 subscription.title = element.getAttribute("title"); 326 subscription.title = element.getAttribute("title");
327 subscription.url = element.getAttribute("url"); 327 subscription.url = element.getAttribute("url");
328 subscription.disabled = null; 328 subscription.disabled = null;
329 subscription.downloadStatus = null; 329 subscription.downloadStatus = null;
330 subscription.homepage = null; 330 subscription.homepage = null;
331 subscription.lastSuccess = null; 331 subscription.lastSuccess = null;
332 var recommendation = Object.create(null); 332 var recommendation = Object.create(null);
333 recommendation.isAdsType = false; 333 recommendation.type = element.getAttribute("type");
334 recommendation.isPopular = false;
335 var prefix = element.getAttribute("prefixes"); 334 var prefix = element.getAttribute("prefixes");
336 if (prefix) 335 if (prefix)
337 { 336 {
338 var prefix = element.getAttribute("prefixes").replace(/,/g, "_"); 337 prefix = prefix.replace(/\W/g, "_");
339 subscription.title = ext.i18n.getMessage("options_language_" + prefix) ; 338 subscription.title = ext.i18n.getMessage("options_language_" + prefix) ;
340 recommendation.isAdsType = true;
341 } 339 }
342 else 340 else
343 { 341 {
344 subscription.title = element.getAttribute("specialization"); 342 var type = recommendation.type.replace(/\W/g, "_");
345 recommendation.isPopular = true; 343 subscription.title = ext.i18n.getMessage("common_feature_" + type + "_ title");
346 } 344 }
347 345
348 recommendationsMap[subscription.url] = recommendation; 346 recommendationsMap[subscription.url] = recommendation;
349 updateSubscription(subscription); 347 updateSubscription(subscription);
350 } 348 }
351 }, false); 349 }, false);
352 request.send(null); 350 request.send(null);
353 } 351 }
354 352
355 function onClick(e) 353 function onClick(e)
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 filter: ["added", "loaded", "removed"] 817 filter: ["added", "loaded", "removed"]
820 }); 818 });
821 ext.backgroundPage.sendMessage( 819 ext.backgroundPage.sendMessage(
822 { 820 {
823 type: "subscriptions.listen", 821 type: "subscriptions.listen",
824 filter: ["added", "disabled", "homepage", "removed", "title"] 822 filter: ["added", "disabled", "homepage", "removed", "title"]
825 }); 823 });
826 824
827 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 825 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
828 })(); 826 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld