Skip to content

Commit

Permalink
Merge remote-tracking branch 'gzzhanghao/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
lem9 committed Feb 13, 2015
2 parents 9af4514 + 3007c6a commit 9ef49d8
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 6 deletions.
14 changes: 14 additions & 0 deletions js/console.js
Expand Up @@ -539,6 +539,15 @@ var PMA_consoleInput = {
}
$('#pma_console .console_query_input').keydown(PMA_consoleInput._keydown);
},
getUnfinished: function () {
return PMA_consoleInput._unfinished;
},
on: function (event, handler) {
PMA_consoleInput._inputs.console.on(event, handler);
},
off: function (event, handler) {
PMA_consoleInput._inputs.console.off(event, handler);
},
_historyNavigate: function(event) {
if (event.keyCode == 38 || event.keyCode == 40) {
var upPermitted = false;
Expand Down Expand Up @@ -1016,4 +1025,9 @@ var PMA_consoleBookmarks = {
*/
$(function () {
PMA_console.initialize();
PMA_consoleInput.on('change', function () {
var query = PMA_consoleInput.getText();
PMA_consoleInput._unfinished = query;
});
PMA_consoleInput.setText($('#pma_console_container').attr('data-unfinished'));
});
13 changes: 8 additions & 5 deletions js/functions.js
Expand Up @@ -709,11 +709,14 @@ AJAX.registerOnload('functions.js', function () {
function UpdateIdleTime() {
var href = 'index.php';
var params = {
'ajax_request' : true,
'token' : PMA_commonParams.get('token'),
'db' : PMA_commonParams.get('db'),
'access_time':_idleSecondsCounter
};
'ajax_request' : true,
'token' : PMA_commonParams.get('token'),
'db' : PMA_commonParams.get('db'),
'access_time':_idleSecondsCounter
};
if (PMA_consoleInput && PMA_consoleInput.getUnfinished()) {
params.unfinished = PMA_consoleInput.getUnfinished();
}
$.ajax({
type: 'POST',
url: href,
Expand Down
52 changes: 52 additions & 0 deletions js/sql.js
Expand Up @@ -100,6 +100,16 @@ AJAX.registerTeardown('sql.js', function () {
$(document).off('click', 'th.column_heading.marker');
$(window).unbind('scroll');
$(document).off("keyup", ".filter_rows");

if (codemirror_editor) {
codemirror_editor.off('change', PMA_handleQueryChanges);
}
$('#sqlquery').off('input propertychange', PMA_handleQueryChanges);
if (PMA_consoleInput) {
PMA_consoleInput.off('change', PMA_handleConsoleChanges);
}
$('#pma_console').off('input propertychange', PMA_handleConsoleChanges);

$('body').off('click', '.navigation .showAllRows');
$('body').off('click','a.browse_foreign');
$('body').off('click', '#simulate_dml');
Expand All @@ -124,6 +134,21 @@ AJAX.registerTeardown('sql.js', function () {
* @memberOf jQuery
*/
AJAX.registerOnload('sql.js', function () {

$(function () {
if (codemirror_editor) {
codemirror_editor.on('change', PMA_handleQueryChanges);
} else {
$('#sqlquery').on('input propertychange', PMA_handleQueryChanges);
}
if (PMA_consoleInput) {
PMA_consoleInput.on('change', PMA_handleConsoleChanges);
} else {
$('#pma_console').on('input propertychange', PMA_handleConsoleChanges);
}
PMA_handleConsoleChanges();
});

// Delete row from SQL results
$(document).on('click', 'a.delete_row.ajax', function (e) {
e.preventDefault();
Expand Down Expand Up @@ -550,6 +575,33 @@ AJAX.registerOnload('sql.js', function () {
});
}); // end $()

function PMA_handleQueryChanges() {

var query = null;

if (codemirror_editor) {
query = codemirror_editor.getValue();
} else {
query = $('#sqlquery').val();
}
if (PMA_consoleInput.getText() !== query) {
PMA_consoleInput.setText(query);
}
}

function PMA_handleConsoleChanges() {

var query = PMA_consoleInput.getText();

if (codemirror_editor) {
if (query !== codemirror_editor.getValue()) {
codemirror_editor.setValue(query);
}
} else if (query !== $('#sqlquery').val()) {
$('#sqlquery').val(query);
}
}

/**
* Starting from some th, change the class of all td under it.
* If isAddClass is specified, it will be used to determine whether to add or remove the class.
Expand Down
6 changes: 5 additions & 1 deletion libraries/Console.class.php
Expand Up @@ -167,7 +167,11 @@ public function getDisplay()
}
$this->_scripts->addFile('console.js');
$output .= $this->_scripts->getDisplay();
$output .= '<div id="pma_console_container"><div id="pma_console">';
$output .= '<div id="pma_console_container" data-unfinished="';
if (isset($_SESSION['unfinished'])) {
$output .= $_SESSION['unfinished'];
}
$output .= '"><div id="pma_console">';

// The templates, use sprintf() to output them
// There're white space at the end of every <span>,
Expand Down
3 changes: 3 additions & 0 deletions libraries/plugins/auth/AuthenticationCookie.class.php
Expand Up @@ -450,6 +450,9 @@ public function authCheck()
PMA_Util::cacheUnset('dbs_where_create_table_allowed');
PMA_Util::cacheUnset('dbs_to_test');
$GLOBALS['no_activity'] = true;
if (!empty($_REQUEST['unfinished'])) {
$_SESSION['unfinished'] = $_REQUEST['unfinished'];
}
$this->authFails();
if (! defined('TESTSUITE')) {
exit;
Expand Down

0 comments on commit 9ef49d8

Please sign in to comment.