Merge branch 'colresize' into aris

This commit is contained in:
Aris Feryanto 2011-05-31 13:13:27 +07:00
commit 8098115448
3 changed files with 80 additions and 23 deletions

View File

@ -5,6 +5,9 @@
// constant
minColWidth: 5,
// changeable vars
firstColSpan: 5, // default to 5, only useful in horizontal mode
// functions
dragStartRsz: function(e, obj) {
var n = $('div', this.cRsz).index(obj);
@ -13,7 +16,8 @@
n: n,
obj: obj,
objLeft: parseInt(obj.style.left),
objWidth: $('th div:eq(' + (1 + n) + ')', this.t).width()
objWidth: $('tr:first th:eq(' + (1 + n) + ') span,' +
'tr:first td:eq(' + n + ') span', this.t).width()
};
$('body').css('cursor', 'col-resize');
$('body').noSelect();
@ -34,7 +38,7 @@
}
var n = this.colRsz.n;
$('tr', this.t).each(function() {
$('th:eq(' + (1 + n) + ') div, td:eq(' + (5 + n) + ') div', this).each(function() {
$('th:eq(' + (1 + n) + ') span, td:eq(' + (g.firstColSpan + n) + ') span', this).each(function() {
$(this).css('width', nw + 'px');
});
});
@ -44,7 +48,7 @@
}
},
reposRsz: function() {
$(this.t).find('thead tr:first th:gt(0)').each(function() {
$(this.t).find('tr:first th:gt(0), tr:first td').each(function() {
$this = $(this);
var n = $this.index();
$cb = $('div:eq(' + (n - 1) + ')', g.cRsz); // column border
@ -54,10 +58,16 @@
}
g.gDiv = document.createElement('div'); // create global div
g.cRsz = document.createElement('div'); // column resizer
// chain table and grid together
t.grid = g;
g.t = t;
// assign the first column (actions) span
g.firstColSpan = $('tr:first th:first', t).attr('colspan');
g.firstColSpan = (g.firstColSpan != undefined) ? parseInt(g.firstColSpan) : 0; // posibility of vertical display mode
// create column borders
$(t).find('thead tr:first th:gt(0)').each(function() {
$(t).find('tr:first th:gt(0), tr:first td').each(function() {
$this = $(this);
var cb = document.createElement('div'); // column border
cb.style.left = $this.position().left + $this.width() + 'px';
@ -69,9 +79,9 @@
$(g.cRsz).append(cb);
});
// wrap all cells with div
$(t).find('th, td').each(function() {
$(this).wrapInner('<div />');
// wrap all cells, except actions cell, with div
$(t).find('th, td:not(:has(span))').each(function() {
$(this).wrapInner('<span />');
});
// register events
@ -116,6 +126,18 @@
}
});
};
$.fn.refreshgrid = function() {
return this.each(function() {
if (!docready) {
var t = this;
$(document).ready(function() {
if (t.grid) t.grid.reposRsz();
});
} else {
if (this.grid) this.grid.reposRsz();
}
});
}
$.fn.noSelect = function (p) { //no select plugin by Paulo P.Marinas
var prevent = (p == null) ? true : p;
if (prevent) {

View File

@ -211,6 +211,24 @@ $(document).ready(function() {
$("#sqlqueryresults").live('appendAnchor',function() {
appendInlineAnchor();
})
/**
* Attach the {@link makegrid} function to a custom event, which will be
* triggered manually everytime the table of results is reloaded
* @memberOf jQuery
*/
$("#sqlqueryresults").live('makegrid', function() {
$('#table_results').makegrid();
})
/**
* Attach the {@link refreshgrid} function to a custom event, which will be
* triggered manually everytime the table of results is manipulated (e.g., by inline edit)
* @memberOf jQuery
*/
$("#sqlqueryresults").live('refreshgrid', function() {
$('#table_results').refreshgrid();
})
/**
* Trigger the appendAnchor event to prepare the first table for inline edit
@ -324,6 +342,7 @@ $(document).ready(function() {
$('#sqlqueryresults').show();
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
$("#sqlqueryresults").trigger('makegrid');
$('#togglequerybox').show();
if($("#togglequerybox").siblings(":visible").length > 0) {
$("#togglequerybox").trigger('click');
@ -364,6 +383,7 @@ $(document).ready(function() {
$.post($the_form.attr('action'), $the_form.serialize(), function(data) {
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
$("#sqlqueryresults").trigger('makegrid');
PMA_init_slider();
PMA_ajaxRemoveMessage($msgbox);
@ -387,6 +407,7 @@ $(document).ready(function() {
$.post($the_form.attr('action'), $the_form.serialize() + '&ajax_request=true', function(data) {
$("#sqlqueryresults").html(data);
$("#sqlqueryresults").trigger('appendAnchor');
$("#sqlqueryresults").trigger('makegrid');
PMA_init_slider();
PMA_ajaxRemoveMessage($msgbox);
}) // end $.post()
@ -412,7 +433,8 @@ $(document).ready(function() {
$.get($anchor.attr('href'), $anchor.serialize() + '&ajax_request=true', function(data) {
$("#sqlqueryresults")
.html(data)
.trigger('appendAnchor');
.trigger('appendAnchor')
.trigger('makegrid');
PMA_ajaxRemoveMessage($msgbox);
}) // end $.get()
})//end Sort results table
@ -431,7 +453,8 @@ $(document).ready(function() {
$.post($form.attr('action'), $form.serialize() + '&ajax_request=true' , function(data) {
$("#sqlqueryresults")
.html(data)
.trigger('appendAnchor');
.trigger('appendAnchor')
.trigger('makegrid');
PMA_init_slider();
}) // end $.post()
})
@ -523,15 +546,19 @@ $(document).ready(function() {
if($this_hide.siblings("td:eq(" + i + ")").hasClass("inline_edit") == false) {
continue;
}
txt = $this_hide.siblings("td:eq(" + i + ")").data('original_data');
if($this_hide.siblings("td:eq(" + i + ")").children().length != 0) {
$this_hide.siblings("td:eq(" + i + ")").empty();
$this_hide.siblings("td:eq(" + i + ")").append(txt);
var $this_hide_siblings = $this_hide.siblings("td:eq(" + i + ")").children('span');
txt = $this_hide_siblings.data('original_data');
if($this_hide_siblings.children().length != 0) {
$this_hide_siblings.empty();
$this_hide_siblings.append(txt);
}
}
$(this).prev().prev().remove();
$(this).prev().remove();
$(this).remove();
// refresh the grid
$("#sqlqueryresults").trigger('refreshgrid');
});
} else {
var txt = '';
@ -556,13 +583,17 @@ $(document).ready(function() {
if( $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").hasClass("inline_edit") == false) {
continue;
}
txt = $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").data('original_data');
$this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").empty();
$this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").append(txt);
$this_row_siblings = $this_row.siblings("tr:eq(" + i + ") td:eq(" + pos + ")").children('span');
txt = $this_row_siblings.data('original_data');
$this_row_siblings.empty();
$this_row_siblings.append(txt);
}
$(this).prev().remove();
$(this).prev().remove();
$(this).remove();
// refresh the grid
$("#sqlqueryresults").trigger('refreshgrid');
});
}
@ -594,7 +625,7 @@ $(document).ready(function() {
/**
* @var data_value Current value of this field
*/
var data_value = $(this).html();
var data_value = $(this).children('span').html();
// We need to retrieve the value from the server for truncated/relation fields
// Find the field name
@ -602,7 +633,7 @@ $(document).ready(function() {
/**
* @var this_field Object referring to this field (<td>)
*/
var $this_field = $(this);
var $this_field = $(this).children('span');
/**
* @var field_name String containing the name of this field.
* @see getFieldName()
@ -779,7 +810,11 @@ $(document).ready(function() {
$this_field.append('<textarea></textarea>');
$this_field.data('original_data', 'NULL');
}
})
});
// refresh the grid
$("#sqlqueryresults").trigger('refreshgrid');
}) // End On click, replace the current field with an input/textarea
/**
@ -1146,7 +1181,7 @@ $(document).ready(function() {
/**
* create resizable table
*/
$('#table_results').makegrid();
$("#sqlqueryresults").trigger('makegrid');
})
/**#@- */

View File

@ -2116,14 +2116,14 @@ fieldset .disabled-field td {
}
.colborder {
border-right: solid 1px #FFFFFF;
border-right: solid 2px #FFFFFF;
cursor: col-resize;
margin-left: -1px;
margin-left: -2px;
position: absolute;
width: 3px;
}
.pma_table thead th div, .pma_table tbody td div {
.pma_table thead th span, .pma_table tbody td span {
display: block;
overflow: hidden;
}