diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 7b84306aef..a483d311de 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -8,7 +8,7 @@ return array( 'names' => array( 'core.pkg.css' => '2fbe65a2', - 'core.pkg.js' => '49f8bdc0', + 'core.pkg.js' => '1bcca0f3', 'darkconsole.pkg.js' => 'e7393ebb', 'differential.pkg.css' => '3e81ae60', 'differential.pkg.js' => '634399e9', @@ -491,7 +491,7 @@ return array( 'rsrc/js/core/behavior-history-install.js' => '7ee2b591', 'rsrc/js/core/behavior-hovercard.js' => 'bcaccd64', 'rsrc/js/core/behavior-keyboard-pager.js' => 'a8da01f0', - 'rsrc/js/core/behavior-keyboard-shortcuts.js' => '7835f8c9', + 'rsrc/js/core/behavior-keyboard-shortcuts.js' => '01fca1f0', 'rsrc/js/core/behavior-lightbox-attachments.js' => 'f8ba29d7', 'rsrc/js/core/behavior-line-linker.js' => '1499a8cb', 'rsrc/js/core/behavior-more.js' => 'a80d0378', @@ -654,7 +654,7 @@ return array( 'javelin-behavior-phabricator-gesture' => '3ab51e2c', 'javelin-behavior-phabricator-gesture-example' => '558829c2', 'javelin-behavior-phabricator-keyboard-pager' => 'a8da01f0', - 'javelin-behavior-phabricator-keyboard-shortcuts' => '7835f8c9', + 'javelin-behavior-phabricator-keyboard-shortcuts' => '01fca1f0', 'javelin-behavior-phabricator-line-linker' => '1499a8cb', 'javelin-behavior-phabricator-nav' => '56a1ca03', 'javelin-behavior-phabricator-notification-example' => '8ce821c5', @@ -921,6 +921,13 @@ return array( 'javelin-workflow', 'phabricator-draggable-list', ), + '01fca1f0' => array( + 'javelin-behavior', + 'javelin-workflow', + 'javelin-json', + 'javelin-dom', + 'phabricator-keyboard-shortcut', + ), '031cee25' => array( 'javelin-behavior', 'javelin-request', @@ -1499,13 +1506,6 @@ return array( 'multirow-row-manager', 'javelin-json', ), - '7835f8c9' => array( - 'javelin-behavior', - 'javelin-workflow', - 'javelin-json', - 'javelin-dom', - 'phabricator-keyboard-shortcut', - ), '7927a7d3' => array( 'javelin-behavior', 'javelin-quicksand', diff --git a/src/view/page/menu/PhabricatorMainMenuView.php b/src/view/page/menu/PhabricatorMainMenuView.php index 69ff522d5b..25dba1871a 100644 --- a/src/view/page/menu/PhabricatorMainMenuView.php +++ b/src/view/page/menu/PhabricatorMainMenuView.php @@ -186,9 +186,17 @@ final class PhabricatorMainMenuView extends AphrontView { } $result = $search; + $keyboard_config['searchID'] = $search->getID(); } - Javelin::initBehavior('phabricator-keyboard-shortcuts', $keyboard_config); + $keyboard_config['pht'] = array( + '/' => pht('Give keyboard focus to the search box.'), + '?' => pht('Show keyboard shortcut help for the current page.'), + ); + + Javelin::initBehavior( + 'phabricator-keyboard-shortcuts', + $keyboard_config); if ($result) { $result = id(new PHUIListItemView()) diff --git a/webroot/rsrc/js/core/behavior-keyboard-shortcuts.js b/webroot/rsrc/js/core/behavior-keyboard-shortcuts.js index a2f7ca172b..e1c6fa97d8 100644 --- a/webroot/rsrc/js/core/behavior-keyboard-shortcuts.js +++ b/webroot/rsrc/js/core/behavior-keyboard-shortcuts.js @@ -11,10 +11,10 @@ * Define global keyboard shortcuts. */ JX.behavior('phabricator-keyboard-shortcuts', function(config) { + var pht = JX.phtize(config.pht); var workflow = null; - var desc = 'Show keyboard shortcut help for the current page.'; - new JX.KeyboardShortcut('?', desc) + new JX.KeyboardShortcut('?', pht('?')) .setHandler(function(manager) { if (workflow) { // Already showing the dialog. @@ -30,4 +30,14 @@ JX.behavior('phabricator-keyboard-shortcuts', function(config) { }) .register(); + if (config.searchID) { + new JX.KeyboardShortcut('/', pht('/')) + .setHandler(function() { + var search = JX.$(config.searchID); + search.focus(); + search.select(); + }) + .register(); + } + });