Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: chrome/browser/resources/md_downloads/crisper.js

Issue 2337513002: Only handle click actions for left & middle buttons (Closed)
Patch Set: vulanize the resources Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/history/other_devices.js ('k') | chrome/browser/resources/ntp4/new_tab.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/md_downloads/crisper.js
diff --git a/chrome/browser/resources/md_downloads/crisper.js b/chrome/browser/resources/md_downloads/crisper.js
index 55db37276f878b9e72f751573f00b9f95113255b..e78cb0824f8afad58b51ad06c32985558763a8a3 100644
--- a/chrome/browser/resources/md_downloads/crisper.js
+++ b/chrome/browser/resources/md_downloads/crisper.js
@@ -648,6 +648,7 @@ function queryRequiredElement(selectors, opt_context) {
[ 'click', 'auxclick' ].forEach(function(eventName) {
document.addEventListener(eventName, function(e) {
+ if (e.button > 1) return;
if (e.defaultPrevented) return;
var eventPath = e.path;
var anchor = null;
@@ -733,6 +734,19 @@ function quoteString(str) {
return str.replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, '\\$1');
}
+function listenOnce(target, eventNames, callback) {
+ if (!Array.isArray(eventNames)) eventNames = eventNames.split(/ +/);
+ var removeAllAndCallCallback = function(event) {
+ eventNames.forEach(function(eventName) {
+ target.removeEventListener(eventName, removeAllAndCallCallback, false);
+ });
+ return callback(event);
+ };
+ eventNames.forEach(function(eventName) {
+ target.addEventListener(eventName, removeAllAndCallCallback, false);
+ });
+}
+
// <if expr="is_ios">
if (!('key' in KeyboardEvent.prototype)) {
Object.defineProperty(KeyboardEvent.prototype, 'key', {
« no previous file with comments | « chrome/browser/resources/history/other_devices.js ('k') | chrome/browser/resources/ntp4/new_tab.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698