Auto-expand the selected database, feature 1435
This commit is contained in:
commit
77c4cbed7f
16
js/common.js
16
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) {
|
||||
|
||||
122
js/navigation.js
122
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
|
||||
*
|
||||
|
||||
@ -877,6 +877,7 @@ class PMA_NavigationTree
|
||||
$retval .= "</div>";
|
||||
}
|
||||
|
||||
$dblinkclass = ' class="dbLink"';
|
||||
$linkClass = '';
|
||||
$haveAjax = array(
|
||||
'functions',
|
||||
@ -931,7 +932,7 @@ class PMA_NavigationTree
|
||||
} else {
|
||||
$title = '';
|
||||
}
|
||||
$retval .= "<a$linkClass$title href='$link'>";
|
||||
$retval .= "<a$dblinkclass$linkClass$title href='$link'>";
|
||||
$retval .= htmlspecialchars($node->real_name);
|
||||
$retval .= "</a>";
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user