Merge remote-tracking branch 'origin/QA_3_5' into QA_3_5

This commit is contained in:
Michal Čihař 2012-04-12 02:35:16 +02:00
commit 65f70fb8c0
4 changed files with 242 additions and 174 deletions

View File

@ -15,6 +15,7 @@ phpMyAdmin - ChangeLog
- bug #3516761 [edit] Query error after search
- bug #3516405 [display] Chart title is getting wrong within chart export
- bug #3517021 [interface] Header links except 'More' hide after closing dialog
- bug #3516817 [interface] "More" actions in table structure
3.5.0.0 (2012-04-07)
+ rfe #2021981 [interface] Add support for mass prefix change.

View File

@ -2148,80 +2148,6 @@ $(document).ready(function() {
}, 'top.frame_content'); //end $(document).ready for 'Create Table'
/**
* jQuery coding for 'Change Table' and 'Add Column'. Used on tbl_structure.php *
* Attach Ajax Event handlers for Change Table
*/
$(document).ready(function() {
/**
*Ajax action for submitting the "Column Change" and "Add Column" form
**/
$("#append_fields_form input[name=do_save_data]").live('click', function(event) {
event.preventDefault();
/**
* @var the_form object referring to the export form
*/
var $form = $("#append_fields_form");
/*
* First validate the form; if there is a problem, avoid submitting it
*
* checkTableEditForm() needs a pure element and not a jQuery object,
* this is why we pass $form[0] as a parameter (the jQuery object
* is actually an array of DOM elements)
*/
if (checkTableEditForm($form[0], $form.find('input[name=orig_num_fields]').val())) {
// OK, form passed validation step
if ($form.hasClass('ajax')) {
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize()+"&do_save_data=Save", function(data) {
if ($("#sqlqueryresults").length != 0) {
$("#sqlqueryresults").remove();
} else if ($(".error").length != 0) {
$(".error").remove();
}
if (data.success == true) {
PMA_ajaxShowMessage(data.message);
$("<div id='sqlqueryresults'></div>").insertAfter("#floating_menubar");
$("#sqlqueryresults").html(data.sql_query);
$("#result_query .notice").remove();
$("#result_query").prepend((data.message));
if ($("#change_column_dialog").length > 0) {
$("#change_column_dialog").dialog("close").remove();
} else if ($("#add_columns").length > 0) {
$("#add_columns").dialog("close").remove();
}
/*Reload the field form*/
$.post($("#fieldsForm").attr('action'), $("#fieldsForm").serialize()+"&ajax_request=true", function(form_data) {
$("#fieldsForm").remove();
$("#addColumns").remove();
var $temp_div = $("<div id='temp_div'><div>").append(form_data);
if ($("#sqlqueryresults").length != 0) {
$temp_div.find("#fieldsForm").insertAfter("#sqlqueryresults");
} else {
$temp_div.find("#fieldsForm").insertAfter(".error");
}
$temp_div.find("#addColumns").insertBefore("iframe.IE_hack");
/*Call the function to display the more options in table*/
displayMoreTableOpts();
});
} else {
var $temp_div = $("<div id='temp_div'><div>").append(data);
var $error = $temp_div.find(".error code").addClass("error");
PMA_ajaxShowMessage($error, false);
}
}) // end $.post()
} else {
// non-Ajax submit
$form.append('<input type="hidden" name="do_save_data" value="Save" />');
$form.submit();
}
}
}) // end change table button "do_save_data"
}, 'top.frame_content'); //end $(document).ready for 'Change Table'
/**
* jQuery coding for 'Table operations'. Used on tbl_operations.php
* Attach Ajax Event handlers for Table operations
@ -2717,87 +2643,6 @@ $(document).ready(function() {
});
});
/**
* Hides certain table structure actions, replacing them
* with the word "More". They are displayed in a dropdown
* menu when the user hovers over the word "More."
*/
$(document).ready(function() {
displayMoreTableOpts();
});
function displayMoreTableOpts()
{
// Remove the actions from the table cells (they are available by default for JavaScript-disabled browsers)
// if the table is not a view or information_schema (otherwise there is only one action to hide and there's no point)
if($("input[type='hidden'][name='table_type']").val() == "table") {
var $table = $("table[id='tablestructure']");
$table.find("td[class='browse']").remove();
$table.find("td[class='primary']").remove();
$table.find("td[class='unique']").remove();
$table.find("td[class='index']").remove();
$table.find("td[class='fulltext']").remove();
$table.find("td[class='spatial']").remove();
$table.find("th[class='action']").attr("colspan", 3);
// Display the "more" text
$table.find("td[class='more_opts']").show();
// Position the dropdown
$(".structure_actions_dropdown").each(function() {
// Optimize DOM querying
var $this_dropdown = $(this);
// The top offset must be set for IE even if it didn't change
var cell_right_edge_offset = $this_dropdown.parent().position().left + $this_dropdown.parent().innerWidth();
var left_offset = cell_right_edge_offset - $this_dropdown.innerWidth();
var top_offset = $this_dropdown.parent().position().top + $this_dropdown.parent().innerHeight();
$this_dropdown.offset({ top: top_offset, left: left_offset });
});
// A hack for IE6 to prevent the after_field select element from being displayed on top of the dropdown by
// positioning an iframe directly on top of it
var $after_field = $("select[name='after_field']");
$("iframe[class='IE_hack']")
.width($after_field.width())
.height($after_field.height())
.offset({
top: $after_field.offset().top,
left: $after_field.offset().left
});
// When "more" is hovered over, show the hidden actions
$table.find("td[class='more_opts']")
.mouseenter(function() {
if($.browser.msie && $.browser.version == "6.0") {
$("iframe[class='IE_hack']")
.show()
.width($after_field.width()+4)
.height($after_field.height()+4)
.offset({
top: $after_field.offset().top,
left: $after_field.offset().left
});
}
$(".structure_actions_dropdown").hide(); // Hide all the other ones that may be open
$(this).children(".structure_actions_dropdown").show();
// Need to do this again for IE otherwise the offset is wrong
if($.browser.msie) {
var left_offset_IE = $(this).offset().left + $(this).innerWidth() - $(this).children(".structure_actions_dropdown").innerWidth();
var top_offset_IE = $(this).offset().top + $(this).innerHeight();
$(this).children(".structure_actions_dropdown").offset({
top: top_offset_IE,
left: left_offset_IE });
}
})
.mouseleave(function() {
$(this).children(".structure_actions_dropdown").hide();
if($.browser.msie && $.browser.version == "6.0") {
$("iframe[class='IE_hack']").hide();
}
});
}
}
$(document).ready(function(){
PMA_convertFootnotesToTooltips();
});

