Mercurial > addons > firefox-addons > feed-preview
changeset 9:fcd65cf3f634
Simplify the hint shown if there are no entries
Always create the element and hide it with CSS if there are entries.
author | Guido Berhoerster <guido+feed-preview@berhoerster.name> |
---|---|
date | Tue, 27 Nov 2018 16:05:14 +0100 |
parents | c271192aac9d |
children | ff5e5e3eba32 |
files | js/feed-preview.js web_resources/feed-preview.xhtml web_resources/style/feed-preview.css |
diffstat | 3 files changed, 9 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/js/feed-preview.js Tue Nov 27 11:11:15 2018 +0100 +++ b/js/feed-preview.js Tue Nov 27 16:05:14 2018 +0100 @@ -36,6 +36,9 @@ feedPreviewDocument.querySelector('#feed-header').prepend(logoNode); } + feedPreviewDocument.querySelector("#no-entries-hint").textContent = + browser.i18n.getMessage('noEntriesHint'); + let entryTemplateElement = feedPreviewDocument.querySelector('#entry-template'); let entryTitleTemplateElement = @@ -46,16 +49,6 @@ feedPreviewDocument.querySelector('#entry-files-list-template'); let entryFileTemplateElement = feedPreviewDocument.querySelector('#entry-file-template'); - if (feed.entries.length === 0) { - let hintTemplateElement = - previewDocument.querySelector('#no-entries-hint-template'); - let hintNode = previewDocument.importNode(hintTemplateElement.content, - true); - hintNode.querySelector("#no-entries-hint").textContent = - browser.i18n.getMessage('noEntriesHint'); - - previewDocument.body.append(hintNode); - } for (let entry of feed.entries) { let entryNode = feedPreviewDocument.importNode(entryTemplateElement.content,
--- a/web_resources/feed-preview.xhtml Tue Nov 27 11:11:15 2018 +0100 +++ b/web_resources/feed-preview.xhtml Tue Nov 27 16:05:14 2018 +0100 @@ -44,9 +44,6 @@ </ul> </footer> </template> - <template id="no-entries-hint-template"> - <p id="no-entries-hint"></p> - </template> <template id="entry-file-template"> <li class="entry-file"><a class="entry-file-link" href="" title=""></a> <span class="entry-file-info"></span></li> @@ -55,5 +52,6 @@ <h1 id="feed-title"></h1> <p id="feed-subtitle"></p> </header> + <p id="no-entries-hint"></p> </body> </html>
--- a/web_resources/style/feed-preview.css Tue Nov 27 11:11:15 2018 +0100 +++ b/web_resources/style/feed-preview.css Tue Nov 27 16:05:14 2018 +0100 @@ -86,6 +86,11 @@ #no-entries-hint { color: var(--secondary-color); font: var(--font-display-20); + display: none; +} + +#no-entries-hint:last-child { + display: block; } #no-entries-hint,