diff --git a/js/functions.js b/js/functions.js
index 8e844cb65c..8c858882c3 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -2981,8 +2981,8 @@ function PMA_createqTip($elements, content, options) {
function PMA_getCellValue(td) {
if ($(td).is('.null')) {
return '';
- } else if ($(td).is(':not(.truncated, .transformed, .relation, .enum, .set, .null)')) {
- return $(td).find('span').html().replace(/ /g, "\n");
+ } else if ($(td).is(':not(.transformed, .relation, .enum, .set, .null)')) {
+ return unescape($(td).find('span').html()).replace(/ /g, "\n");
} else {
return $(td).text();
}
diff --git a/js/makegrid.js b/js/makegrid.js
index 7af6ea465c..5c0af4897c 100644
--- a/js/makegrid.js
+++ b/js/makegrid.js
@@ -25,7 +25,10 @@
isEditCellTextEditable: false, // true if current edit cell is editable in the text input box (not textarea)
currentEditCell: null, // reference to
that currently being edited
inEditMode: false, // true if grid is in edit mode
- cellEditHint: '', // text hint when doing grid edit
+ cellEditHint: '', // hint shown when doing grid edit
+ gotoLinkText: 'Go to link', // "Go to link" text
+ wasEditedCellNull: false, // true if last value of the edited cell was NULL
+ maxTruncatedLen: 0, // number of characters that can be displayed in a cell
// functions
dragStartRsz: function(e, obj) { // start column resize
@@ -39,7 +42,7 @@
};
$('body').css('cursor', 'col-resize');
$('body').noSelect();
- if (g.isInEditMode) {
+ if (g.isCellEditActive) {
g.hideEditCell();
}
},
@@ -73,7 +76,7 @@
this.qtip.hide();
$('body').css('cursor', 'move');
$('body').noSelect();
- if (g.isInEditMode) {
+ if (g.isCellEditActive) {
g.hideEditCell();
}
},
@@ -455,8 +458,7 @@
* Show edit cell, if it can be shown or it is forced.
*/
showEditCell: function(cell, force) {
- if (g.isInEditMode &&
- $(cell).is('.inline_edit') &&
+ if ($(cell).is('.inline_edit') &&
!g.colRsz && !g.colMov)
{
if (!g.isCellEditActive || force) {
@@ -471,7 +473,7 @@
.show()
.find('input')
.css({
- width: $cell.outerWidth() - 16,
+ width: $cell.outerWidth(),
height: $cell.outerHeight()
});
// fill the cell edit with text from
, if it is not null
@@ -481,6 +483,7 @@
g.isCellEditActive = false;
g.currentEditCell = cell;
+ $(g.cEdit).find('input[type=text]').focus();
}
} else {
g.hideEditCell();
@@ -537,6 +540,10 @@
}
})
}
+ } else if ($this_field.is('.truncated')) {
+ if (new_html.length > g.maxTruncatedLen) {
+ new_html = new_html.substring(0, g.maxTruncatedLen) + '...';
+ }
}
// replace '\n' with
new_html = new_html.replace(/\n/g, ' ');
@@ -605,10 +612,24 @@
* relational display column if in 'Relational key' mode (for fields that are foreign keyed).
*/
var relation_key_or_display_column = $td.find('a').attr('title');
+ /**
+ * @var curr_value String current value of the field (for fields that are of type enum or set).
+ */
+ var curr_value = $td.find('span').text();
// empty all edit area, then rebuild it based on $td classes
$editArea.empty();
+ // add goto link, if this cell contains a link
+ if ($td.find('a').length > 0) {
+ var gotoLink = document.createElement('div');
+ gotoLink.className = 'goto_link';
+ $(gotoLink).append(g.gotoLinkText + ': ')
+ .append($td.find('a').clone());
+ $editArea.append(gotoLink);
+ }
+
+ g.wasEditedCellNull = false;
if ($td.is(':not(.not_null)')) {
// append a null checkbox
$editArea.append('
Null :
');
@@ -616,6 +637,7 @@
// check if current
is NULL
if ($td.is('.null')) {
$checkbox.attr('checked', true);
+ g.wasEditedCellNull = true;
}
// if the select/editor is changed un-check the 'checkbox_null__'.
@@ -660,44 +682,7 @@
})
}
- if($td.is('.truncated, .transformed')) {
- /** @lends jQuery */
- //handle truncated/transformed values values
- $editArea.addClass('edit_area_loading');
-
- /**
- * @var sql_query String containing the SQL query used to retrieve value of truncated/transformed data
- */
- var sql_query = 'SELECT `' + field_name + '` FROM `' + window.parent.table + '` WHERE ' + PMA_urldecode(where_clause);
-
- // Make the Ajax call and get the data, wrap it and insert it
- $.post('sql.php', {
- 'token' : window.parent.token,
- 'server' : window.parent.server,
- 'db' : window.parent.db,
- 'ajax_request' : true,
- 'sql_query' : sql_query,
- 'inline_edit' : true
- }, function(data) {
- $editArea.removeClass('edit_area_loading');
- if(data.success == true) {
- $(g.cEdit).find('input[type=text]').val(data.value);
- $editArea.append('');
- $editArea.find('textarea').live('keyup', function(e) {
- $(g.cEdit).find('input[type=text]').val($(this).val());
- });
- $(g.cEdit).find('input[type=text]').live('keyup', function(e) {
- $editArea.find('textarea').val($(this).val());
- });
- $editArea.append('
' + g.cellEditHint + '
');
- }
- else {
- PMA_ajaxShowMessage(data.error);
- }
- }) // end $.post()
- g.isEditCellTextEditable = true;
- }
- else if($td.is('.relation')) {
+ if($td.is('.relation')) {
/** @lends jQuery */
//handle relations
$editArea.addClass('edit_area_loading');
@@ -783,6 +768,46 @@
$editArea.find('select').live('change', function(e) {
$(g.cEdit).find('input[type=text]').val($(this).val());
})
+ }
+ else if($td.is('.truncated, .transformed')) {
+ /** @lends jQuery */
+ //handle truncated/transformed values values
+ $editArea.addClass('edit_area_loading');
+
+ /**
+ * @var sql_query String containing the SQL query used to retrieve value of truncated/transformed data
+ */
+ var sql_query = 'SELECT `' + field_name + '` FROM `' + window.parent.table + '` WHERE ' + PMA_urldecode(where_clause);
+
+ // Make the Ajax call and get the data, wrap it and insert it
+ $.post('sql.php', {
+ 'token' : window.parent.token,
+ 'server' : window.parent.server,
+ 'db' : window.parent.db,
+ 'ajax_request' : true,
+ 'sql_query' : sql_query,
+ 'inline_edit' : true
+ }, function(data) {
+ $editArea.removeClass('edit_area_loading');
+ if(data.success == true) {
+ // get the truncated data length
+ g.maxTruncatedLen = PMA_getCellValue(g.currentEditCell).length - 3;
+
+ $(g.cEdit).find('input[type=text]').val(data.value);
+ $editArea.append('');
+ $editArea.find('textarea').live('keyup', function(e) {
+ $(g.cEdit).find('input[type=text]').val($(this).val());
+ });
+ $(g.cEdit).find('input[type=text]').live('keyup', function(e) {
+ $editArea.find('textarea').val($(this).val());
+ });
+ $editArea.append('