| Index: new-options.js |
| =================================================================== |
| --- a/new-options.js |
| +++ b/new-options.js |
| @@ -52,24 +52,35 @@ |
| this.items = []; |
| } |
| - Collection.prototype._setEmpty = function(table, texts) |
| + Collection.prototype._setEmpty = function(table, detail, removeEmpty) |
|
ire
2017/09/26 08:37:55
NIT: This function and the nested if statements ar
saroyanm
2017/09/26 16:35:25
Absolutely, my bad, now should be more readable I
|
| { |
| - let placeholders = table.querySelectorAll(".empty-placeholder"); |
| + if (removeEmpty) |
| + { |
| + let placeholders = table.querySelectorAll(".empty-placeholder"); |
| + if (placeholders.length > 0) |
| + { |
| + for (let placeholder of placeholders) |
| + table.removeChild(placeholder); |
| + } |
| - if (texts && placeholders.length == 0) |
| + if (detail.removeEmptyAction) |
| + execAction(detail.removeEmptyAction, table); |
| + } |
| + else |
| { |
| - for (let text of texts) |
| + if (detail.emptyText) |
| { |
| - let placeholder = document.createElement("li"); |
| - placeholder.className = "empty-placeholder"; |
| - placeholder.textContent = getMessage(text); |
| - table.appendChild(placeholder); |
| + for (let text of detail.emptyText) |
| + { |
| + let placeholder = document.createElement("li"); |
| + placeholder.className = "empty-placeholder"; |
| + placeholder.textContent = getMessage(text); |
| + table.appendChild(placeholder); |
| + } |
| } |
| - } |
| - else if (placeholders.length > 0) |
| - { |
| - for (let placeholder of placeholders) |
| - table.removeChild(placeholder); |
| + |
| + if (detail.setEmptyAction) |
| + execAction(detail.setEmptyAction, table); |
| } |
| }; |
| @@ -153,7 +164,7 @@ |
| } |
| } |
| - this._setEmpty(table, null); |
| + this._setEmpty(table, detail, true); |
| if (table.children.length > 0) |
| table.insertBefore(listItem, table.children[this.items.indexOf(item)]); |
| else |
| @@ -199,7 +210,7 @@ |
| element.parentElement.removeChild(element); |
| if (this.items.length == 0) |
| - this._setEmpty(table, detail.emptyText); |
| + this._setEmpty(table, detail); |
| } |
| }; |
| @@ -316,7 +327,7 @@ |
| element = element.nextElementSibling; |
| } |
| - this._setEmpty(table, detail.emptyText); |
| + this._setEmpty(table, detail); |
| } |
| }; |
| @@ -354,7 +365,9 @@ |
| ]); |
| collections.more = new Collection([ |
| { |
| - id: "more-list-table" |
| + id: "more-list-table", |
| + setEmptyAction: "hide-more-section", |
| + removeEmptyAction: "show-more-section" |
|
ire
2017/09/26 08:37:55
NIT: Calling it "hide-more-section" seems to gener
saroyanm
2017/09/26 16:35:25
I agree with you, done.
|
| } |
| ]); |
| collections.whitelist = new Collection([ |
| @@ -583,6 +596,9 @@ |
| case "edit-custom-filters": |
| setCustomFiltersView("write"); |
| break; |
| + case "hide-more-section": |
| + E("more-filters").setAttribute("aria-hidden", true); |
| + break; |
| case "hide-notification": |
| hideNotification(); |
| break; |
| @@ -626,6 +642,9 @@ |
| setCustomFiltersView("read"); |
| }); |
| break; |
| + case "show-more-section": |
| + E("more-filters").setAttribute("aria-hidden", false); |
| + break; |
| case "switch-acceptable-ads": |
| let value = element.value || element.dataset.value; |
| ext.backgroundPage.sendMessage({ |