| 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 // TODO(arv): Now that this is driven by a data model, implement a data model | 5 // TODO(arv): Now that this is driven by a data model, implement a data model |
| 6 // that handles the loading and the events from the bookmark backend. | 6 // that handles the loading and the events from the bookmark backend. |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * @typedef {{childIds: Array<string>}} | 9 * @typedef {{childIds: Array<string>}} |
| 10 * | 10 * |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 var urlEl = labelEl.nextSibling; | 472 var urlEl = labelEl.nextSibling; |
| 473 var labelInput, urlInput; | 473 var labelInput, urlInput; |
| 474 | 474 |
| 475 // Handles enter and escape which trigger reset and commit respectively. | 475 // Handles enter and escape which trigger reset and commit respectively. |
| 476 function handleKeydown(e) { | 476 function handleKeydown(e) { |
| 477 // Make sure that the tree does not handle the key. | 477 // Make sure that the tree does not handle the key. |
| 478 e.stopPropagation(); | 478 e.stopPropagation(); |
| 479 | 479 |
| 480 // Calling list.focus blurs the input which will stop editing the list | 480 // Calling list.focus blurs the input which will stop editing the list |
| 481 // item. | 481 // item. |
| 482 switch (e.keyIdentifier) { | 482 switch (e.key) { |
| 483 case 'U+001B': // Esc | 483 case 'Escape': // Esc |
| 484 labelInput.value = title; | 484 labelInput.value = title; |
| 485 if (!isFolder) | 485 if (!isFolder) |
| 486 urlInput.value = url; | 486 urlInput.value = url; |
| 487 // fall through | 487 // fall through |
| 488 cr.dispatchSimpleEvent(listItem, 'canceledit', true); | 488 cr.dispatchSimpleEvent(listItem, 'canceledit', true); |
| 489 case 'Enter': | 489 case 'Enter': |
| 490 if (listItem.parentNode) | 490 if (listItem.parentNode) |
| 491 listItem.parentNode.focus(); | 491 listItem.parentNode.focus(); |
| 492 break; | 492 break; |
| 493 case 'U+0009': // Tab | 493 case 'Tab': // Tab |
| 494 // urlInput is the last focusable element in the page. If we | 494 // urlInput is the last focusable element in the page. If we |
| 495 // allowed Tab focus navigation and the page loses focus, we | 495 // allowed Tab focus navigation and the page loses focus, we |
| 496 // couldn't give focus on urlInput programatically. So, we prevent | 496 // couldn't give focus on urlInput programatically. So, we prevent |
| 497 // Tab focus navigation. | 497 // Tab focus navigation. |
| 498 if (document.activeElement == urlInput && !e.ctrlKey && | 498 if (document.activeElement == urlInput && !e.ctrlKey && |
| 499 !e.metaKey && !e.shiftKey && !getValidURL(urlInput)) { | 499 !e.metaKey && !e.shiftKey && !getValidURL(urlInput)) { |
| 500 e.preventDefault(); | 500 e.preventDefault(); |
| 501 urlInput.blur(); | 501 urlInput.blur(); |
| 502 } | 502 } |
| 503 break; | 503 break; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 } | 629 } |
| 630 } | 630 } |
| 631 } | 631 } |
| 632 }; | 632 }; |
| 633 | 633 |
| 634 return { | 634 return { |
| 635 BookmarkList: BookmarkList, | 635 BookmarkList: BookmarkList, |
| 636 list: /** @type {Element} */(null), // Set when decorated. | 636 list: /** @type {Element} */(null), // Set when decorated. |
| 637 }; | 637 }; |
| 638 }); | 638 }); |
| OLD | NEW |