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

Side by Side Diff: ui/webui/resources/js/util.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 unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // <include src="assert.js"> 5 // <include src="assert.js">
6 6
7 /** 7 /**
8 * Alias for document.getElementById. Found elements must be HTMLElements. 8 * Alias for document.getElementById. Found elements must be HTMLElements.
9 * @param {string} id The ID of the element to find. 9 * @param {string} id The ID of the element to find.
10 * @return {HTMLElement} The found element or null if not found. 10 * @return {HTMLElement} The found element or null if not found.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 function queryRequiredElement(selectors, opt_context) { 207 function queryRequiredElement(selectors, opt_context) {
208 var element = (opt_context || document).querySelector(selectors); 208 var element = (opt_context || document).querySelector(selectors);
209 return assertInstanceof(element, HTMLElement, 209 return assertInstanceof(element, HTMLElement,
210 'Missing required element: ' + selectors); 210 'Missing required element: ' + selectors);
211 } 211 }
212 212
213 // Handle click on a link. If the link points to a chrome: or file: url, then 213 // Handle click on a link. If the link points to a chrome: or file: url, then
214 // call into the browser to do the navigation. 214 // call into the browser to do the navigation.
215 ['click', 'auxclick'].forEach(function(eventName) { 215 ['click', 'auxclick'].forEach(function(eventName) {
216 document.addEventListener(eventName, function(e) { 216 document.addEventListener(eventName, function(e) {
217 if (e.button > 1)
218 return; // Ignore buttons other than left and middle.
217 if (e.defaultPrevented) 219 if (e.defaultPrevented)
218 return; 220 return;
219 221
220 var eventPath = e.path; 222 var eventPath = e.path;
221 var anchor = null; 223 var anchor = null;
222 if (eventPath) { 224 if (eventPath) {
223 for (var i = 0; i < eventPath.length; i++) { 225 for (var i = 0; i < eventPath.length; i++) {
224 var element = eventPath[i]; 226 var element = eventPath[i];
225 if (element.tagName === 'A' && element.href) { 227 if (element.tagName === 'A' && element.href) {
226 anchor = element; 228 anchor = element;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 case 0xdb: return '['; 479 case 0xdb: return '[';
478 case 0xdd: return ']'; 480 case 0xdd: return ']';
479 } 481 }
480 return 'Unidentified'; 482 return 'Unidentified';
481 } 483 }
482 }); 484 });
483 } else { 485 } else {
484 window.console.log("KeyboardEvent.Key polyfill not required"); 486 window.console.log("KeyboardEvent.Key polyfill not required");
485 } 487 }
486 // </if> /* is_ios */ 488 // </if> /* is_ios */
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698