View File

@ -474,3 +474,209 @@ function changeColumns(action,url)
}) // end $.get()
}
/**
* jQuery coding for 'Change Table' and 'Add Column'. Used on tbl_structure.php *
* Attach Ajax Event handlers for Change Table
*/
$(document).ready(function() {
/**
*Ajax action for submitting the "Column Change" and "Add Column" form
**/
$("#append_fields_form input[name=do_save_data]").live('click', function(event) {
event.preventDefault();
/**
* @var the_form object referring to the export form
*/
var $form = $("#append_fields_form");
/*
* First validate the form; if there is a problem, avoid submitting it
*
* checkTableEditForm() needs a pure element and not a jQuery object,
* this is why we pass $form[0] as a parameter (the jQuery object
* is actually an array of DOM elements)
*/
if (checkTableEditForm($form[0], $form.find('input[name=orig_num_fields]').val())) {
// OK, form passed validation step
if ($form.hasClass('ajax')) {
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize()+"&do_save_data=Save", function(data) {
if ($("#sqlqueryresults").length != 0) {
$("#sqlqueryresults").remove();
} else if ($(".error").length != 0) {
$(".error").remove();
}
if (data.success == true) {
PMA_ajaxShowMessage(data.message);
$("<div id='sqlqueryresults'></div>").insertAfter("#floating_menubar");
$("#sqlqueryresults").html(data.sql_query);
$("#result_query .notice").remove();
$("#result_query").prepend((data.message));
if ($("#change_column_dialog").length > 0) {
$("#change_column_dialog").dialog("close").remove();
} else if ($("#add_columns").length > 0) {
$("#add_columns").dialog("close").remove();
}
/*Reload the field form*/
$.post($("#fieldsForm").attr('action'), $("#fieldsForm").serialize()+"&ajax_request=true", function(form_data) {
$("#fieldsForm").remove();
$("#addColumns").remove();
var $temp_div = $("<div id='temp_div'><div>").append(form_data);
if ($("#sqlqueryresults").length != 0) {
$temp_div.find("#fieldsForm").insertAfter("#sqlqueryresults");
} else {
$temp_div.find("#fieldsForm").insertAfter(".error");
}
$temp_div.find("#addColumns").insertBefore("iframe.IE_hack");
/*Call the function to display the more options in table*/
$table_clone = false;
moreOptsMenuResize();
});
} else {
var $temp_div = $("<div id='temp_div'><div>").append(data);
var $error = $temp_div.find(".error code").addClass("error");
PMA_ajaxShowMessage($error, false);
}
}) // end $.post()
} else {
// non-Ajax submit
$form.append('<input type="hidden" name="do_save_data" value="Save" />');
$form.submit();
}
}
}) // end change table button "do_save_data"
}, 'top.frame_content'); //end $(document).ready for 'Change Table'
/**
* Hides certain table structure actions, replacing them
* with the word "More". They are displayed in a dropdown
* menu when the user hovers over the word "More."
*/
var $table_clone = false;
function moreOptsMenuResize() {
var $table = $("table#tablestructure");
// don't use More menu if we're only showing icons and no text
if ($table.hasClass("PropertiesIconic")) {
return;
}
// reset table to defaults
if ($table_clone === false) {
$table_clone = $table.clone();
}
else {
$table.replaceWith($table_clone);
$table = $table_clone;
$table_clone = $table.clone();
}
var getCurWidth = function() {
var cur_width = 0;
$table.find("tr").eq(1)
.find("td.edit, td.drop, .replaced_by_more:visible, .more_opts:visible")
.each(function () {
cur_width += $(this).outerWidth();
});
return cur_width;
};
// get window width
var window_width = $(window).width();
// find out maximum action links width
var max_width = window_width;
$table.find("th").each(function () {
if ($(this).index() < 8) {
max_width -= $(this).outerWidth() + 1;
}
});
// current action links width
var cur_width = getCurWidth();
// remove some links if current width is wider than maximum allowed
if (cur_width > max_width) {
while (cur_width > max_width
&& $(".replaced_by_more:visible").length > 0) {
// hide last visible element
var css_class = $table.find("tr").eq(1)
.find(".replaced_by_more:visible").last().prop("className").split(" ");
$table.find("." + css_class.join(".")).hide();
// show corresponding more-menu entry
$table.find(".replace_in_more.action_" + css_class[0]).show();
// recalculate width
cur_width = getCurWidth();
}
}
if ($(".replaced_by_more:hidden").length == 0) {
$table.find("td.more_opts").hide();
}
else {
$table.find("td.more_opts").show();
}
// Position the dropdown
$(".structure_actions_dropdown").each(function() {
// Optimize DOM querying
var $this_dropdown = $(this);
// The top offset must be set for IE even if it didn't change
var cell_right_edge_offset = $this_dropdown.parent().position().left + $this_dropdown.parent().innerWidth();
var left_offset = cell_right_edge_offset - $this_dropdown.innerWidth();
var top_offset = $this_dropdown.parent().position().top + $this_dropdown.parent().innerHeight();
$this_dropdown.offset({ top: top_offset, left: left_offset });
});
// A hack for IE6 to prevent the after_field select element from being displayed on top of the dropdown by
// positioning an iframe directly on top of it
var $after_field = $("select[name='after_field']");
$("iframe[class='IE_hack']")
.width($after_field.width())
.height($after_field.height())
.offset({
top: $after_field.offset().top,
left: $after_field.offset().left
});
// When "more" is hovered over, show the hidden actions
$table.find("td.more_opts")
.unbind("mouseenter")
.bind("mouseenter", function() {
if($.browser.msie && $.browser.version == "6.0") {
$("iframe[class='IE_hack']")
.show()
.width($after_field.width()+4)
.height($after_field.height()+4)
.offset({
top: $after_field.offset().top,
left: $after_field.offset().left
});
}
$(".structure_actions_dropdown").hide(); // Hide all the other ones that may be open
$(this).children(".structure_actions_dropdown").show();
// Need to do this again for IE otherwise the offset is wrong
if($.browser.msie) {
var left_offset_IE = $(this).offset().left + $(this).innerWidth() - $(this).children(".structure_actions_dropdown").innerWidth();
var top_offset_IE = $(this).offset().top + $(this).innerHeight();
$(this).children(".structure_actions_dropdown").offset({
top: top_offset_IE,
left: left_offset_IE });
}
})
.unbind("mouseleave")
.bind("mouseleave", function() {
$(this).children(".structure_actions_dropdown").hide();
if($.browser.msie && $.browser.version == "6.0") {
$("iframe[class='IE_hack']").hide();
}
});
}
$(window).resize(moreOptsMenuResize);
$(function () {
$(".replace_in_more").hide();
moreOptsMenuResize();
});

