Skip to content

Commit

Permalink
Merge pull request #11963 from Achilles-96/Issue-11865
Browse files Browse the repository at this point in the history
Fixes #11865 partially
  • Loading branch information
nijel committed Feb 22, 2016
2 parents 6a46ea5 + 4073e46 commit aa077ee
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 7 deletions.
7 changes: 7 additions & 0 deletions doc/config.rst
Expand Up @@ -1190,6 +1190,13 @@ Server connection settings
Generic settings
----------------

.. config:option:: $cfg['DisableShortcutKeys']
:type: boolean
:default: false

You can disable phpMyAdmin shortcut keys by setting :config:option:`$cfg['DisableShortcutKeys']` to false.

.. config:option:: $cfg['ServerDefault']
:type: integer
Expand Down
15 changes: 15 additions & 0 deletions doc/intro.rst
Expand Up @@ -48,6 +48,21 @@ Currently phpMyAdmin can:
<https://www.phpmyadmin.net/translations/>`_


Shortcut keys
-------------

Currently phpMyAdmin supports following shortcuts:

* k - Toggle console
* h - Go to home page
* s - Open settings
* d + s - Go to database structure (Provided you are in database related page)
* d + f - Search database (Provided you are in database related page)
* t + s - Go to table structure (Provided you are in table related page)
* t + f - Search table (Provided you are in table related page)
* backspace - Takes you to older page.


A word about users
------------------

Expand Down
6 changes: 0 additions & 6 deletions js/console.js
Expand Up @@ -127,12 +127,6 @@ var PMA_console = {
PMA_consoleDebug.initialize();

PMA_console.$consoleToolbar.children('.console_switch').click(PMA_console.toggle);
$(document).keydown(function(event) {
// Ctrl + Alt + C
if (event.ctrlKey && event.altKey && event.keyCode === 67) {
PMA_console.toggle();
}
});

$('#pma_console').find('.toolbar').children().mousedown(function(event) {
event.preventDefault();
Expand Down
106 changes: 106 additions & 0 deletions js/shortcuts_handler.js
@@ -0,0 +1,106 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* @fileoverview Handle shortcuts in various pages
* @name Shortcuts handler
*
* @requires jQuery
* @requires jQueryUI
*/

/**
* Register key events on load
*/
$(document).ready(function() {
var databaseOp = false;
var tableOp = false;
var keyD = 68;
var keyT = 84;
var keyK = 75;
var keyS = 83;
var keyF = 70;
var keyE = 69;
var keyH = 72;
var keyC = 67;
var keyBackSpace = 8;
$(document).keyup(function(e) {
if( e.target.nodeName === 'INPUT' || e.target.nodeName === 'TEXTAREA' || e.target.nodeName === 'SELECT' ) {
return;
}

if(e.keyCode === keyD) {
setTimeout(function() {
databaseOp = false;
}, 2000);
}
else if(e.keyCode === keyT) {
setTimeout(function() {
tableOp = false;
}, 2000);
}
});
$(document).keydown(function(e) {
if ( e.ctrlKey && e.altKey && e.keyCode === keyC ) {
PMA_console.toggle();
}

if( e.target.nodeName === 'INPUT' || e.target.nodeName === 'TEXTAREA' || e.target.nodeName === 'SELECT' ) {
return;
}

var isTable;
var isDb;
if(e.keyCode === keyD) {
databaseOp = true;
}
else if(e.keyCode === keyK) {
PMA_console.toggle();
}
else if(e.keyCode === keyS) {
if(databaseOp === true) {
isTable = PMA_commonParams.get('table');
isDb = PMA_commonParams.get('db');
if(isDb && ! isTable) {
$('.tab .ic_b_props').first().trigger('click');
}
}
else if(tableOp === true) {
isTable = PMA_commonParams.get('table');
isDb = PMA_commonParams.get('db');
if(isDb && isTable) {
$('.tab .ic_b_props').first().trigger('click');
}
}
else{
$('#pma_navigation_settings_icon').trigger('click');
}
}
else if(e.keyCode === keyF) {
if(databaseOp === true) {
isTable = PMA_commonParams.get('table');
isDb = PMA_commonParams.get('db');
if(isDb && ! isTable) {
$('.tab .ic_b_search').first().trigger('click');
}
}
else if(tableOp === true) {
isTable = PMA_commonParams.get('table');
isDb = PMA_commonParams.get('db');
if(isDb && isTable) {
$('.tab .ic_b_search').first().trigger('click');
}
}
}
else if(e.keyCode === keyT) {
tableOp = true;
}
else if(e.keyCode === keyE) {
$('.ic_b_export').first().trigger('click');
}
else if(e.keyCode === keyBackSpace) {
window.history.back();
}
else if(e.keyCode === keyH) {
$('.ic_b_home').first().trigger('click');
}
});
});
3 changes: 3 additions & 0 deletions libraries/Header.php
Expand Up @@ -202,6 +202,9 @@ private function _addDefaultScripts()
$this->_scripts->addFile('indexes.js');
$this->_scripts->addFile('common.js');
$this->_scripts->addFile('page_settings.js');
if(!$GLOBALS['cfg']['DisableShortcutKeys']) {
$this->_scripts->addFile('shortcuts_handler.js');
}
$this->_scripts->addCode($this->getJsParamsCode());
}

Expand Down
7 changes: 7 additions & 0 deletions libraries/config.default.php
Expand Up @@ -3125,3 +3125,10 @@
'internal' => 50500,
'human' => '5.5.0'
);

/**
* Disable shortcuts
*
* @global array $cfg['DisableShortcutKeys']
*/
$cfg['DisableShortcutKeys'] = false;
2 changes: 2 additions & 0 deletions libraries/config/messages.inc.php
Expand Up @@ -549,6 +549,8 @@
'Whether to show row links even in the absence of a unique key.'
);
$strConfigRowActionLinksWithoutUnique_name = __('Show row links anyway');
$strConfigDisableShortcutKeys_name = __('Disable shortcut keys');
$strConfigDisableShortcutKeys_desc = __('Disable shortcut keys');
$strConfigNaturalOrder_desc
= __('Use natural order for sorting table and database names.');
$strConfigNaturalOrder_name = __('Natural order');
Expand Down
3 changes: 2 additions & 1 deletion libraries/config/setup.forms.php
Expand Up @@ -147,7 +147,8 @@
'ProxyUser',
'ProxyPass',
'AllowThirdPartyFraming',
'ZeroConf'
'ZeroConf',
'DisableShortcutKeys'
);
$forms['Sql_queries']['Sql_queries'] = array(
'ShowSQL',
Expand Down

0 comments on commit aa077ee

Please sign in to comment.