Chromium Code Reviews| Index: chrome/browser/resources/ntp4/synthetic_middleclick.js |
| diff --git a/chrome/browser/resources/ntp4/synthetic_middleclick.js b/chrome/browser/resources/ntp4/synthetic_middleclick.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6981fec1ded0cf85babb1807d83e9883dac1be4b |
| --- /dev/null |
| +++ b/chrome/browser/resources/ntp4/synthetic_middleclick.js |
| @@ -0,0 +1,18 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +(function() { |
|
Dan Beam
2016/05/24 18:17:25
\n are well worth the bytes
(function() {
var mi
Navid Zolghadr
2016/05/24 18:38:23
Sure. Done.
|
| +var middleButtonMouseDownTarget = null; |
| +document.addEventListener('mousedown', function(e) { |
| + if (e.button == 1) |
| + middleButtonMouseDownTarget = e.path[0]; |
| +}, true); |
| +document.addEventListener('mouseup', function(e) { |
| + if (e.button == 1) { |
| + if (e.path[0] == middleButtonMouseDownTarget) |
| + e.path[0].dispatchEvent(new MouseEvent('click', e)); |
| + middleButtonMouseDownTarget = null; |
| + } |
| +}, true); |
| +})(); |