View File

@ -193,7 +193,8 @@ $i = 0;
echo '"table" />';
} ?>
<table id="tablestructure" class="data">
<table id="tablestructure" class="data<?php
if ($GLOBALS['cfg']['PropertiesIconic'] === true) echo ' PropertiesIconic'; ?>">
<thead>
<tr>
<th id="th<?php echo ++$i; ?>"></th>
@ -208,7 +209,16 @@ $i = 0;
<?php if ($db_is_information_schema || $tbl_is_view) { ?>
<th id="th<?php echo ++$i; ?>" class="view"><?php echo __('View'); ?></th>
<?php } else { ?>
<th colspan="7" id="th<?php echo ++$i; ?>" class="action"><?php echo __('Action'); ?></th>
<th colspan="<?php
$colspan = 9;
if (PMA_DRIZZLE) {
$colspan -= 2;
}
if ($GLOBALS['cfg']['PropertiesIconic']) {
$colspan--;
}
echo $colspan; ?>"
id="th<?php echo ++$i; ?>" class="action"><?php echo __('Action'); ?></th>
<?php } ?>
</tr>
</thead>
@ -359,10 +369,6 @@ foreach ($fields as $row) {
echo '<i>' . _pgettext('None for default', 'None') . '</i>';
} ?></td>
<td nowrap="nowrap"><?php echo strtoupper($row['Extra']); ?></td>
<td align="center" class="browse">
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote(__('Rows')) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>">
<?php echo $titles['BrowseDistinctValues']; ?></a>
</td>
<?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
<td align="center" class="edit">
<a href="tbl_alter.php?<?php echo $url_query; ?>&amp;field=<?php echo $field_encoded; ?>">
@ -372,7 +378,13 @@ foreach ($fields as $row) {
<a <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="drop_column_anchor"' : ''); ?> href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field'])); ?>&amp;dropped_column=<?php echo urlencode($row['Field']); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('Column %s has been dropped'), htmlspecialchars($row['Field']))); ?>" >
<?php echo $titles['Drop']; ?></a>
</td>
<td align="center" class="primary">
<?php } ?>
<td align="center" class="browse replaced_by_more">
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote(__('Rows')) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>">
<?php echo $titles['BrowseDistinctValues']; ?></a>
</td>
<?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
<td align="center" class="primary replaced_by_more">
<?php
if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || ($primary && $primary->hasColumn($field_name))) {
echo $titles['NoPrimary'] . "\n";
@ -387,7 +399,7 @@ foreach ($fields as $row) {
echo "\n";
?>
</td>
<td align="center" class="unique">
<td align="center" class="unique replaced_by_more">
<?php
if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || isset($columns_with_unique_index[$field_name])) {
echo $titles['NoUnique'] . "\n";
@ -402,7 +414,7 @@ foreach ($fields as $row) {
echo "\n";
?>
</td>
<td align="center" class="index">
<td align="center" class="index replaced_by_more">
<?php
if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
echo $titles['NoIndex'] . "\n";
@ -418,7 +430,9 @@ foreach ($fields as $row) {
echo "\n";
?>
</td>
<td align="center" class="spatial">
<?php
if (!PMA_DRIZZLE) { ?>
<td align="center" class="spatial replaced_by_more">
<?php
$spatial_types = array(
'geometry', 'point', 'linestring', 'polygon', 'multipoint',
@ -444,7 +458,7 @@ foreach ($fields as $row) {
&& (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'char'))) {
echo "\n";
?>
<td align="center" nowrap="nowrap" class="fulltext">
<td align="center" nowrap="nowrap" class="fulltext replaced_by_more">
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['IdxFulltext']; ?></a>
<?php $fulltext_enabled = true; ?>
@ -453,24 +467,25 @@ foreach ($fields as $row) {
} else {
echo "\n";
?>
<td align="center" nowrap="nowrap" class="fulltext">
<td align="center" nowrap="nowrap" class="fulltext replaced_by_more">
<?php echo $titles['NoIdxFulltext'] . "\n"; ?>
<?php $fulltext_enabled = false; ?>
</td>
<?php
}
} // end if... else...
echo "\n";
?>
if ($GLOBALS['cfg']['PropertiesIconic'] !== true) { ?>
<td class="more_opts" id="more_opts<?php echo $rownum; ?>">
<?php echo PMA_getImage('more.png', __('Show more actions')); ?> <?php echo __('More'); ?>
<div class="structure_actions_dropdown" id="row_<?php echo $rownum; ?>">
<div class="action_browse">
<div class="action_browse replace_in_more">
<a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote(__('Rows')) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>">
<?php echo $hidden_titles['BrowseDistinctValues']; ?>
</a>
</div>
<div <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="action_primary"' : ''); ?>>
<div class="<?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'action_primary ' : ''); ?>replace_in_more">
<?php
if (isset($primary_enabled)) {
if ($primary_enabled) { ?>
@ -483,7 +498,7 @@ foreach ($fields as $row) {
}
} ?>
</div>
<div class="action_unique">
<div class="action_unique replace_in_more">
<?php
if (isset($unique_enabled)) {
if ($unique_enabled) { ?>
@ -496,7 +511,7 @@ foreach ($fields as $row) {
}
} ?>
</div>
<div class="action_index">
<div class="action_index replace_in_more">
<?php
if (isset($index_enabled)) {
if ($index_enabled) { ?>
@ -510,7 +525,7 @@ foreach ($fields as $row) {
} ?>
</div>
<?php if (!PMA_DRIZZLE) { ?>
<div class="action_spatial">
<div class="action_spatial replace_in_more">
<?php
if (isset($spatial_enabled)) {
if ($spatial_enabled) { ?>
@ -523,7 +538,7 @@ foreach ($fields as $row) {
}
} ?>
</div>
<div class="action_fulltext">
<div class="action_fulltext replace_in_more">
<?php
if (isset($fulltext_enabled)) {
if ($fulltext_enabled) { ?>
@ -540,6 +555,7 @@ foreach ($fields as $row) {
</div>
</td>
<?php
} // end if (GLOBALS['cfg']['PropertiesIconic'] !== true)
} // end if (! $tbl_is_view && ! $db_is_information_schema)
?>
</tr>