addons/firefox-addons/feed-preview

changeset 1:1c31f4102408

Show a hint if the feed has no entries
author Guido Berhoerster <guido+feed-preview@berhoerster.name>
date Thu Oct 04 09:40:26 2018 +0200 (20 months ago)
parents bc5cc170163c
children 7b24037ef7b5
files _locales/de/messages.json _locales/en/messages.json content_scripts/feed-preview.js web_resources/feed-preview.xhtml web_resources/style/feed-preview.css
line diff
     1.1 --- a/_locales/de/messages.json	Wed Oct 03 23:40:57 2018 +0200
     1.2 +++ b/_locales/de/messages.json	Thu Oct 04 09:40:26 2018 +0200
     1.3 @@ -11,6 +11,10 @@
     1.4          "message": "Feed ohne Titel",
     1.5          "description": "Default title for feeds."
     1.6      },
     1.7 +    "noEntriesHint": {
     1.8 +        "message": "Dieser Feed hat keine Eintr├Ąge.",
     1.9 +        "description": "Hint to display if there are no entries."
    1.10 +    },
    1.11      "defaultFeedEntryTitle": {
    1.12          "message": "Eintrag ohne Titel",
    1.13          "description": "Default title for feed entries."
     2.1 --- a/_locales/en/messages.json	Wed Oct 03 23:40:57 2018 +0200
     2.2 +++ b/_locales/en/messages.json	Thu Oct 04 09:40:26 2018 +0200
     2.3 @@ -11,6 +11,10 @@
     2.4          "message": "Untitled Feed",
     2.5          "description": "Default title for feeds."
     2.6      },
     2.7 +    "noEntriesHint": {
     2.8 +        "message": "This feed has no entries.",
     2.9 +        "description": "Hint to display if there are no entries."
    2.10 +    },
    2.11      "defaultFeedEntryTitle": {
    2.12          "message": "Untitled Entry",
    2.13          "description": "Default title for feed entries."
     3.1 --- a/content_scripts/feed-preview.js	Wed Oct 03 23:40:57 2018 +0200
     3.2 +++ b/content_scripts/feed-preview.js	Thu Oct 04 09:40:26 2018 +0200
     3.3 @@ -329,6 +329,17 @@
     3.4                  previewDocument.querySelector('#entry-files-list-template');
     3.5          let entryFileTemplateElement =
     3.6                  previewDocument.querySelector('#entry-file-template');
     3.7 +        if (this.entries.length === 0) {
     3.8 +            let hintTemplateElement =
     3.9 +                    previewDocument.querySelector('#no-entries-hint-template');
    3.10 +            let hintNode =
    3.11 +                    previewDocument.importNode(hintTemplateElement.content,
    3.12 +                    true);
    3.13 +            hintNode.querySelector("#no-entries-hint").textContent =
    3.14 +                browser.i18n.getMessage('noEntriesHint');
    3.15 +
    3.16 +            previewDocument.body.append(hintNode);
    3.17 +        }
    3.18          for (let entry of this.entries) {
    3.19              let entryNode =
    3.20                      previewDocument.importNode(entryTemplateElement.content,
     4.1 --- a/web_resources/feed-preview.xhtml	Wed Oct 03 23:40:57 2018 +0200
     4.2 +++ b/web_resources/feed-preview.xhtml	Thu Oct 04 09:40:26 2018 +0200
     4.3 @@ -43,6 +43,9 @@
     4.4        </ul>
     4.5      </footer>
     4.6    </template>
     4.7 +  <template id="no-entries-hint-template">
     4.8 +    <p id="no-entries-hint"></p>
     4.9 +  </template>
    4.10    <template id="entry-file-template">
    4.11      <li class="entry-file"><a class="entry-file-link" href="" title=""></a>
    4.12      <span class="entry-file-info"></span></li>
     5.1 --- a/web_resources/style/feed-preview.css	Wed Oct 03 23:40:57 2018 +0200
     5.2 +++ b/web_resources/style/feed-preview.css	Thu Oct 04 09:40:26 2018 +0200
     5.3 @@ -28,6 +28,11 @@
     5.4    margin: 0 0 16px 0;
     5.5  }
     5.6  
     5.7 +#no-entries-hint {
     5.8 +  color: var(--grey-50);
     5.9 +}
    5.10 +
    5.11 +#no-entries-hint,
    5.12  .entry {
    5.13    clear: both;
    5.14    margin: 16px auto;