on clicking Empty, really ensure no further click, change icon, adjust number of rows and size

This commit is contained in:
Marc Delisle
2010-11-13 17:02:26 -05:00
parent 30f0b20d38
commit eb21b97041

View File

@@ -27,32 +27,45 @@ $(document).ready(function() {
$(".truncate_table_anchor").live('click', function(event) { $(".truncate_table_anchor").live('click', function(event) {
event.preventDefault(); event.preventDefault();
/**
* @var $this_anchor Object referring to the anchor clicked
*/
var $this_anchor = $(this);
//extract current table name and build the question string //extract current table name and build the question string
/** /**
* @var curr_table_name String containing the name of the table to be truncated * @var curr_table_name String containing the name of the table to be truncated
*/ */
var curr_table_name = $(this).parents('tr').children('th').children('a').text(); var curr_table_name = $this_anchor.parents('tr').children('th').children('a').text();
/** /**
* @var question String containing the question to be asked for confirmation * @var question String containing the question to be asked for confirmation
*/ */
var question = 'TRUNCATE ' + curr_table_name; var question = 'TRUNCATE ' + curr_table_name;
/**
* @var this_anchor Object referring to the anchor clicked
*/
var this_anchor = $(this);
$(this).PMA_confirm(question, $(this).attr('href'), function(url) { $this_anchor.PMA_confirm(question, $this_anchor.attr('href'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) { $.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) {
if(data.success == true) { if(data.success == true) {
PMA_ajaxShowMessage(data.message); PMA_ajaxShowMessage(data.message);
//Remove the action's href and class, so as to disable further attempts to truncate the table //Fetch inner span of this anchor
// @todo: How to replace the icon with the disabled version? //and replace the icon with its disabled version
$(this_anchor) var span = $this_anchor.html().replace(/b_empty.png/, 'bd_empty.png');
.removeAttr('href') // find parent td of this anchor
.removeClass('.truncate_table_anchor'); $this_anchor.parent()
// set number of rows to 0
.next().next().text('0')
// set size to unknown (not sure how to get the exact
// value here, as an empty InnoDB table would have a size)
.next().next().next().text('-');
$this_anchor
//To disable further attempts to truncate the table,
//replace the a element with its inner span (modified)
.replaceWith(span)
.removeClass('truncate_table_anchor');
} }
else { else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error); PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);