From 9a5ced626a10a0fed66dbd0059eebcd68acb85e7 Mon Sep 17 00:00:00 2001
From: Jo Michael
Date: Tue, 3 Apr 2012 23:10:24 +0200
Subject: [PATCH] Better implementation of rfe #3488185 using a jQuery UI
dialog
---
Documentation.html | 11 +++++++++
js/makegrid.js | 31 +++++++++++++++----------
js/messages.php | 3 +++
libraries/display_tbl.lib.php | 9 +++----
themes/original/css/theme_right.css.php | 23 ++++++------------
themes/pmahomme/css/theme_right.css.php | 22 ++++++------------
6 files changed, 52 insertions(+), 47 deletions(-)
diff --git a/Documentation.html b/Documentation.html
index 781cfb1251..fdd519c9ea 100644
--- a/Documentation.html
+++ b/Documentation.html
@@ -4488,6 +4488,17 @@ chmod o+rwx tmp
instructions on how to use can be viewed by clicking the 'How to use?' link located just above
the plot.
Selecting the name of the column within the browse table header cell for copying is difficult,
+ as the columns support reordering by dragging the header cells as well as sorting by clicking on
+ the linked column name.
+
+ To copy a column name, double-click on the empty area next to the column name,
+ when the tooltip tells you to do so. This will show you an input box with the column name.
+ You may right-click the column name within this input box to copy it to your clipboard.
+
phpMyAdmin project
diff --git a/js/makegrid.js b/js/makegrid.js
index 42c0236c96..948db0b018 100644
--- a/js/makegrid.js
+++ b/js/makegrid.js
@@ -40,6 +40,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
reorderHint: '', // string, hint for column reordering
sortHint: '', // string, hint for column sorting
markHint: '', // string, hint for column marking
+ copyHint: '', // string, hint for copy column name
colVisibHint: '', // string, hint for column visibility drop-down
showReorderHint: false,
showSortHint: false,
@@ -441,6 +442,8 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
text += text.length > 0 ? ' ' : '';
text += g.colVisibHint;
}
+ text += text.length > 0 ? ' ' : '';
+ text += g.copyHint;
// hide the hint if no text and the event is mouseenter
if (g.qtip) {
@@ -1428,18 +1431,21 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
g.showReorderHint = false;
})
.dblclick(function(e) {
- if ($(this).find("input").length) {
- $(this).find("span").hide().end().find("input").show().focus().select();
- }
- else {
- var $input = $("")
- .val($(this).find("span").text())
- .blur(function (e) {
- $(this).hide().parent().find("span").show();
- });
- $(this).append($input).find("span").hide();
- $input.focus().select();
- }
+ e.preventDefault();
+ $("")
+ .prop("title", PMA_messages["strColNameCopyTitle"])
+ .addClass("modal-copy")
+ .text(PMA_messages["strColNameCopyText"])
+ .append(
+ $("")
+ .prop("readonly", true)
+ .val($(this).data("column"))
+ )
+ .dialog({
+ resizable: false,
+ modal: true
+ })
+ .find("input").focus().select();
});
// restore column order when the restore button is clicked
$('.restore_column').click(function() {
@@ -1685,6 +1691,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
// assign the hints
g.sortHint = PMA_messages['strSortHint'];
g.markHint = PMA_messages['strColMarkHint'];
+ g.copyHint = PMA_messages['strColNameCopyHint'];
// assign common hidden inputs
var $common_hidden_inputs = $('.common_hidden_inputs');
diff --git a/js/messages.php b/js/messages.php
index 6d573f2e7d..e5ca3bc8f0 100644
--- a/js/messages.php
+++ b/js/messages.php
@@ -345,11 +345,14 @@ $js_messages['strSaveCellWarning'] = __('You have edited some data and they have
$js_messages['strColOrderHint'] = __('Drag to reorder');
$js_messages['strSortHint'] = __('Click to sort');
$js_messages['strColMarkHint'] = __('Click to mark/unmark');
+$js_messages['strColNameCopyHint'] = __('Double-click to copy column name');
$js_messages['strColVisibHint'] = __('Click the drop-down arrow to toggle column\'s visibility');
$js_messages['strShowAllCol'] = __('Show all');
$js_messages['strAlertNonUnique'] = __('This table does not contain a unique column. Features related to the grid edit, checkbox, Edit, Copy and Delete links may not work after saving.');
$js_messages['strGridEditFeatureHint'] = __('You can also edit most columns by clicking directly on their content.');
$js_messages['strGoToLink'] = __('Go to link');
+$js_messages['strColNameCopyTitle'] = __('Copy column name');
+$js_messages['strColNameCopyText'] = __('Right-click the column name to copy it to your clipboard.');
/* password generation */
$js_messages['strGeneratePassword'] = __('Generate password');
diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php
index 02074f4d9b..218d31c833 100644
--- a/libraries/display_tbl.lib.php
+++ b/libraries/display_tbl.lib.php
@@ -1039,12 +1039,13 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
echo ' vbottom';
}
- echo '">' . $order_link . $comments . '';
+ echo '" data-column="' . htmlspecialchars($fields_meta[$i]->name) . '">'
+ . $order_link . $comments . '';
}
$vertical_display['desc'][] = '