mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Make "/" focus the search input again
Summary: See D1902, T989, T11263, D15984, T4103 , D15976, https://secure.phabricator.com/w/changelog/2016.22/, T2527, T11231, T8286, T11264 for discussion! When we get another copy of T989, I will rename it to "Build a complicated keybinding settings page like a cool video game" and leave it open forever. Test Plan: Pressed "/" in Firefox, had my pristine browsing experience inexplicably hijacked by this horrible application. Reviewers: avivey, chad Reviewed By: avivey Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D15984
This commit is contained in:
parent
444e353700
commit
1a303e7d2a
3 changed files with 31 additions and 13 deletions
|
@ -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',
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue