# HG changeset patch # User Guido Berhoerster # Date 1548080159 -3600 # Node ID 688d75e554e02e5a9ce1775f47ca77ee0fde57b2 # Parent 104a1faebd432593bcc6c6281645d428a5665e6b Add option to expand feed entries by default diff -r 104a1faebd43 -r 688d75e554e0 _locales/de/messages.json --- a/_locales/de/messages.json Mon Jan 21 08:22:52 2019 +0100 +++ b/_locales/de/messages.json Mon Jan 21 15:15:59 2019 +0100 @@ -90,5 +90,13 @@ "missingPlaceholderError": { "message": "Bitte die URL zum Abonnieren von Feeds eingeben, die einen Platzhalter \"%s\" für die URL das Feeds enthält.", "description": "Error message if the placholder is missing from the subscription URL template." + }, + "feedPreviewTitle": { + "message": "Feed-Vorschau", + "description": "Title of the feed preview options." + }, + "feedPreviewExpandItemLabel": { + "message": "Feed-Einträge standardmäßig aufklappen", + "description": "Label of the checkbox for enabling feed entry expansion by default." } } diff -r 104a1faebd43 -r 688d75e554e0 _locales/en/messages.json --- a/_locales/en/messages.json Mon Jan 21 08:22:52 2019 +0100 +++ b/_locales/en/messages.json Mon Jan 21 15:15:59 2019 +0100 @@ -90,5 +90,13 @@ "missingPlaceholderError": { "message": "Please enter a subscription URL which contains a placeholder \"%s\" for the feed URL.", "description": "Error message if the placholder is missing from the subscription URL template." + }, + "feedPreviewTitle": { + "message": "Feed Preview", + "description": "Title of the feed preview options." + }, + "feedPreviewExpandItemLabel": { + "message": "Expand feed entries by default", + "description": "Label of the checkbox for enabling feed entry expansion by default." } } diff -r 104a1faebd43 -r 688d75e554e0 js/background.js --- a/js/background.js Mon Jan 21 08:22:52 2019 +0100 +++ b/js/background.js Mon Jan 21 15:15:59 2019 +0100 @@ -57,6 +57,9 @@ var tabsFeedPreviews = new Map(); var fetchingFeedPreview = fetch('web_resources/feed-preview.xhtml') .then(response => response.text()); +var feedPreviewOptions = { + expandEntries: false +}; function parseContentType(header) { let contentType = { @@ -103,7 +106,8 @@ // render the preview document let feedPreviewDocument = new DOMParser() .parseFromString(await fetchingFeedPreview, 'text/html'); - renderFeedPreview(feedPreviewDocument, feed); + renderFeedPreview(feedPreviewDocument, feed, + feedPreviewOptions.expandEntries); return new XMLSerializer().serializeToString(feedPreviewDocument); } @@ -226,3 +230,20 @@ browser.storage.sync.set({feedReaders}); } }); + +browser.storage.sync.get('feedPreview').then(({feedPreview}) => { + if (typeof feedPreview !== 'undefined' && + feedPreview === Object(feedPreview)) { + feedPreviewOptions.expandEntries = !!feedPreview.expandEntries; + } +}); +browser.storage.onChanged.addListener((changes, areaName) => { + if (areaName !== 'sync' || typeof changes.feedPreview === 'undefined') { + return; + } + + let newValue = changes.feedPreview.newValue; + if (typeof newValue !== 'undefined' && newValue === Object(newValue)) { + feedPreviewOptions.expandEntries = !!newValue.expandEntries; + } +}); diff -r 104a1faebd43 -r 688d75e554e0 js/feed-preview.js --- a/js/feed-preview.js Mon Jan 21 08:22:52 2019 +0100 +++ b/js/feed-preview.js Mon Jan 21 15:15:59 2019 +0100 @@ -8,7 +8,8 @@ 'use strict'; -export function renderFeedPreview(feedPreviewDocument, feed) { +export function renderFeedPreview(feedPreviewDocument, feed, + expandEntriesByDefault) { // inject XSL stylesheet which transforms XHTML to HTML allowing the use of // the HTML DOM let xslFilename = browser.runtime.getURL('web_resources/xhtml-to-html.xsl'); @@ -59,9 +60,10 @@ let entryNode = feedPreviewDocument.importNode(entryTemplateElement.content, true); + entryNode.querySelector('details.entry').open = expandEntriesByDefault; + let titleElement; let titleNode; - if (typeof entry.link !== 'undefined') { titleNode = feedPreviewDocument .importNode(entryTitleLinkedTemplateElement.content, true); diff -r 104a1faebd43 -r 688d75e554e0 options/options.css --- a/options/options.css Mon Jan 21 08:22:52 2019 +0100 +++ b/options/options.css Mon Jan 21 15:15:59 2019 +0100 @@ -35,6 +35,10 @@ font-weight: bold; } +h1 ~ h1 { + margin-top: 32px; +} + input[type="text"] { border-radius: 2px; font-size: 15px; @@ -42,6 +46,11 @@ min-height: 32px; } +input[type="checkbox"], +input[type="checkbox"] + label { + vertical-align: middle; +} + .browser-style > input[type=text] { border-color: var(--text-input-border-color); box-shadow: none; diff -r 104a1faebd43 -r 688d75e554e0 options/options.html --- a/options/options.html Mon Jan 21 08:22:52 2019 +0100 +++ b/options/options.html Mon Jan 21 15:15:59 2019 +0100 @@ -50,5 +50,11 @@