From da4a80b88a64855bd62d996baabaaf25497c5f42 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 24 Jan 2019 19:43:28 +0100 Subject: Add a JavaScript event when opening an article (#2222) * Add a JavaScript event when opening an article https://framagit.org/nicofrand/xextension-threepanesview/issues/4 ```javascript document.body.addEventListener('freshrss:openArticle', function (e) { console.log('freshrss:openArticle'); console.log(e.target); }); ``` --- p/scripts/main.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index b12b3cf26..6cab2e55a 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -237,6 +237,9 @@ function mark_favorite(active) { }); } +var freshrssOpenArticleEvent = document.createEvent('Event'); +freshrssOpenArticleEvent.initEvent('freshrss:openArticle', true, true); + function toggleContent(new_active, old_active, skipping) { // If skipping, move current without activating or marking as read if (new_active.length === 0) { @@ -299,8 +302,11 @@ function toggleContent(new_active, old_active, skipping) { } } - if (context.auto_mark_article && new_active.hasClass('active') && !skipping) { - mark_read(new_active, true); + if (new_active.hasClass('active') && !skipping) { + if (context.auto_mark_article) { + mark_read(new_active, true); + } + new_active[0].dispatchEvent(freshrssOpenArticleEvent); } } -- cgit v1.2.3