OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |