From c2ca9805fa61d045fa5466a8c3ba88d8a0c5a299 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 16 Sep 2014 17:44:51 +0200 Subject: [PATCH] Same behaviour for middle click on article Middle click was not catched by JavaScript so when opening article in a new page, itwas not marked as read. See https://github.com/marienfressinaud/FreshRSS/issues/454 --- p/scripts/main.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/p/scripts/main.js b/p/scripts/main.js index 7c3be3af4..fd49d62ba 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -702,11 +702,25 @@ function init_stream(divStream) { }); divStream.on('click', '.item.title > a', function (e) { + // Allow default control-click behaviour such as open in backround-tab. + return e.ctrlKey; + }); + divStream.on('mouseup', '.item.title > a', function (e) { + // Mouseup enables us to catch middle click. if (e.ctrlKey) { - return true; //Allow default control-click behaviour such as open in backround-tab + // CTRL+click, it will be manage by previous rule. + return; + } + + if (e.which == 2) { + // If middle click, we want same behaviour as CTRL+click. + var e = jQuery.Event("click"); + e.ctrlKey = true; + $(this).trigger(e); + } else if(e.which == 1) { + // Normal click, just toggle article. + $(this).parent().click(); } - $(this).parent().click(); //Will perform toggle flux_content - return false; }); divStream.on('click', '.flux .content a', function () { @@ -714,7 +728,13 @@ function init_stream(divStream) { }); if (auto_mark_site) { - divStream.on('click', '.flux .link > a', function () { + // catch mouseup instead of click so we can have the correct behaviour + // with middle button click (scroll button). + divStream.on('mouseup', '.flux .link > a', function (e) { + if (e.which == 3) { + return; + } + mark_read($(this).parents(".flux"), true); }); }