From e5c8d52aa1ef5a624512b5faf64ea30697ef7e4c Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 1 Apr 2019 23:43:20 +0200 Subject: Fix ASC load more (#2318) https://github.com/FreshRSS/FreshRSS/issues/2314 --- p/scripts/main.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index f59976b39..04bf50c81 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1286,12 +1286,11 @@ function load_more_posts() { paginationNew = streamAdopted.querySelector('.pagination'); formPagination.replaceChild(paginationNew, paginationOld); - if (context.display_order === 'ASC') { - document.querySelector('#nav_menu_read_all .read_all').formAction = - document.getElementById('bigMarkAsRead').formAction; - } else { - const bigMarkAsRead = document.getElementById('bigMarkAsRead'); - if (bigMarkAsRead) { + const bigMarkAsRead = document.getElementById('bigMarkAsRead'); + if (bigMarkAsRead) { + if (context.display_order === 'ASC') { + document.querySelector('#nav_menu_read_all .read_all').formAction = bigMarkAsRead.formAction; + } else { bigMarkAsRead.formAction = document.querySelector('#nav_menu_read_all .read_all').formAction; } } @@ -1305,8 +1304,7 @@ function load_more_posts() { init_load_more(box_load_more); - const bigMarkAsRead = document.getElementById('bigMarkAsRead'), - div_load_more = document.getElementById('load_more'); + const div_load_more = document.getElementById('load_more'); if (bigMarkAsRead) { bigMarkAsRead.removeAttribute('disabled'); } -- cgit v1.2.3 From c2a339f2f8a5a9a44d5feaaa8a000f027873d7da Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Mon, 1 Apr 2019 23:47:36 +0200 Subject: [CI] Lint JS scripts with jshint (#2315) --- .jshintignore | 4 ++++ .jshintrc | 8 ++++++++ .travis.yml | 9 +++++++++ p/scripts/install.js | 14 +++++++------- 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 .jshintignore create mode 100644 .jshintrc (limited to 'p/scripts') diff --git a/.jshintignore b/.jshintignore new file mode 100644 index 000000000..80bbc5b89 --- /dev/null +++ b/.jshintignore @@ -0,0 +1,4 @@ +node_modules +p/scripts/bcrypt.min.js +p/scripts/flotr2.min.js +p/scripts/jquery.min.js diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 000000000..07d282b1c --- /dev/null +++ b/.jshintrc @@ -0,0 +1,8 @@ +{ + "esversion" : 6, + "browser" : true, + "globals": { + "confirm": true, + "console": true + } +} diff --git a/.travis.yml b/.travis.yml index 44bc59e3f..1ec2aeb65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,15 @@ matrix: dist: precise - php: "7.2" env: CHECK_TRANSLATION=yes VALIDATE_STANDARD=no + - language: node_js + node_js: + - "node" + php: + # none + install: + - npm install jshint + script: + - node_modules/jshint/bin/jshint . allow_failures: - env: CHECK_TRANSLATION=yes VALIDATE_STANDARD=no - dist: precise diff --git a/p/scripts/install.js b/p/scripts/install.js index b7975fd6e..967d27627 100644 --- a/p/scripts/install.js +++ b/p/scripts/install.js @@ -1,15 +1,15 @@ "use strict"; /* jshint globalstrict: true */ -function show_password() { - var button = this; +function show_password(ev) { + var button = ev.target; var passwordField = document.getElementById(button.getAttribute('data-toggle')); passwordField.setAttribute('type', 'text'); button.className += ' active'; return false; } -function hide_password() { - var button = this; +function hide_password(ev) { + var button = ev.target; var passwordField = document.getElementById(button.getAttribute('data-toggle')); passwordField.setAttribute('type', 'password'); button.className = button.className.replace(/(?:^|\s)active(?!\S)/g , ''); @@ -61,10 +61,10 @@ if (bd_type) { bd_type.addEventListener('change', mySqlShowHide); } -function ask_confirmation(e) { - var str_confirmation = this.getAttribute('data-str-confirm'); +function ask_confirmation(ev) { + var str_confirmation = ev.target.getAttribute('data-str-confirm'); if (!confirm(str_confirmation)) { - e.preventDefault(); + ev.preventDefault(); } } var confirms = document.getElementsByClassName('confirm'); -- cgit v1.2.3 From 8599dc29a17da3bdb7fdb264cadc0944f44d9eaf Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 2 Apr 2019 22:46:56 +0200 Subject: Fix control click (#2330) https://github.com/FreshRSS/FreshRSS/issues/2310 --- p/scripts/main.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 04bf50c81..e8b5dbd4f 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -891,21 +891,28 @@ function init_stream(stream) { } }; - stream.onmouseup = function (ev) { // Mouseup enables us to catch middle click + stream.onmouseup = function (ev) { // Mouseup enables us to catch middle click, and control+click in IE/Edge + if (ev.altKey || ev.metaKey || ev.shiftKey) { + return; + } + let el = ev.target.closest('.item.title > a'); if (el) { - if (ev.ctrlKey) { - return; // CTRL+click, it will be manage by previous rule. - } - if (ev.which == 2) { - // If middle click, we want same behaviour as CTRL+click. - const evc = document.createEvent('click'); - evc.ctrlKey = true; - el.dispatchEvent(evc); - } else if (ev.which == 1) { - // Normal click, just toggle article. - el.parentElement.click(); + if (ev.which == 1) { + if (ev.ctrlKey) { //Control+click + if (context.auto_mark_site) { + mark_read(el.closest('.flux'), true); + } + } else { + el.parentElement.click(); //Normal click, just toggle article. + } + } else if (ev.which == 2 && !ev.ctrlKey) { //Simple middle click: same behaviour as CTRL+click + if (context.auto_mark_article) { + const new_active = el.closest('.flux'); + mark_read(new_active, true); + } } + return; } if (context.auto_mark_site) { -- cgit v1.2.3 From 452419bf83b2b124bb05c58f48b459107595ce0a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 3 Apr 2019 23:08:46 +0200 Subject: Fix auto_remove_article (#2334) * Fix auto_remove_article https://github.com/FreshRSS/FreshRSS/issues/2323 * Second attempt * Third attempt --- p/scripts/main.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index e8b5dbd4f..192d0bdf3 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -590,23 +590,24 @@ function onScroll() { }); } if (context.auto_remove_article) { - let maxTop = box_to_follow.scrollTop, - scrollOffset = 0; - document.querySelectorAll('.flux:not(.active):not(.keep_unread)').forEach(function (div) { + let scrollTop = box_to_follow.scrollTop; + let dirty = false; + document.querySelectorAll('.flux:not(.active):not(.not_read)').forEach(function (div) { if (!pending_entries[div.id] && div.offsetHeight > 0 && - div.offsetParent.offsetTop + div.offsetTop + div.offsetHeight < maxTop) { + div.offsetParent.offsetTop + div.offsetTop + (div.offsetHeight * 2) < scrollTop) { const p = div.previousElementSibling, n = div.nextElementSibling; if (p && p.classList.contains('day') && n && n.classList.contains('day')) { + scrollTop -= p.offsetHeight; p.remove(); } - maxTop -= div.offsetHeight; - scrollOffset -= div.offsetHeight; + scrollTop -= div.offsetHeight; div.remove(); + dirty = true; } }); - if (scrollOffset != 0) { - box_to_follow.scrollTop += scrollOffset; + if (dirty) { + box_to_follow.scrollTop = scrollTop; return; //onscroll will be called again } } -- cgit v1.2.3 From 2efab9893cd0e0e115edadbd21c1bbd6b771df5b Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 3 Apr 2019 23:10:33 +0200 Subject: Fix shortcut problem when showing articles unfolded (#2336) Fix https://github.com/FreshRSS/FreshRSS/issues/2328 --- p/scripts/main.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 192d0bdf3..f22a9079b 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -365,13 +365,12 @@ function toggleContent(new_active, old_active, skipping) { const relative_move = context.current_view === 'global', box_to_move = relative_move ? document.getElementById('panel') : document.documentElement; - if (context.sticky_post) { + if (context.sticky_post) { //Stick the article to the top when opened let prev_article = new_active.previousElementSibling, - new_pos = new_active.offsetTop + document.documentElement.scrollTop, - old_scroll = box_to_move.scrollTop; + new_pos = new_active.offsetParent.offsetTop + new_active.offsetTop; if (prev_article && new_active.offsetTop - prev_article.offsetTop <= 150) { - new_pos = prev_article.offsetTop; + new_pos = prev_article.offsetParent.offsetTop + prev_article.offsetTop; if (relative_move) { new_pos -= box_to_move.offsetTop; } @@ -382,7 +381,7 @@ function toggleContent(new_active, old_active, skipping) { new_pos -= document.body.clientHeight / 4; } if (relative_move) { - new_pos += old_scroll; + new_pos += box_to_move.scrollTop; } box_to_move.scrollTop = new_pos; } -- cgit v1.2.3 From e1bb23ee443820458a14967e873868c44b4c01fe Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 4 Apr 2019 00:02:23 +0200 Subject: Fix scroll functions in Edge (#2337) Use more standard / robust document.scrollingElement --- p/scripts/main.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index f22a9079b..62b965d18 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -2,6 +2,7 @@ /* jshint esversion:6, strict:global */ // +if (!document.scrollingElement) document.scrollingElement = document.documentElement; if (!NodeList.prototype.forEach) NodeList.prototype.forEach = Array.prototype.forEach; if (!Element.prototype.matches) Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.webkitMatchesSelector; if (!Element.prototype.closest) Element.prototype.closest = function (s) { @@ -51,11 +52,11 @@ function badAjax() { } function needsScroll(elem) { - const winBottom = document.documentElement.scrollTop + document.documentElement.clientHeight, + const winBottom = document.scrollingElement.scrollTop + document.scrollingElement.clientHeight, elemTop = elem.offsetParent.offsetTop + elem.offsetTop, elemBottom = elemTop + elem.offsetHeight; - return (elemTop < document.documentElement.scrollTop || elemBottom > winBottom) ? - elemTop - (document.documentElement.clientHeight / 2) : 0; + return (elemTop < document.scrollingElement.scrollTop || elemBottom > winBottom) ? + elemTop - (document.scrollingElement.clientHeight / 2) : 0; } function str2int(str) { @@ -363,7 +364,7 @@ function toggleContent(new_active, old_active, skipping) { } const relative_move = context.current_view === 'global', - box_to_move = relative_move ? document.getElementById('panel') : document.documentElement; + box_to_move = relative_move ? document.getElementById('panel') : document.scrollingElement; if (context.sticky_post) { //Stick the article to the top when opened let prev_article = new_active.previousElementSibling, @@ -528,7 +529,7 @@ function user_filter(key) { // Force scrolling to the filter div const scroll = needsScroll(document.querySelector('.header')); if (scroll !== 0) { - document.documentElement.scrollTop = scroll; + document.scrollingElement.scrollTop = scroll; } // Force the key value if there is only one action, so we can trigger it automatically if (filters.length === 1) { @@ -556,7 +557,7 @@ function auto_share(key) { // Force scrolling to the share div const scrollTop = needsScroll(share.closest('.bottom')); if (scrollTop !== 0) { - document.documentElement.scrollTop = scrollTop; + document.scrollingElement.scrollTop = scrollTop; } // Force the key value if there is only one action, so we can trigger it automatically if (shares.length === 1) { @@ -621,10 +622,10 @@ function onScroll() { function init_posts() { if (context.auto_load_more || context.auto_mark_scroll || context.auto_remove_article) { - box_to_follow = context.current_view === 'global' ? document.getElementById('panel') : document.documentElement; + box_to_follow = context.current_view === 'global' ? document.getElementById('panel') : document.scrollingElement; let lastScroll = 0, //Throttle timerId = 0; - (box_to_follow === document.documentElement ? window : box_to_follow).onscroll = function () { + (box_to_follow === document.scrollingElement ? window : box_to_follow).onscroll = function () { clearTimeout(timerId); if (lastScroll + 500 < Date.now()) { lastScroll = Date.now(); @@ -987,10 +988,10 @@ function init_nav_entries() { }; nav_entries.querySelector('.up').onclick = function (e) { const active_item = document.querySelector('.flux.current'), - windowTop = document.documentElement.scrollTop, + windowTop = document.scrollingElement.scrollTop, item_top = active_item.offsetParent.offsetTop + active_item.offsetTop; - document.documentElement.scrollTop = windowTop > item_top ? item_top : 0; + document.scrollingElement.scrollTop = windowTop > item_top ? item_top : 0; return false; }; } -- cgit v1.2.3 From 09a5b4493d94120f836b85db5b84c0db7309a4ca Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 6 Apr 2019 09:24:22 +0200 Subject: Better handling of bad request and fast unload (#2346) * Better handling of bad request and fast unload Warnings for bad requests, confirmation before leaving a page with pending mark-as-read requests (not the others for now) * Fix callbacks --- p/scripts/main.js | 60 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 21 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 62b965d18..48d88d15b 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -45,9 +45,11 @@ var context; }()); // -function badAjax() { +function badAjax(reload) { openNotification(context.i18n.notif_request_failed, 'bad'); - location.reload(); + if (reload) { + setTimeout(function () { location.reload(); }, 2000); + } return true; } @@ -168,19 +170,19 @@ function send_mark_read_queue(queue, asRead, callback) { req.open('POST', '.?c=entry&a=read' + (asRead ? '' : '&is_read=0'), true); req.responseType = 'json'; req.onerror = function (e) { - openNotification(context.i18n.notif_request_failed, 'bad'); for (let i = queue.length - 1; i >= 0; i--) { delete pending_entries['flux_' + queue[i]]; } - if (this.status == 403) { - badAjax(); - } + badAjax(this.status == 403); }; req.onload = function (e) { if (this.status != 200) { return req.onerror(e); } const json = xmlHttpRequestJson(this); + if (!json) { + return req.onerror(e); + } for (let i = queue.length - 1; i >= 0; i--) { const div = document.getElementById('flux_' + queue[i]), myIcons = context.icons; @@ -238,10 +240,11 @@ function send_mark_queue_tick(callback) { mark_read_queue = []; send_mark_read_queue(queue, true, callback); } +var delayedFunction = send_mark_queue_tick; function delayedClick(a) { if (a) { - send_mark_queue_tick(function () { a.click(); }); + delayedFunction(function () { a.click(); }); } } @@ -288,17 +291,17 @@ function mark_favorite(div) { req.open('POST', url, true); req.responseType = 'json'; req.onerror = function (e) { - openNotification(context.i18n.notif_request_failed, 'bad'); delete pending_entries[div.id]; - if (this.status == 403) { - badAjax(); - } + badAjax(this.status == 403); }; req.onload = function (e) { if (this.status != 200) { return req.onerror(e); } const json = xmlHttpRequestJson(this); + if (!json) { + return req.onerror(e); + } let inc = 0; if (div.classList.contains('favorite')) { div.classList.remove('favorite'); @@ -945,9 +948,7 @@ function init_stream(stream) { req.responseType = 'json'; req.onerror = function (e) { checkboxTag.checked = !isChecked; - if (this.status == 403) { - badAjax(); - } + badAjax(this.status == 403); }; req.onload = function (e) { if (this.status != 200) { @@ -1014,6 +1015,9 @@ function loadDynamicTags(div) { return req.onerror(e); } const json = xmlHttpRequestJson(this); + if (!json) { + return req.onerror(e); + } let html = '
  • '; if (json && json.length) { for (let i = 0; i < json.length; i++) { @@ -1039,7 +1043,7 @@ function updateFeed(feeds, feeds_count) { req.open('POST', feed.url, true); req.onloadend = function (e) { if (this.status != 200) { - return badAjax(); + return badAjax(false); } feed_processed++; const div = document.getElementById('actualizeProgress'); @@ -1050,7 +1054,7 @@ function updateFeed(feeds, feeds_count) { const req2 = new XMLHttpRequest(); req2.open('POST', './?c=feed&a=actualize&id=-1&ajax=1', true); req2.onloadend = function (e) { - location.reload(); + delayedFunction(function () { location.reload(); }); }; req2.setRequestHeader('Content-Type', 'application/json'); req2.send(JSON.stringify({ @@ -1082,9 +1086,12 @@ function init_actualize() { req.responseType = 'json'; req.onload = function (e) { if (this.status != 200) { - return badAjax(); + return badAjax(false); } const json = xmlHttpRequestJson(this); + if (!json) { + return badAjax(false); + } if (auto && json.feeds.length < 1) { auto = false; context.ajax_loading = false; @@ -1192,10 +1199,12 @@ function notifs_html5_show(nb) { }); notification.onclick = function () { - location.reload(); - window.focus(); - notification.close(); - }; + delayedFunction(function() { + location.reload(); + window.focus(); + notification.close(); + }); + }; if (context.html5_notif_timeout !== 0) { setTimeout(function () { @@ -1219,6 +1228,9 @@ function refreshUnreads() { req.responseType = 'json'; req.onload = function (e) { const json = xmlHttpRequestJson(this); + if (!json) { + return badAjax(false); + } const isAll = document.querySelector('.category.all.active'); let new_articles = false; @@ -1413,6 +1425,12 @@ function init_normal() { init_shortcuts(); init_actualize(); faviconNbUnread(); + + window.onbeforeunload = function (e) { + if (mark_read_queue && mark_read_queue.length > 0) { + return false; + } + }; } function init_beforeDOM() { -- cgit v1.2.3 From 0a067dbcd4f1c8958a1c7945fbbc8780b88c8d8a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 6 Apr 2019 15:51:39 +0200 Subject: Fix hide articles + batch option (#2349) https://github.com/FreshRSS/FreshRSS/issues/2332 https://github.com/FreshRSS/FreshRSS/issues/2345 Re-introduces the instant-remove article. Batch mark-as-read only used for fast actions like scroll and keyboard shortcut for next/previous articles. --- p/scripts/main.js | 67 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 33 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 48d88d15b..286764d22 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -162,6 +162,26 @@ function incUnreadsTag(tag_id, nb) { } } +function removeArticle(div) { + let scrollTop = box_to_follow.scrollTop; + let dirty = false; + const p = div.previousElementSibling, + n = div.nextElementSibling; + if (p && p.classList.contains('day') && n && n.classList.contains('day')) { + scrollTop -= p.offsetHeight; + dirty = true; + p.remove(); + } + if (div.offsetHeight > 0 && div.offsetParent.offsetTop + div.offsetTop + div.offsetHeight < scrollTop) { + scrollTop -= div.offsetHeight; + dirty = true; + } + div.remove(); + if (dirty) { + box_to_follow.scrollTop = scrollTop; + } +} + var pending_entries = {}, mark_read_queue = []; @@ -194,6 +214,9 @@ function send_mark_read_queue(queue, asRead, callback) { }); div.querySelectorAll('a.read > .icon').forEach(function (img) { img.outerHTML = myIcons.read; }); inc--; + if (context.auto_remove_article) { + removeArticle(div); + } } else { div.classList.add('not_read'); div.classList.add('keep_unread'); //Split for IE11 @@ -248,7 +271,7 @@ function delayedClick(a) { } } -function mark_read(div, only_not_read) { +function mark_read(div, only_not_read, asBatch) { if (!div || !div.id || context.anonymous || (only_not_read && !div.classList.contains('not_read'))) { return false; @@ -260,7 +283,7 @@ function mark_read(div, only_not_read) { const asRead = div.classList.contains('not_read'), entryId = div.id.replace(/^flux_/, ''); - if (asRead) { + if (asRead && asBatch) { mark_read_queue.push(entryId); if (send_mark_read_queue_timeout == 0) { send_mark_read_queue_timeout = setTimeout(function () { send_mark_queue_tick(null); }, 1000); @@ -392,7 +415,7 @@ function toggleContent(new_active, old_active, skipping) { if (new_active.classList.contains('active') && !skipping) { if (context.auto_mark_article) { - mark_read(new_active, true); + mark_read(new_active, true, true); } new_active.dispatchEvent(freshrssOpenArticleEvent); } @@ -588,32 +611,10 @@ function onScroll() { document.querySelectorAll('.not_read:not(.keep_unread)').forEach(function (div) { if (div.offsetHeight > 0 && div.offsetParent.offsetTop + div.offsetTop + div.offsetHeight < minTop) { - mark_read(div, true); + mark_read(div, true, true); } }); } - if (context.auto_remove_article) { - let scrollTop = box_to_follow.scrollTop; - let dirty = false; - document.querySelectorAll('.flux:not(.active):not(.not_read)').forEach(function (div) { - if (!pending_entries[div.id] && div.offsetHeight > 0 && - div.offsetParent.offsetTop + div.offsetTop + (div.offsetHeight * 2) < scrollTop) { - const p = div.previousElementSibling, - n = div.nextElementSibling; - if (p && p.classList.contains('day') && n && n.classList.contains('day')) { - scrollTop -= p.offsetHeight; - p.remove(); - } - scrollTop -= div.offsetHeight; - div.remove(); - dirty = true; - } - }); - if (dirty) { - box_to_follow.scrollTop = scrollTop; - return; //onscroll will be called again - } - } if (context.auto_load_more) { const pagination = document.getElementById('mark-read-pagination'); if (pagination && box_to_follow.offsetHeight > 0 && @@ -749,7 +750,7 @@ function init_shortcuts() { } else if (ev.shiftKey) { // Mark everything as read document.querySelector('.nav_menu .read_all').click(); } else { // Toggle the read state - mark_read(document.querySelector('.flux.current'), false); + mark_read(document.querySelector('.flux.current'), false, false); } return false; } @@ -791,7 +792,7 @@ function init_shortcuts() { } if (k === s.go_website) { if (context.auto_mark_site) { - mark_read(document.querySelector('.flux.current'), true); + mark_read(document.querySelector('.flux.current'), true, false); } window.open(document.querySelector('.flux.current a.go_website').href); return false; @@ -817,7 +818,7 @@ function init_stream(stream) { stream.onclick = function (ev) { let el = ev.target.closest('.flux a.read'); if (el) { - mark_read(el.closest('.flux'), false); + mark_read(el.closest('.flux'), false, false); return false; } @@ -886,7 +887,7 @@ function init_stream(stream) { new_active = el.parentNode; if (ev.target.tagName.toUpperCase() === 'A') { //Leave real links alone if (context.auto_mark_article) { - mark_read(new_active, true); + mark_read(new_active, true, false); } return true; } @@ -905,7 +906,7 @@ function init_stream(stream) { if (ev.which == 1) { if (ev.ctrlKey) { //Control+click if (context.auto_mark_site) { - mark_read(el.closest('.flux'), true); + mark_read(el.closest('.flux'), true, false); } } else { el.parentElement.click(); //Normal click, just toggle article. @@ -913,7 +914,7 @@ function init_stream(stream) { } else if (ev.which == 2 && !ev.ctrlKey) { //Simple middle click: same behaviour as CTRL+click if (context.auto_mark_article) { const new_active = el.closest('.flux'); - mark_read(new_active, true); + mark_read(new_active, true, false); } } return; @@ -927,7 +928,7 @@ function init_stream(stream) { if (ev.which == 3) { return; } - mark_read(el.closest('.flux'), true); + mark_read(el.closest('.flux'), true, false); } } }; -- cgit v1.2.3 From 43e3a2d69dc6343f3e30e7c3e3e1cb396a5650a1 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 6 Apr 2019 16:45:21 +0200 Subject: Fix autoremove again (#2352) Fix https://github.com/FreshRSS/FreshRSS/pull/2349 --- p/scripts/main.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 286764d22..a44a22c6a 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -163,6 +163,9 @@ function incUnreadsTag(tag_id, nb) { } function removeArticle(div) { + if (!div || div.classList.contains('active') || div.classList.contains('not_read')) { + return; + } let scrollTop = box_to_follow.scrollTop; let dirty = false; const p = div.previousElementSibling, @@ -384,6 +387,9 @@ function toggleContent(new_active, old_active, skipping) { if (old_active) { old_active.classList.remove('active'); old_active.classList.remove('current'); //Split for IE11 + if (context.auto_remove_article) { + removeArticle(old_active); + } } } else { new_active.classList.toggle('active'); -- cgit v1.2.3 From 1b7cf6b0354c6b665d5a6ff8d3f6c4b52be6fbd6 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 6 Apr 2019 17:05:53 +0200 Subject: Fix menu warning (#2353) confirm is only for labels, not for feeds --- p/scripts/main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index a44a22c6a..215d4117b 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -692,7 +692,10 @@ function init_column_categories() { a.href = '#dropdown-' + id; div.querySelector('.dropdown-target').id = 'dropdown-' + id; div.insertAdjacentHTML('beforeend', template); - div.querySelector('button.confirm').disabled = false; + const b = div.querySelector('button.confirm'); + if (b) { + b.disabled = false; + } } else if (getComputedStyle(dropdownMenu).display === 'none') { const id2 = div.closest('.item').id.substr(2); a.href = '#dropdown-' + id2; -- cgit v1.2.3 From aef3f8d71beae6dfd551617d03ec8fcdb53549e4 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 7 Apr 2019 00:29:37 +0200 Subject: Alow mix of auto read options (#2354) Fix https://github.com/FreshRSS/FreshRSS/pull/2349#issuecomment-480540126 --- p/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 215d4117b..d85a3ae15 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -163,7 +163,7 @@ function incUnreadsTag(tag_id, nb) { } function removeArticle(div) { - if (!div || div.classList.contains('active') || div.classList.contains('not_read')) { + if (!div || div.classList.contains('not_read') || (context.auto_mark_article && div.classList.contains('active'))) { return; } let scrollTop = box_to_follow.scrollTop; -- cgit v1.2.3