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

Delta Between Two Patch Sets: new-options.js

Issue 29555849: Issue 5778 - Hide More filters section when there is no filter (Closed)
Left Patch Set: Rebased Created Sept. 26, 2017, 4:32 p.m.
Right Patch Set: Fixed nits Created Sept. 26, 2017, 4:33 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 | « new-options.html ('k') | no next file » | 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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 { 50 {
51 this.details = details; 51 this.details = details;
52 this.items = []; 52 this.items = [];
53 } 53 }
54 54
55 Collection.prototype._setEmpty = function(table, detail, removeEmpty) 55 Collection.prototype._setEmpty = function(table, detail, removeEmpty)
56 { 56 {
57 if (removeEmpty) 57 if (removeEmpty)
58 { 58 {
59 let placeholders = table.querySelectorAll(".empty-placeholder"); 59 let placeholders = table.querySelectorAll(".empty-placeholder");
60 if (placeholders.length > 0) 60 for (let placeholder of placeholders)
61 { 61 table.removeChild(placeholder);
62 for (let placeholder of placeholders) 62
63 table.removeChild(placeholder); 63 execAction(detail.removeEmptyAction, table);
64 }
65
66 if (detail.removeEmptyAction)
67 execAction(detail.removeEmptyAction, table);
68 } 64 }
69 else 65 else
70 { 66 {
71 if (detail.emptyText) 67 let {emptyTexts = []} = detail;
72 { 68 for (let text of emptyTexts)
73 for (let text of detail.emptyText) 69 {
74 { 70 let placeholder = document.createElement("li");
75 let placeholder = document.createElement("li"); 71 placeholder.className = "empty-placeholder";
76 placeholder.className = "empty-placeholder"; 72 placeholder.textContent = getMessage(text);
77 placeholder.textContent = getMessage(text); 73 table.appendChild(placeholder);
78 table.appendChild(placeholder); 74 }
79 } 75
80 } 76 execAction(detail.setEmptyAction, table);
81
82 if (detail.setEmptyAction)
83 execAction(detail.setEmptyAction, table);
84 } 77 }
85 }; 78 };
86 79
87 Collection.prototype._createElementQuery = function(item) 80 Collection.prototype._createElementQuery = function(item)
88 { 81 {
89 let access = (item.url || item.text).replace(/'/g, "\\'"); 82 let access = (item.url || item.text).replace(/'/g, "\\'");
90 return function(container) 83 return function(container)
91 { 84 {
92 return container.querySelector("[data-access='" + access + "']"); 85 return container.querySelector("[data-access='" + access + "']");
93 }; 86 };
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 340 }
348 341
349 collections.protection = new Collection([ 342 collections.protection = new Collection([
350 { 343 {
351 id: "recommend-protection-list-table" 344 id: "recommend-protection-list-table"
352 } 345 }
353 ]); 346 ]);
354 collections.langs = new Collection([ 347 collections.langs = new Collection([
355 { 348 {
356 id: "blocking-languages-table", 349 id: "blocking-languages-table",
357 emptyText: ["options_language_empty"] 350 emptyTexts: ["options_language_empty"]
358 } 351 }
359 ]); 352 ]);
360 collections.allLangs = new Collection([ 353 collections.allLangs = new Collection([
361 { 354 {
362 id: "all-lang-table-add", 355 id: "all-lang-table-add",
363 emptyText: ["options_dialog_language_other_empty"] 356 emptyTexts: ["options_dialog_language_other_empty"]
364 } 357 }
365 ]); 358 ]);
366 collections.more = new Collection([ 359 collections.more = new Collection([
367 { 360 {
368 id: "more-list-table", 361 id: "more-list-table",
369 setEmptyAction: "hide-more-section", 362 setEmptyAction: "hide-more-filters-section",
370 removeEmptyAction: "show-more-section" 363 removeEmptyAction: "show-more-filters-section"
371 } 364 }
372 ]); 365 ]);
373 collections.whitelist = new Collection([ 366 collections.whitelist = new Collection([
374 { 367 {
375 id: "whitelisting-table", 368 id: "whitelisting-table",
376 emptyText: ["options_whitelist_empty_1", "options_whitelist_empty_2"] 369 emptyTexts: ["options_whitelist_empty_1", "options_whitelist_empty_2"]
377 } 370 }
378 ]); 371 ]);
379 collections.filterLists = new Collection([ 372 collections.filterLists = new Collection([
380 { 373 {
381 id: "all-filter-lists-table", 374 id: "all-filter-lists-table",
382 useOriginalTitle: true 375 useOriginalTitle: true
383 } 376 }
384 ]); 377 ]);
385 378
386 function addSubscription(subscription) 379 function addSubscription(subscription)
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 break; 582 break;
590 } 583 }
591 } 584 }
592 break; 585 break;
593 case "close-dialog": 586 case "close-dialog":
594 closeDialog(); 587 closeDialog();
595 break; 588 break;
596 case "edit-custom-filters": 589 case "edit-custom-filters":
597 setCustomFiltersView("write"); 590 setCustomFiltersView("write");
598 break; 591 break;
599 case "hide-more-section": 592 case "hide-more-filters-section":
600 E("more-filters").setAttribute("aria-hidden", true); 593 E("more-filters").setAttribute("aria-hidden", true);
601 break; 594 break;
602 case "hide-notification": 595 case "hide-notification":
603 hideNotification(); 596 hideNotification();
604 break; 597 break;
605 case "import-subscription": { 598 case "import-subscription": {
606 let url = E("blockingList-textbox").value; 599 let url = E("blockingList-textbox").value;
607 addEnableSubscription(url); 600 addEnableSubscription(url);
608 closeDialog(); 601 closeDialog();
609 break; 602 break;
(...skipping 25 matching lines...) Expand all
635 sendMessageHandleErrors({ 628 sendMessageHandleErrors({
636 type: "filters.importRaw", 629 type: "filters.importRaw",
637 text: E("custom-filters-raw").value, 630 text: E("custom-filters-raw").value,
638 removeExisting: true 631 removeExisting: true
639 }, 632 },
640 () => 633 () =>
641 { 634 {
642 setCustomFiltersView("read"); 635 setCustomFiltersView("read");
643 }); 636 });
644 break; 637 break;
645 case "show-more-section": 638 case "show-more-filters-section":
646 E("more-filters").setAttribute("aria-hidden", false); 639 E("more-filters").setAttribute("aria-hidden", false);
647 break; 640 break;
648 case "switch-acceptable-ads": 641 case "switch-acceptable-ads":
649 let value = element.value || element.dataset.value; 642 let value = element.value || element.dataset.value;
650 ext.backgroundPage.sendMessage({ 643 ext.backgroundPage.sendMessage({
651 type: value == "privacy" ? "subscriptions.add" : 644 type: value == "privacy" ? "subscriptions.add" :
652 "subscriptions.remove", 645 "subscriptions.remove",
653 url: acceptableAdsPrivacyUrl 646 url: acceptableAdsPrivacyUrl
654 }); 647 });
655 ext.backgroundPage.sendMessage({ 648 ext.backgroundPage.sendMessage({
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 }); 1393 });
1401 ext.backgroundPage.sendMessage({ 1394 ext.backgroundPage.sendMessage({
1402 type: "subscriptions.listen", 1395 type: "subscriptions.listen",
1403 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1396 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1404 "title", "downloadStatus", "downloading"] 1397 "title", "downloadStatus", "downloading"]
1405 }); 1398 });
1406 1399
1407 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1400 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1408 window.addEventListener("hashchange", onHashChange, false); 1401 window.addEventListener("hashchange", onHashChange, false);
1409 } 1402 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld