Chromium Code Reviews| 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 }, | 472 }, |
| 473 set editing(editing) { | 473 set editing(editing) { |
| 474 var oldEditing = this.editing; | 474 var oldEditing = this.editing; |
| 475 if (oldEditing == editing) | 475 if (oldEditing == editing) |
| 476 return; | 476 return; |
| 477 | 477 |
| 478 var url = this.bookmarkNode.url; | 478 var url = this.bookmarkNode.url; |
| 479 var title = this.bookmarkNode.title; | 479 var title = this.bookmarkNode.title; |
| 480 var isFolder = bmm.isFolder(this.bookmarkNode); | 480 var isFolder = bmm.isFolder(this.bookmarkNode); |
| 481 var listItem = this; | 481 var listItem = this; |
| 482 var labelEl = this.firstChild; | 482 var labelEl = queryRequiredElement('.label-text', this); |
|
Dan Beam
2016/10/27 03:56:17
labelTextEl?
Peter Kasting
2016/10/27 06:00:26
Done.
| |
| 483 var urlEl = labelEl.nextSibling; | 483 var urlEl = queryRequiredElement('.url', this); |
| 484 var labelInput, urlInput; | 484 var labelInput, urlInput; |
| 485 | 485 |
| 486 // Handles enter and escape which trigger reset and commit respectively. | 486 // Handles enter and escape which trigger reset and commit respectively. |
| 487 function handleKeydown(e) { | 487 function handleKeydown(e) { |
| 488 // Make sure that the tree does not handle the key. | 488 // Make sure that the tree does not handle the key. |
| 489 e.stopPropagation(); | 489 e.stopPropagation(); |
| 490 | 490 |
| 491 // Calling list.focus blurs the input which will stop editing the list | 491 // Calling list.focus blurs the input which will stop editing the list |
| 492 // item. | 492 // item. |
| 493 switch (e.key) { | 493 switch (e.key) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 // before deciding if we should exit edit mode. | 538 // before deciding if we should exit edit mode. |
| 539 var doc = e.target.ownerDocument; | 539 var doc = e.target.ownerDocument; |
| 540 window.setTimeout(function() { | 540 window.setTimeout(function() { |
| 541 var activeElement = doc.hasFocus() && doc.activeElement; | 541 var activeElement = doc.hasFocus() && doc.activeElement; |
| 542 if (activeElement != urlInput && activeElement != labelInput) { | 542 if (activeElement != urlInput && activeElement != labelInput) { |
| 543 listItem.editing = false; | 543 listItem.editing = false; |
| 544 } | 544 } |
| 545 }, 50); | 545 }, 50); |
| 546 } | 546 } |
| 547 | 547 |
| 548 var doc = this.ownerDocument; | 548 var doc = this.ownerDocument; |
|
Dan Beam
2016/10/27 03:56:17
can we do
var labelTextEl = queryRequiredElement(
Peter Kasting
2016/10/27 06:00:26
Done.
| |
| 549 if (editing) { | 549 if (editing) { |
| 550 this.setAttribute('editing', ''); | 550 this.setAttribute('editing', ''); |
| 551 this.draggable = false; | 551 this.draggable = false; |
| 552 | 552 |
| 553 labelInput = /** @type {HTMLElement} */(doc.createElement('input')); | 553 labelInput = /** @type {HTMLElement} */(doc.createElement('input')); |
| 554 labelInput.placeholder = | 554 labelInput.placeholder = |
| 555 loadTimeData.getString('name_input_placeholder'); | 555 loadTimeData.getString('name_input_placeholder'); |
| 556 replaceAllChildren(labelEl, labelInput); | 556 replaceAllChildren(labelEl, labelInput); |
| 557 labelInput.value = title; | 557 labelInput.value = title; |
| 558 | 558 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 } | 640 } |
| 641 } | 641 } |
| 642 } | 642 } |
| 643 }; | 643 }; |
| 644 | 644 |
| 645 return { | 645 return { |
| 646 BookmarkList: BookmarkList, | 646 BookmarkList: BookmarkList, |
| 647 list: /** @type {Element} */(null), // Set when decorated. | 647 list: /** @type {Element} */(null), // Set when decorated. |
| 648 }; | 648 }; |
| 649 }); | 649 }); |
| OLD | NEW |