diff --git a/js/common.js b/js/common.js
index 271b77ca9f..b18229d8f4 100644
--- a/js/common.js
+++ b/js/common.js
@@ -41,6 +41,22 @@ var PMA_commonParams = (function () {
if (params[i] !== undefined && params[i] !== obj[i]) {
reload = true;
}
+ // To expand the database in use and collapse the previous one
+ if(i == 'db' && obj[i] !== '') {
+ var $expandElem, $icon;
+ if(params['db'] !== '' && params['db'] !== obj[i]) {
+ $expandElem = $('#pma_navigation_tree a.dbLink:contains("' + params['db'] + '")')
+ .parent().find('a.expander').eq(0);
+ $icon = $expandElem.find('img');
+ if ($icon.is('.ic_b_minus'))
+ PMA_expandNavigationTree($expandElem);
+ }
+ $expandElem = $('#pma_navigation_tree a.dbLink:contains("' + obj[i] + '")')
+ .parent().find('a.expander').eq(0);
+ $icon = $expandElem.find('img');
+ if ($icon.is('.ic_b_plus'))
+ PMA_expandNavigationTree($expandElem);
+ }
params[i] = obj[i];
}
if (reload) {
diff --git a/js/navigation.js b/js/navigation.js
index 260128de6a..998d9c85eb 100644
--- a/js/navigation.js
+++ b/js/navigation.js
@@ -29,64 +29,9 @@ $(function () {
$('#pma_navigation_tree a.expander').live('click', function (event) {
event.preventDefault();
event.stopImmediatePropagation();
- var $this = $(this);
- var $children = $this.closest('li').children('div.list_container');
- var $icon = $this.find('img');
- if ($this.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 = $this.closest('li');
- var $throbber = $('#pma_navigation .throbber')
- .first()
- .clone()
- .css('visibility', 'visible')
- .click(false);
- $icon.hide();
- $throbber.insertBefore($icon);
-
- var searchClause = PMA_fastFilter.getSearchClause();
- var searchClause2 = PMA_fastFilter.getSearchClause2($(this));
-
- var params = {
- aPath: $(this).find('span.aPath').text(),
- vPath: $(this).find('span.vPath').text(),
- pos: $(this).find('span.pos').text(),
- pos2_name: $(this).find('span.pos2_name').text(),
- pos2_value: $(this).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) {
- $this.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();
- });
- }
- $(this).blur();
+ PMA_expandNavigationTree($(this));
});
-
+
/**
* Register event handler for click on the reload
* navigation icon at the top of the panel
@@ -280,6 +225,69 @@ $(function () {
});
});
+/**
+ * Expands/collapses the navigation tree
+ *
+ * @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();
+}
+
/**
* Reloads the whole navigation tree while preserving its state
*
diff --git a/libraries/navigation/NavigationTree.class.php b/libraries/navigation/NavigationTree.class.php
index 36c85e047d..554f3dadc3 100644
--- a/libraries/navigation/NavigationTree.class.php
+++ b/libraries/navigation/NavigationTree.class.php
@@ -877,6 +877,7 @@ class PMA_NavigationTree
$retval .= "";
}
+ $dblinkclass = ' class="dbLink"';
$linkClass = '';
$haveAjax = array(
'functions',
@@ -931,7 +932,7 @@ class PMA_NavigationTree
} else {
$title = '';
}
- $retval .= "";
+ $retval .= "";
$retval .= htmlspecialchars($node->real_name);
$retval .= "";
}