Merge branch 'hidecol' into aris
This commit is contained in:
commit
cab875f3df
385
js/makegrid.js
385
js/makegrid.js
@ -3,12 +3,13 @@
|
||||
// prepare the grid
|
||||
var g = {
|
||||
// constant
|
||||
minColWidth: 5,
|
||||
minColWidth: 15,
|
||||
|
||||
// variables, assigned with default value, changed later
|
||||
alignment: 'horizontal', // 3 possibilities: vertical, horizontal, horizontalflipped
|
||||
actionSpan: 5,
|
||||
colOrder: new Array(), // array of column order
|
||||
colVisib: new Array(), // array of column visibility
|
||||
tableCreateTime: null, // table creation time, only available in "Browse tab"
|
||||
hintShown: false, // true if hint balloon is shown, used by updateHint() method
|
||||
reorderHint: '', // string, hint for column reordering
|
||||
@ -18,6 +19,8 @@
|
||||
showSortHint: false, // boolean, used by showHint() method
|
||||
showMarkHint: false,
|
||||
hintIsHiding: false, // true when hint is still shown, but hide() already called
|
||||
nHide: -1, // zero-based index of column to hide
|
||||
visibleHeadersCount: 0, // number of visible data headers
|
||||
|
||||
// functions
|
||||
dragStartRsz: function(e, obj) { // start column resize
|
||||
@ -28,11 +31,12 @@
|
||||
obj: obj,
|
||||
objLeft: $(obj).position().left,
|
||||
objWidth: this.alignment != 'vertical' ?
|
||||
$(this.t).find('th.draggable:eq(' + n + ') span').outerWidth() :
|
||||
$(this.t).find('th.draggable:visible:eq(' + n + ') span').outerWidth() :
|
||||
$(this.t).find('tr:first td:eq(' + n + ') span').outerWidth()
|
||||
};
|
||||
$('body').css('cursor', 'col-resize');
|
||||
$('body').noSelect();
|
||||
$(g.cHide).hide();
|
||||
},
|
||||
|
||||
dragStartMove: function(e, obj) { // start column move
|
||||
@ -76,6 +80,7 @@
|
||||
$('body').css('cursor', 'move');
|
||||
this.hideHint();
|
||||
$('body').noSelect();
|
||||
$(g.cHide).hide();
|
||||
},
|
||||
|
||||
dragMove: function(e) {
|
||||
@ -141,20 +146,11 @@
|
||||
}
|
||||
var n = this.colRsz.n;
|
||||
// do the resizing
|
||||
if (this.alignment != 'vertical') {
|
||||
$(this.t).find('tr').each(function() {
|
||||
$(this).find('th.draggable:eq(' + n + ') span,' +
|
||||
'td:eq(' + (g.actionSpan + n) + ') span')
|
||||
.css('width', nw);
|
||||
});
|
||||
} else { // vertical alignment
|
||||
$(this.t).find('tr').each(function() {
|
||||
$(this).find('td:eq(' + n + ') span')
|
||||
.css('width', nw);
|
||||
});
|
||||
}
|
||||
this.resize(n, nw);
|
||||
|
||||
$('body').css('cursor', 'default');
|
||||
this.reposRsz();
|
||||
this.reposDrop();
|
||||
this.colRsz = false;
|
||||
} else if (this.colMov) {
|
||||
// shift columns
|
||||
@ -167,7 +163,7 @@
|
||||
this.colMov.n = this.colMov.newn;
|
||||
// send request to server to remember the column order
|
||||
if (this.tableCreateTime) {
|
||||
this.sendColOrder();
|
||||
this.sendColPrefs();
|
||||
}
|
||||
this.refreshRestoreButton();
|
||||
}
|
||||
@ -187,19 +183,36 @@
|
||||
$('body').noSelect(false);
|
||||
},
|
||||
|
||||
/**
|
||||
* Resize column n to new width "nw"
|
||||
*/
|
||||
resize: function(n, nw) {
|
||||
if (this.alignment != 'vertical') {
|
||||
$(this.t).find('tr').each(function() {
|
||||
$(this).find('th.draggable:visible:eq(' + n + ') span,' +
|
||||
'td:visible:eq(' + (g.actionSpan + n) + ') span')
|
||||
.css('width', nw);
|
||||
});
|
||||
} else { // vertical alignment
|
||||
$(this.t).find('tr').each(function() {
|
||||
$(this).find('td:eq(' + n + ') span')
|
||||
.css('width', nw);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Reposition column resize bars.
|
||||
*/
|
||||
reposRsz: function() {
|
||||
$(this.cRsz).find('div').hide();
|
||||
$firstRowCols = this.alignment != 'vertical' ?
|
||||
$(this.t).find('tr:first th.draggable') :
|
||||
$(this.t).find('tr:first th.draggable:visible') :
|
||||
$(this.t).find('tr:first td');
|
||||
for (var n = 0; n < $firstRowCols.length; n++) {
|
||||
$this = $($firstRowCols[n]);
|
||||
$cb = $(g.cRsz).find('div:eq(' + n + ')'); // column border
|
||||
var pad = parseInt($this.css('padding-right'));
|
||||
$cb.css('left', Math.floor($this.position().left + $this.width() + pad))
|
||||
$cb.css('left', $this.position().left + $this.outerWidth(true))
|
||||
.show();
|
||||
}
|
||||
},
|
||||
@ -229,16 +242,30 @@
|
||||
// shift rows
|
||||
if (newn < oldn) {
|
||||
$(this.t).find('tr:eq(' + (g.actionSpan + newn) + ')')
|
||||
.before($(this.t).find('tr:eq(' + (g.actionSpan + oldn) + ')'));
|
||||
.before($(this.t).find('tr:eq(' + (g.actionSpan + oldn) + ')'));
|
||||
} else {
|
||||
$(this.t).find('tr:eq(' + (g.actionSpan + newn) + ')')
|
||||
.after($(this.t).find('tr:eq(' + (g.actionSpan + oldn) + ')'));
|
||||
.after($(this.t).find('tr:eq(' + (g.actionSpan + oldn) + ')'));
|
||||
}
|
||||
}
|
||||
// adjust the column visibility list
|
||||
if (newn < oldn) {
|
||||
$(g.cList).find('tr:eq(' + newn + ')')
|
||||
.before($(g.cList).find('tr:eq(' + oldn + ')'));
|
||||
} else {
|
||||
$(g.cList).find('tr:eq(' + newn + ')')
|
||||
.after($(g.cList).find('tr:eq(' + oldn + ')'));
|
||||
}
|
||||
// adjust the colOrder
|
||||
var tmp = this.colOrder[oldn];
|
||||
this.colOrder.splice(oldn, 1);
|
||||
this.colOrder.splice(newn, 0, tmp);
|
||||
// adjust the colVisib
|
||||
var tmp = this.colVisib[oldn];
|
||||
this.colVisib.splice(oldn, 1);
|
||||
this.colVisib.splice(newn, 0, tmp);
|
||||
|
||||
$(g.cHide).hide();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -247,10 +274,10 @@
|
||||
*/
|
||||
getHoveredCol: function(e) {
|
||||
var hoveredCol;
|
||||
$headers = $(this.t).find('th.draggable');
|
||||
$headers = $(this.t).find('th.draggable:visible');
|
||||
if (this.alignment != 'vertical') {
|
||||
$headers.each(function() {
|
||||
var left = $(this).position().left;
|
||||
var left = $(this).offset().left;
|
||||
var right = left + $(this).outerWidth();
|
||||
if (left <= e.pageX && e.pageX <= right) {
|
||||
hoveredCol = this;
|
||||
@ -258,7 +285,7 @@
|
||||
});
|
||||
} else { // vertical alignment
|
||||
$headers.each(function() {
|
||||
var top = $(this).position().top;
|
||||
var top = $(this).offset().top;
|
||||
var bottom = top + $(this).height();
|
||||
if (top <= e.pageY && e.pageY <= bottom) {
|
||||
hoveredCol = this;
|
||||
@ -286,7 +313,7 @@
|
||||
/**
|
||||
* Reposition the table back to normal order.
|
||||
*/
|
||||
restore: function() {
|
||||
restoreColOrder: function() {
|
||||
// use insertion sort, since we already have shiftCol function
|
||||
for (var i = 1; i < this.colOrder.length; i++) {
|
||||
var x = this.colOrder[i];
|
||||
@ -300,23 +327,24 @@
|
||||
}
|
||||
if (this.tableCreateTime) {
|
||||
// send request to server to remember the column order
|
||||
this.sendColOrder();
|
||||
this.sendColPrefs();
|
||||
}
|
||||
this.refreshRestoreButton();
|
||||
},
|
||||
|
||||
/**
|
||||
* Send column order to the server.
|
||||
* Send column preferences (column order and visibility) to the server.
|
||||
*/
|
||||
sendColOrder: function() {
|
||||
sendColPrefs: function() {
|
||||
$.post('sql.php', {
|
||||
ajax_request: true,
|
||||
db: window.parent.db,
|
||||
table: window.parent.table,
|
||||
token: window.parent.token,
|
||||
server: window.parent.server,
|
||||
set_col_order: true,
|
||||
set_col_prefs: true,
|
||||
col_order: this.colOrder.toString(),
|
||||
col_visib: this.colVisib.toString(),
|
||||
table_create_time: this.tableCreateTime
|
||||
});
|
||||
},
|
||||
@ -334,8 +362,10 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
// check if only one visible column left
|
||||
var isOneColumn = this.visibleHeadersCount == 1;
|
||||
// enable or disable restore button
|
||||
if (isInitial) {
|
||||
if (isInitial || isOneColumn) {
|
||||
$('.restore_column').hide();
|
||||
} else {
|
||||
$('.restore_column').show();
|
||||
@ -373,8 +403,8 @@
|
||||
$(this.dHint)
|
||||
.stop(true, true)
|
||||
.css({
|
||||
top: e.pageY,
|
||||
left: e.pageX + 15
|
||||
top: e.clientY,
|
||||
left: e.clientX + 15
|
||||
})
|
||||
.show('fast');
|
||||
this.hintShown = true;
|
||||
@ -404,18 +434,167 @@
|
||||
updateHint: function(e) {
|
||||
if (this.hintShown) {
|
||||
$(this.dHint).css({
|
||||
top: e.pageY,
|
||||
left: e.pageX + 15
|
||||
top: e.clientY,
|
||||
left: e.clientX + 15
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Show button to hide column.
|
||||
*/
|
||||
showHideBtn: function(obj) {
|
||||
if (!this.colRsz && ! this.colMov) {
|
||||
// check if visible headers is more than one
|
||||
if (this.visibleHeadersCount > 1) {
|
||||
pos = $(obj).position();
|
||||
$(g.cHide).css({
|
||||
left: pos.left + $(obj).width(),
|
||||
top: pos.top
|
||||
})
|
||||
.show();
|
||||
this.nHide = this.getHeaderIdx(obj);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle column's visibility.
|
||||
* After calling this function and it returns true, afterToggleCol() must be called.
|
||||
*
|
||||
* @return boolean True if the column is toggled successfully.
|
||||
*/
|
||||
toggleCol: function(n) {
|
||||
if (this.colVisib[n]) {
|
||||
// can hide if more than one column is visible
|
||||
if (this.visibleHeadersCount > 1) {
|
||||
if (this.alignment != 'vertical') {
|
||||
$(this.t).find('tr').each(function() {
|
||||
$(this).find('th.draggable:eq(' + n + '),' +
|
||||
'td:eq(' + (g.actionSpan + n) + ')')
|
||||
.hide();
|
||||
});
|
||||
} else { // vertical alignment
|
||||
$(this.t).find('tr:eq(' + (g.actionSpan + n) + ')')
|
||||
.hide();
|
||||
}
|
||||
this.colVisib[n] = 0;
|
||||
$(this.cList).find('tr:eq(' + n + ') input').removeAttr('checked');
|
||||
} else {
|
||||
// cannot hide, force the checkbox to stay checked
|
||||
$(this.cList).find('tr:eq(' + n + ') input').attr('checked', 'checked');
|
||||
return false;
|
||||
}
|
||||
} else { // column n is not visible
|
||||
if (this.alignment != 'vertical') {
|
||||
$(this.t).find('tr').each(function() {
|
||||
$(this).find('th.draggable:eq(' + n + '),' +
|
||||
'td:eq(' + (g.actionSpan + n) + ')')
|
||||
.show();
|
||||
});
|
||||
} else { // vertical alignment
|
||||
$(this.t).find('tr:eq(' + (g.actionSpan + n) + ')')
|
||||
.show();
|
||||
}
|
||||
this.colVisib[n] = 1;
|
||||
$(this.cList).find('tr:eq(' + n + ') input').attr('checked', 'checked');
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* This must be called after calling toggleCol() and the return value is true.
|
||||
*
|
||||
* This function is separated from toggleCol because, sometimes, we want to toggle
|
||||
* some columns together at one time and do one adjustment after it, e.g. in showAllColumns().
|
||||
*/
|
||||
afterToggleCol: function() {
|
||||
// some adjustments after hiding column
|
||||
this.reposRsz();
|
||||
this.reposDrop();
|
||||
$(g.cHide).hide();
|
||||
this.sendColPrefs();
|
||||
|
||||
// check visible first row headers count
|
||||
this.visibleHeadersCount = this.alignment != 'vertical' ?
|
||||
$(this.t).find('tr:first th.draggable:visible').length :
|
||||
$(this.t).find('th.draggable:nth-child(1):visible').length;
|
||||
this.refreshRestoreButton();
|
||||
this.refreshShowAllButton();
|
||||
},
|
||||
|
||||
/**
|
||||
* Show columns' visibility list.
|
||||
*/
|
||||
showColList: function(obj) {
|
||||
// only show when not resizing or reordering
|
||||
if (!this.colRsz && !this.colMov) {
|
||||
var pos = $(obj).position();
|
||||
// check if the list position is too right
|
||||
if (pos.left + $(this.cList).outerWidth(true) > $(document).width()) {
|
||||
pos.left = $(document).width() - $(this.cList).outerWidth(true);
|
||||
}
|
||||
$(this.cList).css({
|
||||
left: pos.left,
|
||||
top: pos.top + $(obj).outerHeight(true)
|
||||
})
|
||||
.show();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Reposition the column visibility drop-down arrow.
|
||||
*/
|
||||
reposDrop: function() {
|
||||
$th = $(t).find('th:not(.draggable)');
|
||||
for (var i = 0; i < $th.length; i++) {
|
||||
var $cd = $(this.cDrop).find('div:eq(' + i + ')'); // column drop-down arrow
|
||||
var pos = $($th[i]).position();
|
||||
$cd.css({
|
||||
left: pos.left + $($th[i]).width() - $cd.width(),
|
||||
top: pos.top
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Refresh "show all columns" button state.
|
||||
* Make the button disabled if the table's columns are all shown.
|
||||
*/
|
||||
refreshShowAllButton: function() {
|
||||
if (this.visibleHeadersCount < this.colVisib.length) {
|
||||
$('.show_all_column').show();
|
||||
} else {
|
||||
$('.show_all_column').hide();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Show all hidden columns.
|
||||
*/
|
||||
showAllColumns: function() {
|
||||
for (var i = 0; i < this.colVisib.length; i++) {
|
||||
if (!this.colVisib[i]) {
|
||||
this.toggleCol(i);
|
||||
}
|
||||
}
|
||||
this.afterToggleCol();
|
||||
this.refreshShowAllButton();
|
||||
}
|
||||
}
|
||||
|
||||
// wrap all data cells, except actions cell, with span
|
||||
$(t).find('th, td:not(:has(span))')
|
||||
.wrapInner('<span />');
|
||||
|
||||
g.gDiv = document.createElement('div'); // create global div
|
||||
g.cRsz = document.createElement('div'); // column resizer
|
||||
g.cCpy = document.createElement('div'); // column copy, to store copy of dragged column header
|
||||
g.cPointer = document.createElement('div'); // column pointer, used when reordering column
|
||||
g.dHint = document.createElement('div'); // draggable hint
|
||||
g.cHide = document.createElement('div'); // column hide button
|
||||
g.cDrop = document.createElement('div'); // column drop-down arrows
|
||||
g.cList = document.createElement('div'); // column visibility list
|
||||
|
||||
// assign the table alignment
|
||||
g.alignment = $("#top_direction_dropdown").val();
|
||||
@ -432,6 +611,17 @@
|
||||
g.dHint.className = 'dHint';
|
||||
$(g.dHint).hide();
|
||||
|
||||
// adjust g.cHide
|
||||
g.cHide.className = 'cHide';
|
||||
$(g.cHide).hide();
|
||||
|
||||
// adjust g.cDrop
|
||||
g.cDrop.className = 'cDrop';
|
||||
|
||||
// adjust g.cList
|
||||
g.cList.className = 'cList';
|
||||
$(g.cList).hide();
|
||||
|
||||
// chain table and grid together
|
||||
t.grid = g;
|
||||
g.t = t;
|
||||
@ -441,6 +631,14 @@
|
||||
$(t).find('tr:first th.draggable') :
|
||||
$(t).find('tr:first td');
|
||||
|
||||
// get first row of data headers (first column of data headers, in vertical mode)
|
||||
var $firstRowHeaders = g.alignment != 'vertical' ?
|
||||
$(t).find('tr:first th.draggable') :
|
||||
$(t).find('th.draggable:nth-child(1)');
|
||||
|
||||
// initialize g.visibleHeadersCount
|
||||
g.visibleHeadersCount = $firstRowHeaders.filter(':visible').length;
|
||||
|
||||
// assign first column (actions) span
|
||||
if (! $(t).find('tr:first th:first').hasClass('draggable')) { // action header exist
|
||||
g.actionSpan = g.alignment != 'vertical' ?
|
||||
@ -468,37 +666,91 @@
|
||||
}
|
||||
} else {
|
||||
g.colOrder = new Array();
|
||||
for (var i = 0; i < $firstRowCols.length; i++) {
|
||||
for (var i = 0; i < $firstRowHeaders.length; i++) {
|
||||
g.colOrder.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
// initialize column visibility
|
||||
$col_visib = $('#col_visib');
|
||||
if ($col_visib.length > 0) {
|
||||
g.colVisib = $col_visib.val().split(',');
|
||||
for (var i = 0; i < g.colVisib.length; i++) {
|
||||
g.colVisib[i] = parseInt(g.colVisib[i]);
|
||||
}
|
||||
} else {
|
||||
g.colVisib = new Array();
|
||||
for (var i = 0; i < $firstRowHeaders.length; i++) {
|
||||
g.colVisib.push(1);
|
||||
}
|
||||
}
|
||||
|
||||
if ($firstRowHeaders.length > 1) {
|
||||
// create column drop-down arrow(s)
|
||||
$(t).find('th:not(.draggable)').each(function() {
|
||||
var cd = document.createElement('div'); // column drop-down arrow
|
||||
var pos = $(this).position();
|
||||
$(cd).addClass('coldrop')
|
||||
.css({
|
||||
left: pos.left + $(this).width() - $(cd).width(),
|
||||
top: pos.top
|
||||
})
|
||||
.click(function() {
|
||||
if (g.cList.style.display == 'none') {
|
||||
g.showColList(this);
|
||||
} else {
|
||||
$(g.cList).hide();
|
||||
}
|
||||
});
|
||||
$(g.cDrop).append(cd);
|
||||
});
|
||||
|
||||
// add column visibility control
|
||||
g.cList.innerHTML = '<table cellpadding="0" cellspacing="0"><tbody></tbody></table>';
|
||||
var $tbody = $(g.cList).find('tbody');
|
||||
for (var i = 0; i < $firstRowHeaders.length; i++) {
|
||||
var currHeader = $firstRowHeaders[i];
|
||||
var tr = document.createElement('tr');
|
||||
tr.innerHTML = '<td><input type="checkbox" ' + (g.colVisib[i] ? 'checked="checked" ' : '') + '/></td>' +
|
||||
'<td>' + $(currHeader).text() + '</td>';
|
||||
$tbody.append(tr);
|
||||
// add event on click
|
||||
$(tr).click(function() {
|
||||
if ( g.toggleCol($(this).index()) ) {
|
||||
g.afterToggleCol();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// create column borders
|
||||
$firstRowCols.each(function() {
|
||||
$this = $(this);
|
||||
var cb = document.createElement('div'); // column border
|
||||
var pad = parseInt($this.css('padding-right'));
|
||||
$(cb).css('left', Math.floor($this.position().left + $this.width() + pad));
|
||||
$(cb).addClass('colborder');
|
||||
$(cb).mousedown(function(e) {
|
||||
g.dragStartRsz(e, this);
|
||||
});
|
||||
$(cb).addClass('colborder')
|
||||
.mousedown(function(e) {
|
||||
g.dragStartRsz(e, this);
|
||||
});
|
||||
$(g.cRsz).append(cb);
|
||||
});
|
||||
|
||||
// wrap all data cells, except actions cell, with span
|
||||
$(t).find('th, td:not(:has(span))')
|
||||
.wrapInner('<span />');
|
||||
g.reposRsz();
|
||||
|
||||
// register events
|
||||
if ($firstRowCols.length > 1 && g.reorderHint) { // make sure columns is reorderable
|
||||
if (g.reorderHint) { // make sure columns is reorderable
|
||||
$(t).find('th.draggable')
|
||||
.css('cursor', 'move')
|
||||
.mousedown(function(e) {
|
||||
g.dragStartMove(e, this);
|
||||
if (g.visibleHeadersCount > 1) {
|
||||
g.dragStartMove(e, this);
|
||||
}
|
||||
})
|
||||
.mouseenter(function(e) {
|
||||
g.showReorderHint = true;
|
||||
if (g.visibleHeadersCount > 1) {
|
||||
g.showReorderHint = true;
|
||||
$(this).css('cursor', 'move');
|
||||
g.showHideBtn(this);
|
||||
} else {
|
||||
$(this).css('cursor', 'inherit');
|
||||
}
|
||||
g.showHint(e);
|
||||
})
|
||||
.mouseleave(function(e) {
|
||||
@ -533,7 +785,24 @@
|
||||
g.dragEnd(e);
|
||||
});
|
||||
$('.restore_column').click(function() {
|
||||
g.restore();
|
||||
g.restoreColOrder();
|
||||
});
|
||||
$('.show_all_column').click(function() {
|
||||
g.showAllColumns();
|
||||
});
|
||||
$(t).find('td, th').not('.draggable').mouseenter(function() {
|
||||
$(g.cHide).hide();
|
||||
});
|
||||
$(t).find('td, th.draggable').mouseenter(function() {
|
||||
$(g.cList).hide();
|
||||
});
|
||||
$(g.cHide).click(function() {
|
||||
if (g.toggleCol(g.nHide)) {
|
||||
g.afterToggleCol();
|
||||
}
|
||||
});
|
||||
$(g.cList).mouseleave(function() {
|
||||
$(g.cList).hide();
|
||||
});
|
||||
|
||||
// add table class
|
||||
@ -543,12 +812,16 @@
|
||||
$(t).before(g.gDiv);
|
||||
$(g.gDiv).append(t);
|
||||
$(g.gDiv).prepend(g.cRsz);
|
||||
$(g.gDiv).append(g.cCpy);
|
||||
$(g.gDiv).append(g.cPointer);
|
||||
$(g.gDiv).append(g.cHide);
|
||||
$(g.gDiv).append(g.cDrop);
|
||||
$(g.gDiv).append(g.cList);
|
||||
$(g.gDiv).append(g.dHint);
|
||||
$(g.gDiv).append(g.cCpy);
|
||||
|
||||
// some adjustment
|
||||
g.refreshRestoreButton();
|
||||
g.refreshShowAllButton();
|
||||
g.cRsz.className = 'cRsz';
|
||||
$(t).removeClass('data');
|
||||
$(g.gDiv).addClass('data');
|
||||
@ -574,9 +847,11 @@
|
||||
var t = this;
|
||||
$(document).ready(function() {
|
||||
$.grid(t);
|
||||
t.grid.reposDrop();
|
||||
});
|
||||
} else {
|
||||
$.grid(this);
|
||||
this.grid.reposDrop();
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -588,10 +863,16 @@
|
||||
if (!docready) {
|
||||
var t = this;
|
||||
$(document).ready(function() {
|
||||
if (t.grid) t.grid.reposRsz();
|
||||
if (t.grid) {
|
||||
t.grid.reposRsz();
|
||||
t.grid.reposDrop();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (this.grid) this.grid.reposRsz();
|
||||
if (this.grid) {
|
||||
this.grid.reposRsz();
|
||||
this.grid.reposDrop();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ class PMA_Table
|
||||
*/
|
||||
const PROP_SORTED_COLUMN = 'sorted_col';
|
||||
const PROP_COLUMN_ORDER = 'col_order';
|
||||
const PROP_COLUMN_VISIB = 'col_visib';
|
||||
|
||||
static $cache = array();
|
||||
|
||||
@ -1304,6 +1305,7 @@ class PMA_Table
|
||||
* Available property:
|
||||
* - PROP_SORTED_COLUMN
|
||||
* - PROP_COLUMN_ORDER
|
||||
* - PROP_COLUMN_VISIB
|
||||
*
|
||||
* @uses loadUiPrefs()
|
||||
*
|
||||
@ -1335,7 +1337,8 @@ class PMA_Table
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if ($property == self::PROP_COLUMN_ORDER) {
|
||||
} else if ($property == self::PROP_COLUMN_ORDER ||
|
||||
$property == self::PROP_COLUMN_VISIB) {
|
||||
if (isset($this->uiprefs[$property])) {
|
||||
// check if the table has not been modified
|
||||
if (self::sGetStatusInfo($this->db_name, $this->name, 'CREATE_TIME') ==
|
||||
@ -1361,10 +1364,11 @@ class PMA_Table
|
||||
* Available property:
|
||||
* - PROP_SORTED_COLUMN
|
||||
* - PROP_COLUMN_ORDER
|
||||
* - PROP_COLUMN_VISIB
|
||||
*
|
||||
* @param string $property
|
||||
* @param mixed $value
|
||||
* @param string $table_create_time Needed for PROP_COLUMN_ORDER
|
||||
* @param string $table_create_time Needed for PROP_COLUMN_ORDER and PROP_COLUMN_VISIB
|
||||
* @return boolean|PMA_Message
|
||||
*/
|
||||
public function setUiProp($property, $value, $table_create_time = NULL)
|
||||
@ -1373,7 +1377,9 @@ class PMA_Table
|
||||
$this->loadUiPrefs();
|
||||
}
|
||||
// we want to save the create time if the property is PROP_COLUMN_ORDER
|
||||
if ($property == self::PROP_COLUMN_ORDER) {
|
||||
if ($property == self::PROP_COLUMN_ORDER ||
|
||||
$property == self::PROP_COLUMN_VISIB) {
|
||||
|
||||
$curr_create_time = self::sGetStatusInfo($this->db_name, $this->name, 'CREATE_TIME');
|
||||
if (isset($table_create_time) &&
|
||||
$table_create_time == $curr_create_time) {
|
||||
|
||||
@ -395,6 +395,7 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di
|
||||
?>
|
||||
<td>
|
||||
<input class="restore_column hide" type="submit" value="<?php echo __('Restore column order'); ?>" />
|
||||
<input class="show_all_column hide" type="submit" value="<?php echo __('Show all columns'); ?>" />
|
||||
<?php
|
||||
if (PMA_isSelect()) {
|
||||
// generate the column order, if it is set
|
||||
@ -403,6 +404,10 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di
|
||||
if ($col_order) {
|
||||
echo '<input id="col_order" type="hidden" value="' . implode(',', $col_order) . '" />';
|
||||
}
|
||||
$col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB);
|
||||
if ($col_visib) {
|
||||
echo '<input id="col_visib" type="hidden" value="' . implode(',', $col_visib) . '" />';
|
||||
}
|
||||
// generate table create time
|
||||
echo '<input id="table_create_time" type="hidden" value="' .
|
||||
PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'CREATE_TIME') . '" />';
|
||||
@ -791,8 +796,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
|
||||
// prepare to get the column order, if available
|
||||
$pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
|
||||
$col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER);
|
||||
$col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB);
|
||||
} else {
|
||||
$col_order = false;
|
||||
$col_visib = false;
|
||||
}
|
||||
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
@ -933,6 +940,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
|
||||
echo '<th';
|
||||
$th_class = array();
|
||||
$th_class[] = 'draggable';
|
||||
if ($col_visib && !$col_visib[$j]) {
|
||||
$th_class[] = 'hide';
|
||||
}
|
||||
if ($condition_field) {
|
||||
$th_class[] = 'condition';
|
||||
}
|
||||
@ -951,7 +961,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
|
||||
echo '>' . $order_link . $comments . '</th>';
|
||||
}
|
||||
$vertical_display['desc'][] = ' <th '
|
||||
. 'class="draggable' . ($condition_field ? ' condition' : '') . '">' . "\n"
|
||||
. 'class="draggable'
|
||||
. ($condition_field ? ' condition' : '')
|
||||
. '">' . "\n"
|
||||
. $order_link . $comments . ' </th>' . "\n";
|
||||
} // end if (2.1)
|
||||
|
||||
@ -962,6 +974,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
|
||||
echo '<th';
|
||||
$th_class = array();
|
||||
$th_class[] = 'draggable';
|
||||
if ($col_visib && !$col_visib[$j]) {
|
||||
$th_class[] = 'hide';
|
||||
}
|
||||
if ($condition_field) {
|
||||
$th_class[] = 'condition';
|
||||
}
|
||||
@ -983,7 +998,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
|
||||
echo "\n" . $comments . '</th>';
|
||||
}
|
||||
$vertical_display['desc'][] = ' <th '
|
||||
. 'class="draggable' . ($condition_field ? ' condition"' : '') . '">' . "\n"
|
||||
. 'class="draggable'
|
||||
. ($condition_field ? ' condition"' : '')
|
||||
. '">' . "\n"
|
||||
. ' ' . htmlspecialchars($fields_meta[$i]->name) . "\n"
|
||||
. $comments . ' </th>';
|
||||
} // end else (2.2)
|
||||
@ -1197,8 +1214,10 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
|
||||
if (PMA_isSelect()) {
|
||||
$pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
|
||||
$col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER);
|
||||
$col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB);
|
||||
} else {
|
||||
$col_order = false;
|
||||
$col_visib = false;
|
||||
}
|
||||
|
||||
// Correction University of Virginia 19991216 in the while below
|
||||
@ -1369,11 +1388,14 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
|
||||
$meta = $fields_meta[$i];
|
||||
$not_null_class = $meta->not_null ? 'not_null' : '';
|
||||
$relation_class = isset($map[$meta->name]) ? 'relation' : '';
|
||||
$hide_class = ($col_visib && !$col_visib[$j] &&
|
||||
// hide per <td> only if the display direction is not vertical
|
||||
$_SESSION['tmp_user_values']['disp_direction'] != 'vertical') ? 'hide' : '';
|
||||
$pointer = $i;
|
||||
$is_field_truncated = false;
|
||||
//If the previous column had blob data, we need to reset the class
|
||||
// to $inline_edit_class
|
||||
$class = 'data ' . $inline_edit_class . ' ' . $not_null_class . ' ' . $alternating_color_class . ' ' . $relation_class;
|
||||
$class = 'data ' . $inline_edit_class . ' ' . $not_null_class . ' ' . $alternating_color_class . ' ' . $relation_class . ' ' . $hide_class;
|
||||
|
||||
// See if this column should get highlight because it's used in the
|
||||
// where-query.
|
||||
@ -1794,8 +1816,10 @@ function PMA_displayVerticalTable()
|
||||
// prepare to get the column order, if available
|
||||
$pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
|
||||
$col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER);
|
||||
$col_visib = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_VISIB);
|
||||
} else {
|
||||
$col_order = false;
|
||||
$col_visib = false;
|
||||
}
|
||||
|
||||
// Displays data
|
||||
@ -1803,7 +1827,7 @@ function PMA_displayVerticalTable()
|
||||
// assign appropriate key with current column order
|
||||
$key = $col_order ? $col_order[$j] : $j;
|
||||
|
||||
echo '<tr>' . "\n";
|
||||
echo '<tr' . (($col_visib && !$col_visib[$j]) ? ' class="hide"' : '') . '>' . "\n";
|
||||
echo $val;
|
||||
|
||||
$foo_counter = 0;
|
||||
|
||||
9
sql.php
9
sql.php
@ -164,10 +164,17 @@ if(isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) {
|
||||
/**
|
||||
* Check ajax request to set the column order
|
||||
*/
|
||||
if(isset($_REQUEST['set_col_order']) && $_REQUEST['set_col_order'] == true) {
|
||||
if(isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) {
|
||||
$pmatable = new PMA_Table($table, $db);
|
||||
|
||||
// set column order
|
||||
$col_order = explode(',', $_REQUEST['col_order']);
|
||||
$retval = $pmatable->setUiProp(PMA_Table::PROP_COLUMN_ORDER, $col_order, $_REQUEST['table_create_time']);
|
||||
|
||||
// set column visibility
|
||||
$col_visib = explode(',', $_REQUEST['col_visib']);
|
||||
$retval &= $pmatable->setUiProp(PMA_Table::PROP_COLUMN_VISIB, $col_visib, $_REQUEST['table_create_time']);
|
||||
|
||||
PMA_ajaxResponse(NULL, ($retval == true));
|
||||
}
|
||||
|
||||
|
||||
@ -2067,11 +2067,15 @@ span.mysql-number {
|
||||
border-right: solid 1px #FFFFFF;
|
||||
cursor: col-resize;
|
||||
height: 100%;
|
||||
margin-left: -3px;
|
||||
margin-left: -6px;
|
||||
position: absolute;
|
||||
width: 5px;
|
||||
}
|
||||
|
||||
.pma_table td {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.pma_table th.draggable span, .pma_table tbody td span {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
@ -2121,9 +2125,71 @@ span.mysql-number {
|
||||
margin-top: -1em;
|
||||
opacity: 0.8;
|
||||
padding: 0.5em 1em;
|
||||
position: absolute;
|
||||
position: fixed;
|
||||
text-shadow: -1px -1px #000;
|
||||
-moz-border-radius: 0.3em;
|
||||
-webkit-border-radius: 0.3em;
|
||||
border-radius: 0.3em;
|
||||
}
|
||||
|
||||
.data {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.cHide {
|
||||
background: #D3DCE3 url(<?php echo $_SESSION['PMA_Theme']->getImgPath(); ?>col_hide.png);
|
||||
color: #CCC;
|
||||
cursor: pointer;
|
||||
height: 16px;
|
||||
margin-left: -5px;
|
||||
margin-top: 0.3em;
|
||||
position: absolute;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.cHide:hover {
|
||||
background-color: #AAA;
|
||||
}
|
||||
|
||||
.cDrop {
|
||||
left: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.coldrop {
|
||||
background: url(<?php echo $_SESSION['PMA_Theme']->getImgPath(); ?>col_drop.png);
|
||||
cursor: pointer;
|
||||
height: 16px;
|
||||
margin-left: 8px;
|
||||
margin-top: 0.3em;
|
||||
position: absolute;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.coldrop:hover {
|
||||
background-color: #AAA;
|
||||
}
|
||||
|
||||
.cList {
|
||||
background: #FFF;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.cList table {
|
||||
background: #EEE;
|
||||
border: solid 1px #CCC;
|
||||
}
|
||||
|
||||
.cList table td {
|
||||
border-right: solid 1px #CCC;
|
||||
}
|
||||
|
||||
.cList table tr:hover {
|
||||
background: #DDD;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cList table td input {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ h2 a img{display:inline;}
|
||||
|
||||
.data{
|
||||
margin: 0 0 12px 0;
|
||||
|
||||
position: relative;
|
||||
}
|
||||
|
||||
h3 {
|
||||
@ -2422,14 +2422,18 @@ span.mysql-number {
|
||||
}
|
||||
|
||||
.colborder {
|
||||
border-left: 1px solid #FFF;
|
||||
border-right: 1px solid #FFF;
|
||||
cursor: col-resize;
|
||||
height: 100%;
|
||||
margin-left: -1px;
|
||||
margin-left: -6px;
|
||||
position: absolute;
|
||||
width: 5px;
|
||||
}
|
||||
|
||||
.pma_table td {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.pma_table th.draggable span, .pma_table tbody td span {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
@ -2483,9 +2487,67 @@ span.mysql-number {
|
||||
margin-top: -1em;
|
||||
opacity: 0.8;
|
||||
padding: 0.5em 1em;
|
||||
position: absolute;
|
||||
position: fixed;
|
||||
text-shadow: -1px -1px #000;
|
||||
-moz-border-radius: 0.3em;
|
||||
-webkit-border-radius: 0.3em;
|
||||
border-radius: 0.3em;
|
||||
}
|
||||
|
||||
.cHide {
|
||||
background: #EEE url(./themes/pmahomme/img/col_hide.png);
|
||||
color: #CCC;
|
||||
cursor: pointer;
|
||||
height: 16px;
|
||||
margin-left: -10px;
|
||||
margin-top: 0.3em;
|
||||
position: absolute;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.cHide:hover {
|
||||
background-color: #AAA;
|
||||
}
|
||||
|
||||
.cDrop {
|
||||
left: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.coldrop {
|
||||
background: url(./themes/pmahomme/img/col_drop.png);
|
||||
cursor: pointer;
|
||||
height: 16px;
|
||||
margin-left: 3px;
|
||||
margin-top: 0.3em;
|
||||
position: absolute;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.coldrop:hover {
|
||||
background-color: #AAA;
|
||||
}
|
||||
|
||||
.cList {
|
||||
background: #FFF;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.cList table {
|
||||
background: #EEE;
|
||||
border: solid 1px #CCC;
|
||||
}
|
||||
|
||||
.cList table td {
|
||||
border-right: solid 1px #CCC;
|
||||
}
|
||||
|
||||
.cList table tr:hover {
|
||||
background: #DDD;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cList table td input {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user