Mercurial > addons > firefox-addons > feed-preview
comparison js/feed-preview.js @ 29:688d75e554e0
Add option to expand feed entries by default
author | Guido Berhoerster <guido+feed-preview@berhoerster.name> |
---|---|
date | Mon, 21 Jan 2019 15:15:59 +0100 |
parents | f0c4a458869c |
children | 76e23b361e92 |
comparison
equal
deleted
inserted
replaced
28:104a1faebd43 | 29:688d75e554e0 |
---|---|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. | 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
7 */ | 7 */ |
8 | 8 |
9 'use strict'; | 9 'use strict'; |
10 | 10 |
11 export function renderFeedPreview(feedPreviewDocument, feed) { | 11 export function renderFeedPreview(feedPreviewDocument, feed, |
12 expandEntriesByDefault) { | |
12 // inject XSL stylesheet which transforms XHTML to HTML allowing the use of | 13 // inject XSL stylesheet which transforms XHTML to HTML allowing the use of |
13 // the HTML DOM | 14 // the HTML DOM |
14 let xslFilename = browser.runtime.getURL('web_resources/xhtml-to-html.xsl'); | 15 let xslFilename = browser.runtime.getURL('web_resources/xhtml-to-html.xsl'); |
15 let xmlStylesheetNode = | 16 let xmlStylesheetNode = |
16 feedPreviewDocument.createProcessingInstruction('xml-stylesheet', | 17 feedPreviewDocument.createProcessingInstruction('xml-stylesheet', |
57 feedPreviewDocument.querySelector('#entry-file-template'); | 58 feedPreviewDocument.querySelector('#entry-file-template'); |
58 for (let entry of feed.entries) { | 59 for (let entry of feed.entries) { |
59 let entryNode = | 60 let entryNode = |
60 feedPreviewDocument.importNode(entryTemplateElement.content, | 61 feedPreviewDocument.importNode(entryTemplateElement.content, |
61 true); | 62 true); |
63 entryNode.querySelector('details.entry').open = expandEntriesByDefault; | |
64 | |
62 let titleElement; | 65 let titleElement; |
63 let titleNode; | 66 let titleNode; |
64 | |
65 if (typeof entry.link !== 'undefined') { | 67 if (typeof entry.link !== 'undefined') { |
66 titleNode = feedPreviewDocument | 68 titleNode = feedPreviewDocument |
67 .importNode(entryTitleLinkedTemplateElement.content, true); | 69 .importNode(entryTitleLinkedTemplateElement.content, true); |
68 titleElement = titleNode.querySelector('.entry-link'); | 70 titleElement = titleNode.querySelector('.entry-link'); |
69 titleElement.href = entry.link; | 71 titleElement.href = entry.link; |