diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2015-03-06 16:51:30 +0300 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2015-03-06 16:51:30 +0300 |
commit | 3a012945aeb9d8638cf56e04d8f583d4cc2f5bb2 (patch) | |
tree | c7f93006760604edda8f13c7f1c2e349ee096cae /js/console.js | |
parent | 5653855e66b6f5780e14942042ee1beb7c3aa105 (diff) |
User can choose to use Enter instead of Ctrl+Enter to execute queries.
Implements RFE #1570, part 2.
Signed-off-by: Dan Ungureanu <udan1107@gmail.com>
Diffstat (limited to 'js/console.js')
-rw-r--r-- | js/console.js | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/js/console.js b/js/console.js index 687c78e98c..3d95e7a234 100644 --- a/js/console.js +++ b/js/console.js @@ -107,6 +107,9 @@ var PMA_console = { if(tempConfig.currentQuery === true) { $('#pma_console_options input[name=current_query]').prop('checked', true); } + if(tempConfig.enterExecutes === true) { + $('#pma_console_options input[name=enter_executes]').prop('checked', true); + } } else { $('#pma_console_options input[name=current_query]').prop('checked', true); } @@ -164,9 +167,14 @@ var PMA_console = { $('#pma_console_options input[name=always_expand]').prop('checked', false); $('#pma_console_options input[name=start_history]').prop('checked', false); $('#pma_console_options input[name=current_query]').prop('checked', true); + $('#pma_console_options input[name=enter_executes]').prop('checked', false); PMA_console.updateConfig(); }); + $('#pma_console_options input[name=enter_executes]').change(function() { + PMA_consoleMessages.showInstructions(PMA_console.config.enterExecutes); + }); + $(document).ajaxComplete(function (event, xhr) { try { var data = $.parseJSON(xhr.responseText); @@ -386,7 +394,8 @@ var PMA_console = { PMA_console.config = { alwaysExpand: $('#pma_console_options input[name=always_expand]').prop('checked'), startHistory: $('#pma_console_options input[name=start_history]').prop('checked'), - currentQuery: $('#pma_console_options input[name=current_query]').prop('checked') + currentQuery: $('#pma_console_options input[name=current_query]').prop('checked'), + enterExecutes: $('#pma_console_options input[name=enter_executes]').prop('checked') }; $.cookie('pma_console_config', JSON.stringify(PMA_console.config)); }, @@ -594,13 +603,22 @@ var PMA_consoleInput = { }, /** * Mousedown event handler for bind to input - * Shortcut is Ctrl+Enter key + * Shortcut is Ctrl+Enter key or just ENTER, depending on console's + * configuration. * * @return void */ _keydown: function(event) { - if(event.ctrlKey && event.keyCode === 13) { - PMA_consoleInput.execute(); + if (PMA_console.config.enterExecutes) { + // Enter, but not in combination with Shift (which writes a new line). + if (!event.shiftKey && event.keyCode === 13) { + PMA_consoleInput.execute(); + } + } else { + // Ctrl+Enter + if (event.ctrlKey && event.keyCode === 13) { + PMA_consoleInput.execute(); + } } }, /** @@ -734,6 +752,19 @@ var PMA_consoleMessages = { } }, /** + * Used to show the correct message depending on which key + * combination executes the query (Ctrl+Enter or Enter). + * + * @param bool enterExecutes Only Enter has to be pressed to execute query. + * @return void + */ + showInstructions: function(enterExecutes) { + enterExecutes = +enterExecutes || 0; // conversion to int + var $welcomeMsg = $('#pma_console .content .console_message_container .message.welcome span'); + $welcomeMsg.children('[id^=instructions]').hide(); + $welcomeMsg.children('#instructions-' + enterExecutes).show(); + }, + /** * Used for log new message * * @param string msgString Message to show @@ -928,6 +959,7 @@ var PMA_consoleMessages = { if(PMA_console.config.startHistory) { PMA_consoleMessages.showHistory(); } + PMA_consoleMessages.showInstructions(PMA_console.config.enterExecutes); } }; |