From 80952f29b02e23446e9b2a8cc8aa7715df1bf1f1 Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Sat, 3 Jan 2015 00:49:29 +0100 Subject: [PATCH] middle mouse button triggers event for all browser This is a follow up to #1. The onclick event is triggered by different mouse buttons across browsers: Firefox - all mouse buttons trigger document.onclick (https://bugzilla.mozilla.org/show_bug.cgi?id=430310) - only left mouse button triggers document.body.onclick Internet Explorer - only left mouse button and without any modifier key triggers document.onclick Chrome - left & middle mouse button trigger document.onclick Safari - left mouse button triggers document.onclick - middle click via mac os? By switching to the onmouseup event this can be unified for all mentioned browsers to: - (CTRL+) left click triggers event - middle click triggers event - right click does nothing --- assets/js/all.min.js | 34 +++++++++++++++++----------------- assets/js/event.js | 30 +++++++++++++++++------------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/assets/js/all.min.js b/assets/js/all.min.js index 249eb8f..af8d444 100644 --- a/assets/js/all.min.js +++ b/assets/js/all.min.js @@ -1,20 +1,20 @@ var Miniflux={};Miniflux.App=function(){return{Run:function(){Miniflux.Event.ListenKeyboardEvents();Miniflux.Event.ListenMouseEvents()}}}(); -Miniflux.Feed=function(){var e=[];return{Update:function(c,b){var a=c.querySelector("span.items-count");if(a){var e=c.getAttribute("data-feed-id"),d=c.querySelector("h2:first-of-type");d.className="loading-icon";var f=new XMLHttpRequest;f.onload=function(){d.className="";var f=c.querySelector(".feed-last-checked");f&&(f.innerHTML=f.getAttribute("data-after-update"));if(f=c.querySelector(".feed-parsing-error"))f.innerHTML="";var e=JSON.parse(this.responseText);e.result?a.innerHTML=e.items_count.items_unread+ -"/"+e.items_count.items_total:f&&(f.innerHTML=f.getAttribute("data-after-error"));b&&b(e)};f.open("POST","?action=refresh-feed&feed_id="+e,!0);f.send()}},UpdateAll:function(){var c=Array.prototype.slice.call(document.querySelectorAll("article:not([data-feed-disabled])")),b=setInterval(function(){for(;0e.length;){var a=c.shift();e.push(parseInt(a.getAttribute("data-feed-id")));Miniflux.Feed.Update(a,function(a){a=e.indexOf(a.feed_id);0<=a&&e.splice(a,1);0===c.length&&0===e.length&&(clearInterval(b), +Miniflux.Feed=function(){var d=[];return{Update:function(c,a){var b=c.querySelector("span.items-count");if(b){var d=c.getAttribute("data-feed-id"),e=c.querySelector("h2:first-of-type");e.className="loading-icon";var f=new XMLHttpRequest;f.onload=function(){e.className="";var f=c.querySelector(".feed-last-checked");f&&(f.innerHTML=f.getAttribute("data-after-update"));if(f=c.querySelector(".feed-parsing-error"))f.innerHTML="";var d=JSON.parse(this.responseText);d.result?b.innerHTML=d.items_count.items_unread+ +"/"+d.items_count.items_total:f&&(f.innerHTML=f.getAttribute("data-after-error"));a&&a(d)};f.open("POST","?action=refresh-feed&feed_id="+d,!0);f.send()}},UpdateAll:function(){var c=Array.prototype.slice.call(document.querySelectorAll("article:not([data-feed-disabled])")),a=setInterval(function(){for(;0d.length;){var b=c.shift();d.push(parseInt(b.getAttribute("data-feed-id")));Miniflux.Feed.Update(b,function(b){b=d.indexOf(b.feed_id);0<=b&&d.splice(b,1);0===c.length&&0===d.length&&(clearInterval(a), window.location.href="?action=unread")})}},100)}}}(); -Miniflux.Item=function(){function e(d){return item_id=d.getAttribute("data-item-id")}function c(d){if(d&&d.hasAttribute("data-reverse-label")){var b=d.innerHTML;d.innerHTML=d.getAttribute("data-reverse-label");d.setAttribute("data-reverse-label",b)}}function b(d){"mouse"!==Miniflux.Event.lastEventType&&Miniflux.Nav.SelectNextItem();d.parentNode.removeChild(d);if(d=document.getElementById("page-counter")){var b=document.querySelector("section.page"),c=parseInt(d.textContent,10)-1,a=document.getElementsByTagName("article"); -if(0===c||0===a.length)window.location=location.href;d.textContent=c;switch(b.getAttribute("data-item-page")){case "unread":document.title="Miniflux ("+c+")";document.getElementById("nav-counter").textContent=c;break;case "feed-items":document.title="("+c+") "+d.parentNode.firstChild.nodeValue;break;default:document.title=d.parentNode.firstChild.nodeValue+" ("+c+")"}}}function a(d){var f=e(d),a=new XMLHttpRequest;a.onload=function(){if(Miniflux.Nav.IsListing())if(d.getAttribute("data-hide"))b(d); -else{d.setAttribute("data-item-status","read");var a=d.querySelector("a.mark");c(a);(a=d.querySelector("a.mark"))&&a.setAttribute("data-action","mark-unread")}};a.open("POST","?action=mark-item-read&id="+f,!0);a.send()}function g(d){var a=e(d),k=new XMLHttpRequest;k.onload=function(){if(Miniflux.Nav.IsListing())if(d.getAttribute("data-hide"))b(d);else{d.setAttribute("data-item-status","unread");var a=d.querySelector("a.mark");c(a);(a=d.querySelector("a.mark"))&&a.setAttribute("data-action","mark-read")}}; -k.open("POST","?action=mark-item-unread&id="+a,!0);k.send()}return{MarkAsRead:a,MarkAsUnread:g,MarkAsRemoved:function(d){var a=e(d),c=new XMLHttpRequest;c.onload=function(){Miniflux.Nav.IsListing()&&b(d)};c.open("POST","?action=mark-item-removed&id="+a,!0);c.send()},SwitchBookmark:function(d){var a=e(d),k="1"===d.getAttribute("data-item-bookmark")?"0":"1",h=new XMLHttpRequest;h.onload=function(){var a=document.querySelector("section.page");if(Miniflux.Nav.IsListing()&&"bookmarks"===a.getAttribute("data-item-page"))b(d); -else if(d.setAttribute("data-item-bookmark",k),Miniflux.Nav.IsListing())a=d.querySelector("a.bookmark"),c(a);else if((a=d.querySelector("a.bookmark-icon"))&&a.hasAttribute("data-reverse-title")){var f=a.getAttribute("title");a.setAttribute("title",a.getAttribute("data-reverse-title"));a.setAttribute("data-reverse-title",f)}};h.open("POST","?action=bookmark&id="+a+"&value="+k,!0);h.send()},SwitchStatus:function(d){var b=d.getAttribute("data-item-status");"read"===b?g(d):"unread"===b&&a(d)},Show:function(a){(a= -a.querySelector("a.show"))&&a.click()},OpenOriginal:function(b){var c=b.querySelector("a.original");c&&("unread"===b.getAttribute("data-item-status")&&a(b),c.removeAttribute("data-action"),"mouse"!==Miniflux.Event.lastEventType&&c.click())},DownloadContent:function(a){var b=document.getElementById("download-item");if(b){b.innerHTML=" "+b.getAttribute("data-before-message");b.className="loading-icon";var c=new XMLHttpRequest;c.onload=function(){var a=JSON.parse(c.responseText);b.className="";if(a.result){var d= -document.getElementById("item-content");d&&(d.innerHTML=a.content);b.innerHTML=b.getAttribute("data-after-message")}else b.innerHTML=b.getAttribute("data-failure-message")};a=e(a);c.open("POST","?action=download-item&id="+a,!0);c.send()}},MarkListingAsRead:function(a){for(var b=document.getElementsByTagName("article"),c=[],h=0,g=b.length;ha-(b.offsetTop+b.offsetHeight)||a-b.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,b.offsetTop-10)}function c(){return document.getElementById("listing")?!0:!1}return{OpenNextPage:function(){var b=document.getElementById("next-page");b&&b.click()},OpenPreviousPage:function(){var b=document.getElementById("previous-page");b&&b.click()},SelectNextItem:function(){var b=document.getElementById("next-item"); -if(b)b.click();else if(c())if(b=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var a=0,g=b.length;ab-(a.offsetTop+a.offsetHeight)||b-a.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,a.offsetTop-10)}function c(){return document.getElementById("listing")?!0:!1}return{OpenNextPage:function(){var a=document.getElementById("next-page");a&&a.click()},OpenPreviousPage:function(){var a=document.getElementById("previous-page");a&&a.click()},SelectNextItem:function(){var a=document.getElementById("next-item"); +if(a)a.click();else if(c())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var b=0,h=a.length;b