Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js/sql.js
diff options
context:
space:
mode:
authorZhang Hao <jason.daurus@gmail.com>2015-02-13 13:46:09 +0300
committerZhang Hao <jason.daurus@gmail.com>2015-02-13 13:46:09 +0300
commit3007c6a6ef43c48d2e1f3439f8afba90a0425250 (patch)
tree53d6a04370e778690a9a584c8b1804a417ff2abf /js/sql.js
parent56c240b5225509a381986c51e529ff4a04676747 (diff)
Save unfinished work
Signed-off-by: Zhang Hao <jason.daurus@gmail.com>
Diffstat (limited to 'js/sql.js')
-rw-r--r--js/sql.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/js/sql.js b/js/sql.js
index 553bd40e1b..98cef0550f 100644
--- a/js/sql.js
+++ b/js/sql.js
@@ -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');
@@ -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();
@@ -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.