diff --git a/ChangeLog b/ChangeLog index a51a1f3eab..b0180d6a6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -48,6 +48,7 @@ phpMyAdmin - ChangeLog - bug #4064 Table structure statistics "Space usage" caption too small for l10n - bug #4051 Wrong tabindex when inserting rows - bug #4066 varchar field not truncated in table browse mode ++ rfe #1435 Opening database should expand it in the navigation menu 4.0.5.0 (2013-08-04) - bug #3977 Not detected configuration storage diff --git a/browse_foreigners.php b/browse_foreigners.php index ee35f79e8e..946c1ce2f2 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -13,8 +13,7 @@ require_once 'libraries/transformations.lib.php'; * Sets globals from $_REQUEST */ $request_params = array( - 'field', - 'fieldkey' + 'field' ); foreach ($request_params as $one_request_param) { @@ -117,8 +116,10 @@ $error = PMA_jsFormat( ); -if (! isset($fieldkey) || ! is_numeric($fieldkey)) { +if (! isset($_REQUEST['fieldkey']) || ! is_numeric($_REQUEST['fieldkey'])) { $fieldkey = 0; +} else { + $fieldkey = $_REQUEST['fieldkey']; } $code = << li').length == 1) { - $destination.find('ul > li') - .find('a.expander.container') - .click(); - } - } else { - PMA_ajaxShowMessage(data.error, false); - } - $icon.show(); - $throbber.remove(); - }); - } - $(this).blur(); + PMA_expandNavigationTree($(this)); }); - + /** * Register event handler for click on the reload * navigation icon at the top of the panel @@ -280,6 +225,115 @@ $(function () { }); }); +/** + * Expands/collapses the navigation tree and sets to view the expanded + * + * @param object $expandElem the element that initiated the expanding + * @return void + */ +function PMA_expandNavigationTree($expandElem) { + var $children = $expandElem.closest('li').children('div.list_container'); + var $icon = $expandElem.find('img'); + if ($expandElem.hasClass('loaded')) { + if ($icon.is('.ic_b_plus')) { + $icon.removeClass('ic_b_plus').addClass('ic_b_minus'); + $children.show('fast'); + } else { + $icon.removeClass('ic_b_minus').addClass('ic_b_plus'); + $children.hide('fast'); + } + } else { + var $destination = $expandElem.closest('li'); + var $throbber = $('#pma_navigation .throbber') + .first() + .clone() + .css('visibility', 'visible'); + $icon.hide(); + $throbber.insertBefore($icon); + + var searchClause = PMA_fastFilter.getSearchClause(); + var searchClause2 = PMA_fastFilter.getSearchClause2($expandElem); + + var params = { + aPath: $expandElem.find('span.aPath').text(), + vPath: $expandElem.find('span.vPath').text(), + pos: $expandElem.find('span.pos').text(), + pos2_name: $expandElem.find('span.pos2_name').text(), + pos2_value: $expandElem.find('span.pos2_value').text(), + searchClause: searchClause, + searchClause2: searchClause2 + }; + var url = $('#pma_navigation').find('a.navigation_url').attr('href'); + $.get(url, params, function (data) { + if (data.success === true) { + $expandElem.addClass('loaded'); + $destination.find('div.list_container').remove(); // FIXME: Hack, there shouldn't be a list container there + $destination.append(data.message); + $icon.removeClass('ic_b_plus').addClass('ic_b_minus'); + $destination + .children('div.list_container') + .show('fast'); + if ($destination.find('ul > li').length == 1) { + $destination.find('ul > li') + .find('a.expander.container') + .click(); + } + } else { + PMA_ajaxShowMessage(data.error, false); + } + $icon.show(); + $throbber.remove(); + }); + } + $expandElem.blur(); +} + +/* + * Auto-scrolls the newly chosen database + * + * @param object $element The element to set to view + * @param object $container The container srollable element + * + */ +function scrollToView($element, $container) { + var pushToOffset = $element.offset().top - $container.offset().top + $container.scrollTop(); + $('#pma_navigation_tree_content').stop().animate({ + scrollTop: pushToOffset + }); +} + +/* + * Auto-expands the newly chosen database + * + * @param string $oldDb The previous database + * @param string $newDb The newly chosen database + * + */ +function PMA_autoExpandDatabaseInUse($oldDb, $newDb) { + var $expandElem, $icon; + //Collapse the previous database + if($oldDb !== '' && $oldDb !== $newDb) { + $expandElem = $('#pma_navigation_tree a.dbLink:contains("' + $oldDb + '")') + .parent().find('a.expander').eq(0); + $icon = $expandElem.find('img'); + if ($icon.is('.ic_b_minus')) + PMA_expandNavigationTree($expandElem); + } + //expand the newly chosen database + $expandElem = $('#pma_navigation_tree a.dbLink:contains("' + $newDb + '")') + .parent().find('a.expander').eq(0); + $icon = $expandElem.find('img'); + if ($icon.is('.ic_b_plus')) { + PMA_expandNavigationTree($expandElem); + } + //scroll to new database + if ($oldDb !== $newDb) { + setTimeout(function() { + scrollToView($expandElem.closest('li'), $('#pma_navigation_tree_content')); + }, 150); + } +} + /** * Reloads the whole navigation tree while preserving its state * @@ -289,7 +343,10 @@ $(function () { function PMA_reloadNavigation(callback) { var $throbber = $('#pma_navigation .throbber') .first() - .css('visibility', 'visible'); + .css({ + 'visibility' : 'visible', + 'display' : 'block' + }); var params = { reload: true, pos: $('#pma_navigation_tree').find('a.expander:first > span.pos').text() @@ -332,7 +389,10 @@ function PMA_reloadNavigation(callback) { }); var url = $('#pma_navigation').find('a.navigation_url').attr('href'); $.post(url, params, function (data) { - $throbber.css('visibility', 'hidden'); + $throbber.css('visibility', 'hidden').css({ + 'visibility' : 'hidden', + 'display' : 'none' + }); if (data.success) { $('#pma_navigation_tree').html(data.message).children('div').show(); // Fire the callback, if any diff --git a/js/sql.js b/js/sql.js index f9df4db2b6..e6fbce7244 100644 --- a/js/sql.js +++ b/js/sql.js @@ -296,6 +296,7 @@ AJAX.registerOnload('sql.js', function () { } else if (typeof data.reload != 'undefined') { // this happens if a USE or DROP command was typed PMA_commonActions.setDb(data.db); + PMA_reloadNavigation(); PMA_commonActions.refreshMain(false, function () { if ($('#result_query').length) { $('#result_query').remove(); @@ -307,7 +308,6 @@ AJAX.registerOnload('sql.js', function () { PMA_highlightSQL($('#page_content')); } }); - PMA_reloadNavigation(); } $sqlqueryresults.show().trigger('makegrid'); diff --git a/libraries/navigation/NavigationTree.class.php b/libraries/navigation/NavigationTree.class.php index 36c85e047d..455c11eb47 100644 --- a/libraries/navigation/NavigationTree.class.php +++ b/libraries/navigation/NavigationTree.class.php @@ -635,7 +635,7 @@ class PMA_NavigationTree $retval = $this->_fastFilterHtml($this->_tree); $retval .= $this->_getPageSelector($this->_tree); $this->groupTree(); - $retval .= "