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 Nov 27 16:05:14 2018 +0100 (18 months ago)
parents c271192aac9d
children ff5e5e3eba32
files js/feed-preview.js web_resources/feed-preview.xhtml web_resources/style/feed-preview.css
line diff
     1.1 --- a/js/feed-preview.js	Tue Nov 27 11:11:15 2018 +0100
     1.2 +++ b/js/feed-preview.js	Tue Nov 27 16:05:14 2018 +0100
     1.3 @@ -36,6 +36,9 @@
     1.4          feedPreviewDocument.querySelector('#feed-header').prepend(logoNode);
     1.5      }
     1.6  
     1.7 +    feedPreviewDocument.querySelector("#no-entries-hint").textContent =
     1.8 +            browser.i18n.getMessage('noEntriesHint');
     1.9 +
    1.10      let entryTemplateElement =
    1.11              feedPreviewDocument.querySelector('#entry-template');
    1.12      let entryTitleTemplateElement =
    1.13 @@ -46,16 +49,6 @@
    1.14              feedPreviewDocument.querySelector('#entry-files-list-template');
    1.15      let entryFileTemplateElement =
    1.16              feedPreviewDocument.querySelector('#entry-file-template');
    1.17 -    if (feed.entries.length === 0) {
    1.18 -        let hintTemplateElement =
    1.19 -                previewDocument.querySelector('#no-entries-hint-template');
    1.20 -        let hintNode = previewDocument.importNode(hintTemplateElement.content,
    1.21 -                true);
    1.22 -        hintNode.querySelector("#no-entries-hint").textContent =
    1.23 -            browser.i18n.getMessage('noEntriesHint');
    1.24 -
    1.25 -        previewDocument.body.append(hintNode);
    1.26 -    }
    1.27      for (let entry of feed.entries) {
    1.28          let entryNode =
    1.29                  feedPreviewDocument.importNode(entryTemplateElement.content,
     2.1 --- a/web_resources/feed-preview.xhtml	Tue Nov 27 11:11:15 2018 +0100
     2.2 +++ b/web_resources/feed-preview.xhtml	Tue Nov 27 16:05:14 2018 +0100
     2.3 @@ -44,9 +44,6 @@
     2.4          </ul>
     2.5        </footer>
     2.6      </template>
     2.7 -    <template id="no-entries-hint-template">
     2.8 -      <p id="no-entries-hint"></p>
     2.9 -    </template>
    2.10      <template id="entry-file-template">
    2.11        <li class="entry-file"><a class="entry-file-link" href="" title=""></a>
    2.12        <span class="entry-file-info"></span></li>
    2.13 @@ -55,5 +52,6 @@
    2.14        <h1 id="feed-title"></h1>
    2.15        <p id="feed-subtitle"></p>
    2.16      </header>
    2.17 +    <p id="no-entries-hint"></p>
    2.18    </body>
    2.19  </html>
     3.1 --- a/web_resources/style/feed-preview.css	Tue Nov 27 11:11:15 2018 +0100
     3.2 +++ b/web_resources/style/feed-preview.css	Tue Nov 27 16:05:14 2018 +0100
     3.3 @@ -86,6 +86,11 @@
     3.4  #no-entries-hint {
     3.5    color: var(--secondary-color);
     3.6    font: var(--font-display-20);
     3.7 +  display: none;
     3.8 +}
     3.9 +
    3.10 +#no-entries-hint:last-child {
    3.11 +  display: block;
    3.12  }
    3.13  
    3.14  #no-entries-hint,