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

Side by Side Diff: ui/webui/resources/js/cr/ui.js

Issue 12614002: Fixing ignored clicks after the 'Undo delete' command in Bookmark manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 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 | « no previous file | 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 cr.define('cr.ui', function() { 5 cr.define('cr.ui', function() {
6 6
7 /** 7 /**
8 * Decorates elements as an instance of a class. 8 * Decorates elements as an instance of a class.
9 * @param {string|!Element} source The way to find the element(s) to decorate. 9 * @param {string|!Element} source The way to find the element(s) to decorate.
10 * If this is a string then {@code querySeletorAll} is used to find the 10 * If this is a string then {@code querySeletorAll} is used to find the
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 169 }
170 170
171 /** 171 /**
172 * Users complain they occasionaly use doubleclicks instead of clicks 172 * Users complain they occasionaly use doubleclicks instead of clicks
173 * (http://crbug.com/140364). To fix it we freeze click handling for 173 * (http://crbug.com/140364). To fix it we freeze click handling for
174 * the doubleclick time interval. 174 * the doubleclick time interval.
175 * @param {MouseEvent} e Initial click event. 175 * @param {MouseEvent} e Initial click event.
176 */ 176 */
177 function swallowDoubleClick(e) { 177 function swallowDoubleClick(e) {
178 var doc = e.target.ownerDocument; 178 var doc = e.target.ownerDocument;
179 var counter = e.type == 'click' ? e.detail : 0; 179 var counter = Math.min(1, e.detail);
180 function swallow(e) { 180 function swallow(e) {
181 e.stopPropagation(); 181 e.stopPropagation();
182 e.preventDefault(); 182 e.preventDefault();
183 } 183 }
184 function onclick(e) { 184 function onclick(e) {
185 if (e.detail > counter) { 185 if (e.detail > counter) {
186 counter = e.detail; 186 counter = e.detail;
187 // Swallow the click since it's a click inside the doubleclick timeout. 187 // Swallow the click since it's a click inside the doubleclick timeout.
188 swallow(e); 188 swallow(e);
189 } else { 189 } else {
190 // Stop tracking clicks and let regular handling. 190 // Stop tracking clicks and let regular handling.
191 doc.removeEventListener('dblclick', swallow, true); 191 doc.removeEventListener('dblclick', swallow, true);
192 doc.removeEventListener('click', onclick, true); 192 doc.removeEventListener('click', onclick, true);
193 } 193 }
194 } 194 }
195 doc.addEventListener('click', onclick, true); 195 // The following 'click' event (if e.type == 'mouseup') mustn't be taken
196 doc.addEventListener('dblclick', swallow, true); 196 // into account (it mustn't stop tracking clicks). Start event listening
197 // after zero timeout.
198 setTimeout(function() {
199 doc.addEventListener('click', onclick, true);
200 doc.addEventListener('dblclick', swallow, true);
201 }, 0);
197 } 202 }
198 203
199 return { 204 return {
200 decorate: decorate, 205 decorate: decorate,
201 define: define, 206 define: define,
202 limitInputWidth: limitInputWidth, 207 limitInputWidth: limitInputWidth,
203 toCssPx: toCssPx, 208 toCssPx: toCssPx,
204 swallowDoubleClick: swallowDoubleClick 209 swallowDoubleClick: swallowDoubleClick
205 }; 210 };
206 }); 211 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698