From 9b40496c0b5f77dbc8daf673a7f2ec4e28bc3cc8 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Thu, 5 Dec 2013 07:08:17 +0530 Subject: [PATCH] Force scroll to top for databases --- js/navigation.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/js/navigation.js b/js/navigation.js index d7c3819895..bb46edddf8 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -294,14 +294,15 @@ function expandTreeNode($expandElem, callback) * Auto-scrolls the newly chosen database * * @param object $element The element to set to view + * @param boolean $forceToTop Whether to force scroll to top * */ -function scrollToView($element) { +function scrollToView($element, $forceToTop) { var $container = $('#pma_navigation_tree_content'); var elemTop = $element.offset().top - $container.offset().top; var textHeight = 20; var scrollPadding = 20; // extra padding from top of bottom when scrolling to view - if (elemTop < 0) { + if (elemTop < 0 || $forceToTop) { $container.stop().animate({ scrollTop: elemTop + $container.scrollTop() - scrollPadding }); @@ -408,10 +409,10 @@ function PMA_showCurrentNavigation() if ($tableContainer.length > 0) { var $expander = $tableContainer.children('div:first').children('a.expander'); expandTreeNode($expander, function () { - scrollToView($dbItem); + scrollToView($dbItem, true); }); } else { - scrollToView($dbItem); + scrollToView($dbItem, true); } } } @@ -482,7 +483,7 @@ function PMA_showCurrentNavigation() // no containers, highlight the item var $tableOrView = findLoadedItem($container, table, null, true); if ($tableOrView){ - scrollToView($tableOrView); + scrollToView($tableOrView, false); } } } @@ -501,7 +502,7 @@ function PMA_showCurrentNavigation() table, 'table', true ); if ($table) { - scrollToView($table); + scrollToView($table, false); } } else if ($viewContainer.length > 0) { highlightView($viewContainer, table); @@ -534,7 +535,7 @@ function PMA_showCurrentNavigation() view, 'view', true ); if ($view) { - scrollToView($view); + scrollToView($view, false); } }); } else { @@ -543,7 +544,7 @@ function PMA_showCurrentNavigation() view, 'view', true ); if ($view) { - scrollToView($view); + scrollToView($view, false); } } }