diff --git a/ChangeLog b/ChangeLog
index 55aa07e73c..c3f48f9724 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -70,6 +70,7 @@ VerboseMultiSubmit, ReplaceHelpImg
+ Renamed configuration directive: LeftDisplayDatabaseFilterMinimum => NavigationTreeDisplayDbFilterMinimum
+ Removed the "Mark row on click" feature; must now click the checkbox to mark
+ Removed the "Synchronize" feature
++ Improved layout of server variables page
3.5.5.0 (not yet released)
diff --git a/js/server_variables.js b/js/server_variables.js
index 05955b349d..474cbd0eb3 100644
--- a/js/server_variables.js
+++ b/js/server_variables.js
@@ -4,204 +4,151 @@
* Unbind all event handlers before tearing down a page
*/
AJAX.registerTeardown('server_variables.js', function() {
- $('table.data tbody tr td:nth-child(2).editable').unbind('hover');
+ $('#serverVariables .var-row').unbind('hover');
$('#filterText').unbind('keyup');
+ $('a.editLink').die('click');
});
AJAX.registerOnload('server_variables.js', function() {
- var textFilter = null, odd_row = false;
- var testString = 'abcdefghijklmnopqrstuvwxyz0123456789,ABCEFGHIJKLMOPQRSTUVWXYZ';
- var $tmpDiv, charWidth;
+ var $editLink = $('a.editLink');
+ var $saveLink = $('a.saveLink');
+ var $cancelLink = $('a.cancelLink');
- // Global vars
- $editLink = $('a.editLink');
- $saveLink = $('a.saveLink');
- $cancelLink = $('a.cancelLink');
-
- /* Variable editing */
- $('table.data tbody tr td:nth-child(2).editable').hover(
- function() {
- // Only add edit element if it is the global value, not session value and not when the element is being edited
- if ($(this).parent().children('th').length > 0 && ! $(this).hasClass('edit')) {
- $(this).prepend($editLink.clone().show());
+ /* Show edit link on hover */
+ $('#serverVariables').delegate('.var-row', 'hover', function(event) {
+ if (event.type === 'mouseenter') {
+ var $elm = $(this).find('.var-value');
+ // Only add edit element if the element is not being edited
+ if ($elm.hasClass('editable') && ! $elm.hasClass('edit')) {
+ $elm.prepend($editLink.clone().show());
}
- },
- function() {
+ } else {
$(this).find('a.editLink').remove();
}
- );
-
- $('#filterText').keyup(function(e) {
- if ($(this).val().length == 0) {
- textFilter=null;
- } else {
- textFilter = new RegExp("(^| )"+$(this).val().replace(/_/g,' '),'i');
- }
- filterVariables();
});
- if (location.hash.substr(1).split('=')[0] == 'filter') {
- var name = location.hash.substr(1).split('=')[1];
- // Only allow variable names
- if (! name.match(/[^0-9a-zA-Z_]+/)) {
- $('#filterText').val(name).trigger('keyup');
+ /* Launches the variable editor */
+ $('a.editLink').live('click', function (event) {
+ event.preventDefault();
+ editVariable(this);
+ });
+
+ /* Event handler for variables filter */
+ $('#filterText').keyup(function() {
+ var textFilter = null, val = $(this).val();
+ if (val.length !== 0) {
+ textFilter = new RegExp("(^| )"+val.replace(/_/g,' '),'i');
}
- }
+ filterVariables(textFilter);
+ });
- /* Table width limiting */
- $('table.data').after($tmpDiv=$(''+testString+''));
- charWidth = $tmpDiv.width() / testString.length;
- $tmpDiv.remove();
-
- $(window).resize(limitTableWidth); // FIXME: this doesn't work that well and binding anything to the window resize event is a bad idea
- limitTableWidth();
-
- /* This function chops of long variable values to keep the table from overflowing horizontally
- * It does so by taking a test string and calculating an average font width and removing 'excess width / average font width'
- * chars, so it is not very accurate.
- */
- function limitTableWidth() {
- var fulltext;
- var charDiff;
- var maxTableWidth;
- var $tmpTable;
-
- $('table.data').after($tmpTable = $('
' + testString + '
'));
- maxTableWidth = $('#testTable').width();
- $tmpTable.remove();
- charDiff = ($('table.data').width() - maxTableWidth) / charWidth;
-
- if ($('body').innerWidth() < $('table.data').width() + 10 || $('body').innerWidth() > $('table.data').width() + 20) {
- var maxChars = 0;
-
- $('table.data tbody tr td:nth-child(2)').each(function() {
- maxChars = Math.max($(this).text().length, maxChars);
- });
-
- // Do not resize smaller if there's only 50 chars displayed already
- if (charDiff > 0 && maxChars < 50) { return; }
-
- $('table.data tbody tr td:nth-child(2)').each(function() {
- if ((charDiff > 0 && $(this).text().length > maxChars - charDiff) || (charDiff < 0 && $(this).find('abbr.cutoff').length > 0)) {
- if ($(this).find('abbr.cutoff').length > 0) {
- fulltext = $(this).find('abbr.cutoff').attr('title');
- } else {
- fulltext = $(this).text();
- // Do not cut off elements with html in it and hope they are not too long
- if (fulltext.length != $(this).html().length) { return 0; }
- }
-
- if (fulltext.length < maxChars - charDiff) {
- $(this).html(fulltext);
- } else {
- $(this).html('' + fulltext.substr(0, maxChars - charDiff - 3) + '...');
- }
- }
- });
- }
+ /* Trigger filtering of the list based on incoming variable name */
+ if ($('#filterText').val()) {
+ $('#filterText').trigger('keyup').select();
}
/* Filters the rows by the user given regexp */
- function filterVariables() {
- var mark_next = false, firstCell;
- odd_row = false;
-
- $('table.filteredData tbody tr').each(function() {
- firstCell = $(this).children(':first');
-
- if (mark_next || textFilter == null || textFilter.exec(firstCell.text())) {
- // If current global value is different from session value (=has class diffSession), then display that one too
- mark_next = $(this).hasClass('diffSession') && ! mark_next;
+ function filterVariables(textFilter) {
+ var mark_next = false, $row, odd_row = false;
+ $('#serverVariables .var-row').not('.var-header').each(function() {
+ $row = $(this);
+ if ( mark_next
+ || textFilter === null
+ || textFilter.exec($row.find('.var-name').text())
+ ) {
+ // If current global value is different from session value
+ // (has class diffSession), then display that one too
+ mark_next = $row.hasClass('diffSession') && ! mark_next;
odd_row = ! odd_row;
- $(this).css('display','');
+ $row.css('display', '');
if (odd_row) {
- $(this).addClass('odd');
- $(this).removeClass('even');
+ $row.addClass('odd').removeClass('even');
} else {
- $(this).addClass('even');
- $(this).removeClass('odd');
+ $row.addClass('even').removeClass('odd');
}
} else {
- $(this).css('display','none');
+ $row.css('display', 'none');
}
});
}
-});
-/* Called by inline js. Allows the user to edit a server variable */
-function editVariable(link)
-{
- var varName = $(link).parent().parent().find('th:first').first().text().replace(/ /g,'_');
- var $mySaveLink = $saveLink.clone().show();
- var $myCancelLink = $cancelLink.clone().show();
- var $cell = $(link).parent();
- var $msgbox = PMA_ajaxShowMessage();
+ /* Allows the user to edit a server variable */
+ function editVariable(link) {
+ var $cell = $(link).parent();
+ var varName = $cell.parent().find('.var-name').text().replace(/ /g,'_');
+ var $mySaveLink = $saveLink.clone().show();
+ var $myCancelLink = $cancelLink.clone().show();
+ var $msgbox = PMA_ajaxShowMessage();
- $cell.addClass('edit');
- // remove edit link
- $cell.find('a.editLink').remove();
+ $cell
+ .addClass('edit') // variable is being edited
+ .find('a.editLink')
+ .remove(); // remove edit link
- $mySaveLink.click(function() {
- var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
- $.get($(this).attr('href'), {
- ajax_request: true,
- type: 'setval',
- varName: varName,
- varValue: $cell.find('input').val()
- }, function(data) {
- if (data.success) {
- $cell.html(data.variable);
- PMA_ajaxRemoveMessage($msgbox);
- } else {
- PMA_ajaxShowMessage(data.error, false);
- $cell.html($cell.find('span.oldContent').html());
- }
- $cell.removeClass('edit');
- }, 'json');
-
- return false;
- });
-
- $myCancelLink.click(function() {
- $cell.html($cell.find('span.oldContent').html());
- $cell.removeClass('edit');
- return false;
- });
-
- $.get($mySaveLink.attr('href'), {
- ajax_request: true,
- type: 'getval',
- varName: varName
- }, function(data) {
- if (data.success == true) {
- // hide original content
- $cell.html('' + $cell.html() + '');
- // put edit field and save/cancel link
- $cell.prepend('