Force scroll to top for databases

This commit is contained in:
Madhura Jayaratne 2013-12-05 07:08:17 +05:30
parent a21a18cf56
commit 9b40496c0b

View File

@ -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);
}
}
}