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

Unified Diff: new-options.js

Issue 29555849: Issue 5778 - Hide More filters section when there is no filter (Closed)
Patch Set: Rebased Created Sept. 26, 2017, 4:32 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « new-options.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
{
- 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"
}
]);
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({
« no previous file with comments | « new-options.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld