Просмотр исходного кода

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
Marien Fressinaud 11 лет назад
Родитель
Сommit
c2ca9805fa
1 измененных файлов с 24 добавлено и 4 удалено
  1. 24 4
      p/scripts/main.js

+ 24 - 4
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);
 		});
 	}