Fixed issue #2 in bug #3291301 - Problems with inline edit link for sql query

This commit is contained in:
Rouslan Placella
2011-05-01 17:22:16 +01:00
committed by Michal Čihař
parent bacbe54a67
commit 56fc953b57
2 changed files with 24 additions and 17 deletions

View File

@@ -1118,25 +1118,32 @@ function changeMIMEType(db, table, reference, mime_type)
* Jquery Coding for inline editing SQL_QUERY * Jquery Coding for inline editing SQL_QUERY
*/ */
$(document).ready(function(){ $(document).ready(function(){
var oldText,db,table,token,sql_query; $(".inline_edit").click( function(){
oldText=$(".inner_sql").html(); var db = $(this).prev().find("input[name='db']").val();
$("#inline_edit").live('click',function(){ var table = $(this).prev().find("input[name='table']").val();
db=$("input[name='db']").val(); var token = $(this).prev().find("input[name='token']").val();
table=$("input[name='table']").val(); var sql_query = $(this).prev().find("input[name='sql_query']").val();
token=$("input[name='token']").val(); var $inner_sql = $(this).parent().prev().find('.inner_sql');
sql_query=$("input[name='sql_query']").val(); var old_text = $inner_sql.html();
$(".inner_sql").replaceWith("<textarea name=\"sql_query_edit\" id=\"sql_query_edit\">"+ sql_query +"</textarea><input type=\"button\" id=\"btnSave\" value=\"" + PMA_messages['strGo'] + "\"><input type=\"button\" id=\"btnDiscard\" value=\"" + PMA_messages['strCancel'] + "\">");
var new_content = "<textarea name=\"sql_query_edit\" id=\"sql_query_edit\">" + sql_query + "</textarea>\n";
new_content += "<input type=\"button\" class=\"btnSave\" value=\"" + PMA_messages['strGo'] + "\">\n";
new_content += "<input type=\"button\" class=\"btnDiscard\" value=\"" + PMA_messages['strCancel'] + "\">\n";
$inner_sql.replaceWith(new_content);
$(".btnSave").each(function(){
$(this).click(function(){
sql_query = $(this).prev().val();
window.location.replace("import.php?db=" + db +"&table=" + table + "&sql_query=" + sql_query + "&show_query=1&token=" + token);
});
});
$(".btnDiscard").each(function(){
$(this).click(function(){
$(this).closest(".sql").html("<span class=\"syntax\"><span class=\"inner_sql\">" + old_text + "</span></span>");
});
});
return false; return false;
}); });
$("#btnSave").live("click",function(){
window.location.replace("import.php?db=" + db +"&table=" + table + "&sql_query=" + $("#sql_query_edit").val()+"&show_query=1&token=" + token + "");
});
$("#btnDiscard").live("click",function(){
$(".sql").html("<span class=\"syntax\"><span class=\"inner_sql\">" + oldText + "</span></span>");
});
$('.sqlbutton').click(function(evt){ $('.sqlbutton').click(function(evt){
insertQuery(evt.target.id); insertQuery(evt.target.id);
return false; return false;

View File

@@ -1263,7 +1263,7 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
"//<![CDATA[\n" . "//<![CDATA[\n" .
"$('.tools form').last().after('[<a href=\"#\" title=\"" . "$('.tools form').last().after('[<a href=\"#\" title=\"" .
PMA_escapeJsString(__('Inline edit of this query')) . PMA_escapeJsString(__('Inline edit of this query')) .
"\" id=\"inline_edit\">" . "\" class=\"inline_edit\">" .
PMA_escapeJsString(__('Inline')) . PMA_escapeJsString(__('Inline')) .
"</a>]');\n" . "</a>]');\n" .
"//]]>\n" . "//]]>\n" .