Merge pull request #1546 from udan11/rfe_1570_2
RFE #1570, part 2. User can choose to use Enter instead of Ctrl+Enter to execute queries.
This commit is contained in:
commit
d2a467f002
@ -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();
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
@ -733,6 +751,19 @@ var PMA_consoleMessages = {
|
||||
return $query.text();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
@ -928,6 +959,7 @@ var PMA_consoleMessages = {
|
||||
if(PMA_console.config.startHistory) {
|
||||
PMA_consoleMessages.showHistory();
|
||||
}
|
||||
PMA_consoleMessages.showInstructions(PMA_console.config.enterExecutes);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -215,7 +215,10 @@ class PMA_Console
|
||||
$output .= '<div class="content">';
|
||||
$output .= '<div class="console_message_container">'
|
||||
. '<div class="message welcome"><span>'
|
||||
. __('Press Ctrl+Enter to execute query')
|
||||
. '<span id="instructions-0">'
|
||||
. __('Press Ctrl+Enter to execute query') . '</span>'
|
||||
. '<span class="hide" id="instructions-1">'
|
||||
. __('Press Enter to execute query') . '</span>'
|
||||
. '</span></div>';
|
||||
|
||||
// History support
|
||||
@ -310,6 +313,8 @@ class PMA_Console
|
||||
. __('Show query history at start') . '</label><br>'
|
||||
. '<label><input type="checkbox" name="current_query">'
|
||||
. __('Show current browsing query') . '</label><br>'
|
||||
. '<label><input type="checkbox" name="enter_executes">'
|
||||
. __('Execute queries on ENTER and insert new line with SHIFT + ENTER.') . '</label><br>'
|
||||
. '</div>';
|
||||
$output .= '</div>'; // Options card
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user