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

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

Issue 668983004: Add <a is="action-link">, a web component extension of <a> for in-page actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years, 1 month 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 | « ui/webui/resources/js/action_link.js ('k') | ui/webui/resources/webui_resources.grd » ('j') | 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. 8 * Alias for document.getElementById.
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 }; 220 };
221 221
222 // Disable dragging. 222 // Disable dragging.
223 document.ondragstart = function(e) { 223 document.ondragstart = function(e) {
224 if (!(opt_allowDragStart && opt_allowDragStart.call(this, e))) 224 if (!(opt_allowDragStart && opt_allowDragStart.call(this, e)))
225 e.preventDefault(); 225 e.preventDefault();
226 }; 226 };
227 } 227 }
228 228
229 /** 229 /**
230 * TODO(dbeam): DO NOT USE. THIS IS DEPRECATED. Use an action-link instead.
230 * Call this to stop clicks on <a href="#"> links from scrolling to the top of 231 * Call this to stop clicks on <a href="#"> links from scrolling to the top of
231 * the page (and possibly showing a # in the link). 232 * the page (and possibly showing a # in the link).
232 */ 233 */
233 function preventDefaultOnPoundLinkClicks() { 234 function preventDefaultOnPoundLinkClicks() {
234 document.addEventListener('click', function(e) { 235 document.addEventListener('click', function(e) {
235 var anchor = findAncestor(/** @type {Node} */(e.target), function(el) { 236 var anchor = findAncestor(/** @type {Node} */(e.target), function(el) {
236 return el.tagName == 'A'; 237 return el.tagName == 'A';
237 }); 238 });
238 // Use getAttribute() to prevent URL normalization. 239 // Use getAttribute() to prevent URL normalization.
239 if (anchor && anchor.getAttribute('href') == '#') 240 if (anchor && anchor.getAttribute('href') == '#')
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 * @param {number} maxLength The maximum length allowed for the string. 447 * @param {number} maxLength The maximum length allowed for the string.
447 * @return {string} The original string if its length does not exceed 448 * @return {string} The original string if its length does not exceed
448 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...' 449 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...'
449 * appended. 450 * appended.
450 */ 451 */
451 function elide(original, maxLength) { 452 function elide(original, maxLength) {
452 if (original.length <= maxLength) 453 if (original.length <= maxLength)
453 return original; 454 return original;
454 return original.substring(0, maxLength - 1) + '\u2026'; 455 return original.substring(0, maxLength - 1) + '\u2026';
455 } 456 }
OLDNEW
« no previous file with comments | « ui/webui/resources/js/action_link.js ('k') | ui/webui/resources/webui_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698