Skip to content

Commit

Permalink
Alternative implementation for rfe #1602
Browse files Browse the repository at this point in the history
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
  • Loading branch information
madhuracj committed Feb 26, 2015
1 parent e506afc commit f014821
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions js/functions.js
Expand Up @@ -1000,6 +1000,13 @@ function insertQuery(queryType)
});
}
return;
} else if (queryType == "saved") {
if ($.cookie('auto_saved_sql')) {
setQuery($.cookie('auto_saved_sql'));
} else {
PMA_ajaxShowMessage(PMA_messages.strNoAutoSavedQuery);
}
return;
}

var query = "";
Expand Down
1 change: 1 addition & 0 deletions js/messages.php
Expand Up @@ -305,6 +305,7 @@
$js_messages['strEdit'] = __('Edit');
$js_messages['strNotValidRowNumber'] = __('%d is not valid row number.');
$js_messages['strBrowseForeignValues'] = __('Browse foreign values');
$js_messages['strNoAutoSavedQuery'] = __('No auto saved query');

/* For Central list of columns */
$js_messages['pickColumn'] = __('Pick');
Expand Down
24 changes: 24 additions & 0 deletions js/sql.js
Expand Up @@ -100,6 +100,11 @@ 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');
} else {
$('#sqlquery').off('input propertychange');
}
$('body').off('click', '.navigation .showAllRows');
$('body').off('click','a.browse_foreign');
$('body').off('click', '#simulate_dml');
Expand All @@ -124,6 +129,25 @@ AJAX.registerTeardown('sql.js', function () {
* @memberOf jQuery
*/
AJAX.registerOnload('sql.js', function () {

$(function () {
if (codemirror_editor) {
codemirror_editor.on('change', function () {
var query = codemirror_editor.getValue();
if (query) {
$.cookie('auto_saved_sql', query);
}
});
} else {
$('#sqlquery').on('input propertychange', function () {
var query = $('#sqlquery').val();
if (query) {
$.cookie('auto_saved_sql', query);
}
});
}
});

// Delete row from SQL results
$(document).on('click', 'a.delete_row.ajax', function (e) {
e.preventDefault();
Expand Down
2 changes: 2 additions & 0 deletions libraries/sql_query_form.lib.php
Expand Up @@ -237,6 +237,8 @@ function PMA_getHtmlForSqlQueryFormInsert(
$html .= '<input type="button" value="' . __('Format') . '" id="format"'
. ' class="button sqlbutton" />';
}
$html .= '<input type="button" value="' . __('Auto saved') . '" id="saved"'
. ' class="button sqlbutton" />';
$html .= '</div>' . "\n";

if (count($fields_list)) {
Expand Down

0 comments on commit f014821

Please sign in to comment.