| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 /** | 5 /** |
| 6 * @fileoverview Element which shows context menus and handles keyboard | 6 * @fileoverview Element which shows context menus and handles keyboard |
| 7 * shortcuts. | 7 * shortcuts. |
| 8 */ | 8 */ |
| 9 cr.define('bookmarks', function() { | 9 cr.define('bookmarks', function() { |
| 10 | 10 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 /** | 102 /** |
| 103 * Display the command context menu at (|x|, |y|) in window co-ordinates. | 103 * Display the command context menu at (|x|, |y|) in window co-ordinates. |
| 104 * Commands will execute on |items| if given, or on the currently selected | 104 * Commands will execute on |items| if given, or on the currently selected |
| 105 * items. | 105 * items. |
| 106 * @param {number} x | 106 * @param {number} x |
| 107 * @param {number} y | 107 * @param {number} y |
| 108 * @param {Set<string>=} items | 108 * @param {Set<string>=} items |
| 109 */ | 109 */ |
| 110 openCommandMenuAtPosition: function(x, y, items) { | 110 openCommandMenuAtPosition: function(x, y, items) { |
| 111 this.menuIds_ = items || this.getState().selection.items; | 111 this.menuIds_ = items || this.getState().selection.items; |
| 112 |
| 112 var dropdown = | 113 var dropdown = |
| 113 /** @type {!CrActionMenuElement} */ (this.$.dropdown.get()); | 114 /** @type {!CrActionMenuElement} */ (this.$.dropdown.get()); |
| 114 // Ensure that the menu is fully rendered before trying to position it. | 115 // Ensure that the menu is fully rendered before trying to position it. |
| 115 Polymer.dom.flush(); | 116 Polymer.dom.flush(); |
| 116 dropdown.showAtPosition({top: y, left: x}); | 117 bookmarks.DialogFocusManager.getInstance().showDialog( |
| 118 dropdown, function() { |
| 119 dropdown.showAtPosition({top: y, left: x}); |
| 120 }); |
| 117 }, | 121 }, |
| 118 | 122 |
| 119 /** | 123 /** |
| 120 * Display the command context menu positioned to cover the |target| | 124 * Display the command context menu positioned to cover the |target| |
| 121 * element. Commands will execute on the currently selected items. | 125 * element. Commands will execute on the currently selected items. |
| 122 * @param {!Element} target | 126 * @param {!Element} target |
| 123 */ | 127 */ |
| 124 openCommandMenuAtElement: function(target) { | 128 openCommandMenuAtElement: function(target) { |
| 125 this.menuIds_ = this.getState().selection.items; | 129 this.menuIds_ = this.getState().selection.items; |
| 130 |
| 126 var dropdown = | 131 var dropdown = |
| 127 /** @type {!CrActionMenuElement} */ (this.$.dropdown.get()); | 132 /** @type {!CrActionMenuElement} */ (this.$.dropdown.get()); |
| 128 // Ensure that the menu is fully rendered before trying to position it. | 133 // Ensure that the menu is fully rendered before trying to position it. |
| 129 Polymer.dom.flush(); | 134 Polymer.dom.flush(); |
| 130 dropdown.showAt(target); | 135 bookmarks.DialogFocusManager.getInstance().showDialog( |
| 136 dropdown, function() { |
| 137 dropdown.showAt(target); |
| 138 }); |
| 131 }, | 139 }, |
| 132 | 140 |
| 133 closeCommandMenu: function() { | 141 closeCommandMenu: function() { |
| 134 this.menuIds_ = new Set(); | 142 this.menuIds_ = new Set(); |
| 135 /** @type {!CrActionMenuElement} */ (this.$.dropdown.get()).close(); | 143 /** @type {!CrActionMenuElement} */ (this.$.dropdown.get()).close(); |
| 136 }, | 144 }, |
| 137 | 145 |
| 138 //////////////////////////////////////////////////////////////////////////// | 146 //////////////////////////////////////////////////////////////////////////// |
| 139 // Command handlers: | 147 // Command handlers: |
| 140 | 148 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 385 |
| 378 if (urls.length <= OPEN_CONFIRMATION_LIMIT) { | 386 if (urls.length <= OPEN_CONFIRMATION_LIMIT) { |
| 379 openUrlsCallback(); | 387 openUrlsCallback(); |
| 380 return; | 388 return; |
| 381 } | 389 } |
| 382 | 390 |
| 383 this.confirmOpenCallback_ = openUrlsCallback; | 391 this.confirmOpenCallback_ = openUrlsCallback; |
| 384 var dialog = this.$.openDialog.get(); | 392 var dialog = this.$.openDialog.get(); |
| 385 dialog.querySelector('.body').textContent = | 393 dialog.querySelector('.body').textContent = |
| 386 loadTimeData.getStringF('openDialogBody', urls.length); | 394 loadTimeData.getStringF('openDialogBody', urls.length); |
| 387 dialog.showModal(); | 395 |
| 396 bookmarks.DialogFocusManager.getInstance().showDialog( |
| 397 this.$.openDialog.get()); |
| 388 }, | 398 }, |
| 389 | 399 |
| 390 /** | 400 /** |
| 391 * Returns all URLs in the given set of nodes and their immediate children. | 401 * Returns all URLs in the given set of nodes and their immediate children. |
| 392 * Note that these will be ordered by insertion order into the |itemIds| | 402 * Note that these will be ordered by insertion order into the |itemIds| |
| 393 * set, and that it is possible to duplicate a URL by passing in both the | 403 * set, and that it is possible to duplicate a URL by passing in both the |
| 394 * parent ID and child ID. | 404 * parent ID and child ID. |
| 395 * @param {!Set<string>} itemIds | 405 * @param {!Set<string>} itemIds |
| 396 * @return {!Array<string>} | 406 * @return {!Array<string>} |
| 397 * @private | 407 * @private |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 594 |
| 585 /** @return {!bookmarks.CommandManager} */ | 595 /** @return {!bookmarks.CommandManager} */ |
| 586 CommandManager.getInstance = function() { | 596 CommandManager.getInstance = function() { |
| 587 return assert(CommandManager.instance_); | 597 return assert(CommandManager.instance_); |
| 588 }; | 598 }; |
| 589 | 599 |
| 590 return { | 600 return { |
| 591 CommandManager: CommandManager, | 601 CommandManager: CommandManager, |
| 592 }; | 602 }; |
| 593 }); | 603 }); |
| OLD | NEW |