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

Side by Side Diff: chrome/browser/resources/bookmark_manager/js/main.js

Issue 1089163002: Pressing 'Delete' key in bookmark manager's search box deletes bookmark. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months 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 | « no previous file | no next file » | 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 (function() { 5 (function() {
6 /** @const */ var BookmarkList = bmm.BookmarkList; 6 /** @const */ var BookmarkList = bmm.BookmarkList;
7 /** @const */ var BookmarkTree = bmm.BookmarkTree; 7 /** @const */ var BookmarkTree = bmm.BookmarkTree;
8 /** @const */ var Command = cr.ui.Command; 8 /** @const */ var Command = cr.ui.Command;
9 /** @const */ var LinkKind = cr.LinkKind; 9 /** @const */ var LinkKind = cr.LinkKind;
10 /** @const */ var ListItem = cr.ui.ListItem; 10 /** @const */ var ListItem = cr.ui.ListItem;
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 else if (document.activeElement == bmm.tree) 463 else if (document.activeElement == bmm.tree)
464 cmd = 'paste-from-folders-menu-command'; 464 cmd = 'paste-from-folders-menu-command';
465 465
466 if (cmd) 466 if (cmd)
467 update('paste-from-context-menu-command', !$(cmd).disabled); 467 update('paste-from-context-menu-command', !$(cmd).disabled);
468 468
469 if (opt_f) opt_f(); 469 if (opt_f) opt_f();
470 }); 470 });
471 } 471 }
472 472
473 function handleCanExecuteForSearchBox(e) {
474 var command = e.command;
475 switch (command.id) {
476 case 'delete-command':
477 case 'undo-command':
478 // Do nothing when delete is selected in search box.
479 // Pass the undo command through (fixes http://crbug.com/278112).
480 // Otherwise, because the global undo command has no visible UI, always
Bernhard Bauer 2015/04/15 14:54:45 Remove this sentence (see my comment above).
Deepak 2015/04/15 15:04:15 Done.
481 // enable it, and just make it a no-op if undo is not possible.
482 e.canExecute = false;
483 break;
484 }
485 }
486
473 function handleCanExecuteForDocument(e) { 487 function handleCanExecuteForDocument(e) {
474 var command = e.command; 488 var command = e.command;
475 switch (command.id) { 489 switch (command.id) {
476 case 'import-menu-command': 490 case 'import-menu-command':
477 e.canExecute = canEdit; 491 e.canExecute = canEdit;
478 break; 492 break;
479 493
480 case 'export-menu-command': 494 case 'export-menu-command':
481 // We can always execute the export-menu command. 495 // We can always execute the export-menu command.
482 e.canExecute = true; 496 e.canExecute = true;
483 break; 497 break;
484 498
485 case 'sort-command': 499 case 'sort-command':
486 e.canExecute = !bmm.list.isSearch() && 500 e.canExecute = !bmm.list.isSearch() &&
487 bmm.list.dataModel && bmm.list.dataModel.length > 1 && 501 bmm.list.dataModel && bmm.list.dataModel.length > 1 &&
488 !isUnmodifiable(bmm.tree.getBookmarkNodeById(bmm.list.parentId)); 502 !isUnmodifiable(bmm.tree.getBookmarkNodeById(bmm.list.parentId));
489 break; 503 break;
490 504
491 case 'undo-command':
492 // If the search box is active, pass the undo command through
493 // (fixes http://crbug.com/278112). Otherwise, because
494 // the global undo command has no visible UI, always enable it, and
495 // just make it a no-op if undo is not possible.
496 e.canExecute = e.currentTarget.activeElement !== $('term');
Bernhard Bauer 2015/04/15 14:54:45 For the undo command we need to keep the behavior
Deepak 2015/04/15 15:04:14 Done.
497 break;
498
499 default: 505 default:
500 canExecuteForList(e); 506 canExecuteForList(e);
501 if (!e.defaultPrevented) 507 if (!e.defaultPrevented)
502 canExecuteForTree(e); 508 canExecuteForTree(e);
503 break; 509 break;
504 } 510 }
505 } 511 }
506 512
507 /** 513 /**
508 * Helper function for handling canExecute for the list and the tree. 514 * Helper function for handling canExecute for the list and the tree.
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 // when // the user goes back and forward in the history. 1463 // when // the user goes back and forward in the history.
1458 window.addEventListener('hashchange', processHash); 1464 window.addEventListener('hashchange', processHash);
1459 1465
1460 document.querySelector('header form').onsubmit = 1466 document.querySelector('header form').onsubmit =
1461 /** @type {function(Event=)} */(function(e) { 1467 /** @type {function(Event=)} */(function(e) {
1462 setSearch($('term').value); 1468 setSearch($('term').value);
1463 e.preventDefault(); 1469 e.preventDefault();
1464 }); 1470 });
1465 1471
1466 $('term').addEventListener('search', handleSearch); 1472 $('term').addEventListener('search', handleSearch);
1473 $('term').addEventListener('canExecute', handleCanExecuteForSearchBox);
1467 1474
1468 $('folders-button').addEventListener('click', handleMenuButtonClicked); 1475 $('folders-button').addEventListener('click', handleMenuButtonClicked);
1469 $('organize-button').addEventListener('click', handleMenuButtonClicked); 1476 $('organize-button').addEventListener('click', handleMenuButtonClicked);
1470 1477
1471 document.addEventListener('canExecute', handleCanExecuteForDocument); 1478 document.addEventListener('canExecute', handleCanExecuteForDocument);
1472 document.addEventListener('command', handleCommand); 1479 document.addEventListener('command', handleCommand);
1473 1480
1474 // Listen to copy, cut and paste events and execute the associated commands. 1481 // Listen to copy, cut and paste events and execute the associated commands.
1475 installEventHandlerForCommand('copy', 'copy-command'); 1482 installEventHandlerForCommand('copy', 'copy-command');
1476 installEventHandlerForCommand('cut', 'cut-command'); 1483 installEventHandlerForCommand('cut', 'cut-command');
(...skipping 29 matching lines...) Expand all
1506 1513
1507 cr.ui.FocusOutlineManager.forDocument(document); 1514 cr.ui.FocusOutlineManager.forDocument(document);
1508 initializeSplitter(); 1515 initializeSplitter();
1509 bmm.addBookmarkModelListeners(); 1516 bmm.addBookmarkModelListeners();
1510 dnd.init(selectItemsAfterUserAction); 1517 dnd.init(selectItemsAfterUserAction);
1511 bmm.tree.reload(); 1518 bmm.tree.reload();
1512 } 1519 }
1513 1520
1514 initializeBookmarkManager(); 1521 initializeBookmarkManager();
1515 })(); 1522 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698