From 82bcf5f7947938b479166fb97c6af3ca52759bcf Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Thu, 8 Nov 2012 12:48:04 +0000 Subject: [PATCH 01/11] Moved documentation links to first column in server_variables.php --- server_variables.php | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/server_variables.php b/server_variables.php index 048b50e3be..58977cd2bc 100644 --- a/server_variables.php +++ b/server_variables.php @@ -157,7 +157,6 @@ $output .= '' . '' - . '' . '' . '' . ''; @@ -170,34 +169,30 @@ foreach ($serverVars as $name => $value) { . ($has_session_value ? 'diffSession' : ''); $output .= '' - . '' + . '' . '' - . ''; + . ''; if ($has_session_value) { - $output .= '' - . '' + $output .= '' . '' . '' - . ''; + . ''; } - $output .= ''; $odd_row = ! $odd_row; } $output .= '' From 202a71e4b4b97e9aeb8d298015628380a6aae8aa Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Thu, 8 Nov 2012 12:55:26 +0000 Subject: [PATCH 02/11] Dropped broken table width limiting function --- js/server_variables.js | 58 ++---------------------------------------- 1 file changed, 2 insertions(+), 56 deletions(-) diff --git a/js/server_variables.js b/js/server_variables.js index 05955b349d..c4b20921bc 100644 --- a/js/server_variables.js +++ b/js/server_variables.js @@ -10,8 +10,6 @@ AJAX.registerTeardown('server_variables.js', function() { AJAX.registerOnload('server_variables.js', function() { var textFilter = null, odd_row = false; - var testString = 'abcdefghijklmnopqrstuvwxyz0123456789,ABCEFGHIJKLMOPQRSTUVWXYZ'; - var $tmpDiv, charWidth; // Global vars $editLink = $('a.editLink'); @@ -40,66 +38,14 @@ AJAX.registerOnload('server_variables.js', function() { filterVariables(); }); + /* FIXME: this seems broken as we now use the hash for the microhistory 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'); } - } - - /* 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 = $('
' . __('Session value') . ' / ' . __('Global value') . '' . __('Documentation') . '
' . htmlspecialchars(str_replace('_', ' ', $name)) - . '' . htmlspecialchars(str_replace('_', ' ', $name)); + + // To display variable documentation link + if (isset($VARIABLE_DOC_LINKS[$name])) { + $output .= PMA_Util::showMySQLDocu( + $VARIABLE_DOC_LINKS[$name][1], + $VARIABLE_DOC_LINKS[$name][1], + false, + $VARIABLE_DOC_LINKS[$name][2] . '_' . $VARIABLE_DOC_LINKS[$name][0] + ); + } + + $output .= '' . formatVariable($name, $value) - . ''; - - // To display variable documentation link - if (isset($VARIABLE_DOC_LINKS[$name])) { - $output .= PMA_Util::showMySQLDocu( - $VARIABLE_DOC_LINKS[$name][1], - $VARIABLE_DOC_LINKS[$name][1], - false, - $VARIABLE_DOC_LINKS[$name][2] . '_' . $VARIABLE_DOC_LINKS[$name][0] - ); - } - - $output .= '
(' . __('Session value') . ')' . formatVariable($name, $serverVarsSession[$name]) . '
' + 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) + '...'); - } - } - }); - } - } + }*/ /* Filters the rows by the user given regexp */ function filterVariables() { From fc9becacb6915ca4a69314efeabc5977d9a53998 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Thu, 8 Nov 2012 21:48:29 +0000 Subject: [PATCH 03/11] Improved layout for server variables page --- js/server_variables.js | 49 ++++++++++--------- server_variables.php | 73 +++++++++++++++------------- themes/original/css/common.css.php | 77 +++++++++++++++++++++--------- themes/pmahomme/css/common.css.php | 66 +++++++++++++++++++------ 4 files changed, 174 insertions(+), 91 deletions(-) diff --git a/js/server_variables.js b/js/server_variables.js index c4b20921bc..f6fcc989bc 100644 --- a/js/server_variables.js +++ b/js/server_variables.js @@ -4,7 +4,7 @@ * 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 .variable_row').unbind('hover'); $('#filterText').unbind('keyup'); }); @@ -17,11 +17,12 @@ AJAX.registerOnload('server_variables.js', function() { $cancelLink = $('a.cancelLink'); /* Variable editing */ - $('table.data tbody tr td:nth-child(2).editable').hover( + $('#serverVariables .variable_row').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()); + var $elm = $(this).find('.variable_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() { @@ -49,14 +50,12 @@ AJAX.registerOnload('server_variables.js', function() { /* Filters the rows by the user given regexp */ function filterVariables() { - var mark_next = false, firstCell; - odd_row = false; - - $('table.filteredData tbody tr').each(function() { + var mark_next = false, firstCell, odd_row = false; + $('#serverVariables .variable_row').not('.variable_header').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 + // If current global value is different from session value + // (has class diffSession), then display that one too mark_next = $(this).hasClass('diffSession') && ! mark_next; odd_row = ! odd_row; @@ -78,7 +77,7 @@ AJAX.registerOnload('server_variables.js', function() { /* 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 varName = $(link).closest('.variable_row').find('.variable_name').text().replace(/ /g,'_'); var $mySaveLink = $saveLink.clone().show(); var $myCancelLink = $cancelLink.clone().show(); var $cell = $(link).parent(); @@ -98,10 +97,11 @@ function editVariable(link) }, function(data) { if (data.success) { $cell.html(data.variable); + $cell.data('content', data.variable); PMA_ajaxRemoveMessage($msgbox); } else { PMA_ajaxShowMessage(data.error, false); - $cell.html($cell.find('span.oldContent').html()); + $cell.html($cell.data('content')); } $cell.removeClass('edit'); }, 'json'); @@ -110,7 +110,7 @@ function editVariable(link) }); $myCancelLink.click(function() { - $cell.html($cell.find('span.oldContent').html()); + $cell.html($cell.data('content')); $cell.removeClass('edit'); return false; }); @@ -121,18 +121,21 @@ function editVariable(link) varName: varName }, function(data) { if (data.success == true) { - // hide original content - $cell.html(''); + $cell.data('content', $cell.html()).html(''); + // put edit field and save/cancel link - $cell.prepend('
' + - '
'); - $cell.find('table td:first').append($mySaveLink); - $cell.find('table td:first').append(' '); - $cell.find('table td:first').append($myCancelLink); + $cell.prepend( + '' + + '' + + '' + + '
' + ); + $cell.find('table td:last').append($mySaveLink); + $cell.find('table td:last').append(' '); + $cell.find('table td:last').append($myCancelLink); // Keyboard shortcuts to the rescue - $('input#variableEditArea').focus(); - $('input#variableEditArea').keydown(function(event) { + $cell.find('input').focus().keydown(function(event) { // Enter key if (event.keyCode == 13) { $mySaveLink.trigger('click'); diff --git a/server_variables.php b/server_variables.php index 58977cd2bc..0777ddcf0d 100644 --- a/server_variables.php +++ b/server_variables.php @@ -123,7 +123,7 @@ $output = '

' . PMA_Util::getImage('s_vars.png') /** * Link templates */ -$url = htmlspecialchars('server_variables.php?' . PMA_generate_common_url($db)); +$url = htmlspecialchars('server_variables.php?' . PMA_generate_common_url()); $output .= ''; $output .= '

'; From 4acb613eea5e4bf530ece0a0c295cfe69f7661e3 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Fri, 9 Nov 2012 12:09:06 +0000 Subject: [PATCH 08/11] Clean-up and speed-up JS on server variables page --- js/server_variables.js | 82 +++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/js/server_variables.js b/js/server_variables.js index 689a8b4fcc..5108426d77 100644 --- a/js/server_variables.js +++ b/js/server_variables.js @@ -10,13 +10,11 @@ AJAX.registerTeardown('server_variables.js', function() { }); AJAX.registerOnload('server_variables.js', function() { - var textFilter = null; - var odd_row = false; var $editLink = $('a.editLink'); var $saveLink = $('a.saveLink'); var $cancelLink = $('a.cancelLink'); - /* Variable editing */ + /* Show edit link on hover */ $('#serverVariables').delegate('.var-row', 'hover', function(event) { if (event.type === 'mouseenter') { var $elm = $(this).find('.var-value'); @@ -29,18 +27,19 @@ AJAX.registerOnload('server_variables.js', function() { } }); - $('#filterText').keyup(function(e) { - if ($(this).val().length == 0) { - textFilter=null; - } else { - textFilter = new RegExp("(^| )"+$(this).val().replace(/_/g,' '),'i'); + /* 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(); + filterVariables(textFilter); }); + /* Launches the variable editor */ $('a.editLink').live('click', function (event) { event.preventDefault(); - editVariable.call(this); + editVariable(this); }); /* FIXME: this seems broken as we now use the hash for the microhistory @@ -53,41 +52,43 @@ AJAX.registerOnload('server_variables.js', function() { }*/ /* Filters the rows by the user given regexp */ - function filterVariables() { - var mark_next = false, firstCell, odd_row = false; + function filterVariables(textFilter) { + var mark_next = false, $row, odd_row = false; $('#serverVariables .var-row').not('.var-header').each(function() { - firstCell = $(this).children(':first'); - if (mark_next || textFilter == null || textFilter.exec(firstCell.text())) { + $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 = $(this).hasClass('diffSession') && ! mark_next; + 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'); } }); } /* Allows the user to edit a server variable */ - function editVariable() { - var $cell = $(this).parent(); + 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); @@ -98,8 +99,9 @@ AJAX.registerOnload('server_variables.js', function() { varValue: $cell.find('input').val() }, function(data) { if (data.success) { - $cell.html(data.variable); - $cell.data('content', data.variable); + $cell + .html(data.variable) + .data('content', data.variable); PMA_ajaxRemoveMessage($msgbox); } else { PMA_ajaxShowMessage(data.error, false); @@ -107,13 +109,13 @@ AJAX.registerOnload('server_variables.js', function() { } $cell.removeClass('edit'); }); - return false; }); $myCancelLink.click(function() { - $cell.html($cell.data('content')); - $cell.removeClass('edit'); + $cell + .html($cell.data('content')) + .removeClass('edit'); return false; }); @@ -122,7 +124,7 @@ AJAX.registerOnload('server_variables.js', function() { type: 'getval', varName: varName }, function(data) { - if (data.success == true) { + if (data.success === true) { var $editor = $('
', {'class':'serverVariableEditor'}) .append($myCancelLink) .append(' ') @@ -134,15 +136,15 @@ AJAX.registerOnload('server_variables.js', function() { ) ); // Save and replace content - $cell.data('content', $cell.html()).html($editor); - // Keyboard shortcuts to the rescue - $cell.find('input').focus().keydown(function(event) { - // Enter key - if (event.keyCode == 13) { + $cell + .data('content', $cell.html()) + .html($editor) + .find('input') + .focus() + .keydown(function(event) { // Keyboard shortcuts + if (event.keyCode === 13) { // Enter key $mySaveLink.trigger('click'); - } - // Escape key - if (event.keyCode == 27) { + } else if (event.keyCode === 27) { // Escape key $myCancelLink.trigger('click'); } }); From 14a7be6e3784c4f5ceaa8328cc0ef67f1a9f6abd Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Fri, 9 Nov 2012 13:20:00 +0000 Subject: [PATCH 09/11] Fixed direct linking to server variable name --- js/server_variables.js | 24 ++++++++++-------------- libraries/Advisor.class.php | 2 +- server_variables.php | 3 ++- test/classes/PMA_Advisor_test.php | 2 +- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/js/server_variables.js b/js/server_variables.js index 5108426d77..474cbd0eb3 100644 --- a/js/server_variables.js +++ b/js/server_variables.js @@ -27,6 +27,12 @@ AJAX.registerOnload('server_variables.js', function() { } }); + /* 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(); @@ -36,20 +42,10 @@ AJAX.registerOnload('server_variables.js', function() { filterVariables(textFilter); }); - /* Launches the variable editor */ - $('a.editLink').live('click', function (event) { - event.preventDefault(); - editVariable(this); - }); - - /* FIXME: this seems broken as we now use the hash for the microhistory - 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'); - } - }*/ + /* 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(textFilter) { diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php index b8764a5c6c..98e090e515 100644 --- a/libraries/Advisor.class.php +++ b/libraries/Advisor.class.php @@ -239,7 +239,7 @@ class Advisor // linking to server_variables.php $rule['recommendation'] = preg_replace( '/\{([a-z_0-9]+)\}/Ui', - '\1', + '\1', $this->translate($rule['recommendation']) ); diff --git a/server_variables.php b/server_variables.php index 89985bafc4..e16d304219 100644 --- a/server_variables.php +++ b/server_variables.php @@ -142,12 +142,13 @@ $serverVars = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES;', 0, 1); /** * Displays the page */ +$value = ! empty($_REQUEST['filter']) ? htmlspecialchars($_REQUEST['filter']) : ''; $output .= '
' . '' . __('Filters') . '' . '
' . '' . '' + . ' style="vertical-align: baseline;" value="' . $value . '" />' . '
' . '
'; diff --git a/test/classes/PMA_Advisor_test.php b/test/classes/PMA_Advisor_test.php index e75dca8d2d..c3c44186e6 100644 --- a/test/classes/PMA_Advisor_test.php +++ b/test/classes/PMA_Advisor_test.php @@ -116,7 +116,7 @@ class Advisor_test extends PHPUnit_Framework_TestCase 'id' => 'Variable', 'name' => 'Variable', 'issue' => 'issue', - 'recommendation' => 'Recommend status_var' + 'recommendation' => 'Recommend status_var' ), null, ), From 06f616a9edaf4100e8330ba46d0090111f1ead77 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Fri, 9 Nov 2012 13:37:22 +0000 Subject: [PATCH 10/11] l10n fixes --- themes/original/css/common.css.php | 4 ++-- themes/pmahomme/css/common.css.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/themes/original/css/common.css.php b/themes/original/css/common.css.php index 2f1656f046..7fcf9ec9ee 100644 --- a/themes/original/css/common.css.php +++ b/themes/original/css/common.css.php @@ -1219,10 +1219,10 @@ div#logTable table { #serverVariables .serverVariableEditor div { display: block; overflow: hidden; - padding-right: 1em; + padding-: 1em; } #serverVariables .serverVariableEditor a { - float: right; + float: ; margin: 0 0.5em; line-height: 2em; } diff --git a/themes/pmahomme/css/common.css.php b/themes/pmahomme/css/common.css.php index d0f2ba098b..52680d3a35 100644 --- a/themes/pmahomme/css/common.css.php +++ b/themes/pmahomme/css/common.css.php @@ -1491,10 +1491,10 @@ div#queryAnalyzerDialog table.queryNums { #serverVariables .serverVariableEditor div { display: block; overflow: hidden; - padding-right: 1em; + padding-: 1em; } #serverVariables .serverVariableEditor a { - float: right; + float: ; margin: 0 0.5em; line-height: 2em; } From bf02d6e06929960b6f2a5843843fe75b140953a3 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Fri, 9 Nov 2012 13:44:29 +0000 Subject: [PATCH 11/11] Updated changelog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) 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)