summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-09-16 17:44:51 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-09-16 17:46:16 +0200
commitc2ca9805fa61d045fa5466a8c3ba88d8a0c5a299 (patch)
tree5e48bf0f4ee11fd212eabc91d90d7ca18056af8d
parent7eb71edecf0b4eb6018bc10bcffc2441996489d3 (diff)
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
-rw-r--r--p/scripts/main.js28
1 files 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);
});
}