make inline editing work for all cases of fmtType

This commit is contained in:
Marc Delisle
2010-06-12 08:45:24 -04:00
parent 8dfdcca68b
commit 485e1736b6
3 changed files with 11 additions and 4 deletions

View File

@@ -1703,13 +1703,13 @@ function changeMIMEType(db, table, reference, mime_type)
*/ */
$(document).ready(function(){ $(document).ready(function(){
var $oldText,$db,$table,$token,$sql_query; var $oldText,$db,$table,$token,$sql_query;
$oldText=$(".syntax").html(); $oldText=$(".inner_sql").html();
$("#inline_edit").click(function(){ $("#inline_edit").click(function(){
$db=$("input[name='db']").val(); $db=$("input[name='db']").val();
$table=$("input[name='table']").val(); $table=$("input[name='table']").val();
$token=$("input[name='token']").val(); $token=$("input[name='token']").val();
$sql_query=$("input[name='sql_query']").val(); $sql_query=$("input[name='sql_query']").val();
$(".syntax").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'] + "\">"); $(".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'] + "\">");
return false; return false;
}); });
@@ -1718,7 +1718,7 @@ $(document).ready(function(){
}); });
$("#btnDiscard").live("click",function(){ $("#btnDiscard").live("click",function(){
$(".sql").html("<span class=\"syntax\">"+$oldText+"</span>"); $(".sql").html("<span class=\"syntax\"><span class=\"inner_sql\">"+$oldText+"</span></span>");
}); });
$('.sqlbutton').click(function(evt){ $('.sqlbutton').click(function(evt){

View File

@@ -320,7 +320,7 @@ function PMA_formatSql($parsed_sql, $unparsed_sql = '')
switch ($cfg['SQP']['fmtType']) { switch ($cfg['SQP']['fmtType']) {
case 'none': case 'none':
if ($unparsed_sql != '') { if ($unparsed_sql != '') {
$formatted_sql = "<pre>\n" . PMA_SQP_formatNone(array('raw' => $unparsed_sql)) . "\n</pre>"; $formatted_sql = '<span class="inner_sql"><pre>' . "\n" . PMA_SQP_formatNone(array('raw' => $unparsed_sql)) . "\n" . '</pre></span>';
} else { } else {
$formatted_sql = PMA_SQP_formatNone($parsed_sql); $formatted_sql = PMA_SQP_formatNone($parsed_sql);
} }

View File

@@ -2092,6 +2092,10 @@ if (! defined('PMA_MINIMUM_COMMON')) {
$docu = TRUE; $docu = TRUE;
break; break;
} // end switch } // end switch
// inner_sql is a span that exists for all cases
// of $cfg['SQP']['fmtType'] to make possible a replacement
// for inline editing
$str .= '<span class="inner_sql">';
$close_docu_link = false; $close_docu_link = false;
$indent = 0; $indent = 0;
$bracketlevel = 0; $bracketlevel = 0;
@@ -2578,7 +2582,10 @@ if (! defined('PMA_MINIMUM_COMMON')) {
$str .= '</a>'; $str .= '</a>';
$close_docu_link = false; $close_docu_link = false;
} }
// close inner_sql span
$str .= '</span>';
if ($mode=='color') { if ($mode=='color') {
// close syntax span
$str .= '</span>'; $str .= '</span>';
} }