Merge branch 'master' of https://github.com/phpmyadmin/phpmyadmin into UT_tbl

This commit is contained in:
adamgsoc2013 2013-08-27 00:14:52 +08:00
commit 761f11e98a
8 changed files with 159 additions and 68 deletions

View File

@ -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

View File

@ -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 = <<<EOC

View File

@ -41,6 +41,10 @@ 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] !== '') {
PMA_autoExpandDatabaseInUse(params['db'], obj[i]);
}
params[i] = obj[i];
}
if (reload) {
@ -71,6 +75,9 @@ var PMA_commonParams = (function () {
PMA_querywindow.refresh();
PMA_reloadNavigation();
}
if(name == 'db' && value !== '') {
PMA_autoExpandDatabaseInUse(params['db'], value);
}
params[name] = value;
return this;
},
@ -108,6 +115,9 @@ var PMA_commonActions = {
*/
setDb: function (new_db) {
if (new_db != PMA_commonParams.get('db')) {
if(new_db !== '') {
PMA_autoExpandDatabaseInUse(PMA_commonParams.get('db'), new_db);
}
PMA_commonParams.set('db', new_db);
PMA_querywindow.refresh();
}

View File

@ -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,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

View File

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

View File

@ -635,7 +635,7 @@ class PMA_NavigationTree
$retval = $this->_fastFilterHtml($this->_tree);
$retval .= $this->_getPageSelector($this->_tree);
$this->groupTree();
$retval .= "<div><ul>";
$retval .= "<div id='pma_navigation_tree_content'><ul>";
$children = $this->_tree->children;
usort($children, array('PMA_NavigationTree', 'sortNode'));
$this->_setVisibility();
@ -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>";
}

View File

@ -21,7 +21,6 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) {
color: <?php echo $GLOBALS['cfg']['NaviColor']; ?>;
width: <?php echo $GLOBALS['cfg']['NaviWidth']; ?>px;
overflow: hidden;
overflow-y: auto;
position: fixed;
top: 0;
<?php echo $left; ?>: 0;
@ -32,6 +31,7 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) {
#pma_navigation_content {
width: 100%;
height: 100%;
position: absolute;
top: 0;
<?php echo $left; ?>: 0;
@ -108,6 +108,15 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) {
margin: 0.5em 0 0;
margin-<?php echo $left; ?>: 1em;
color: #444;
height: 74%;
position: relative;
}
#pma_navigation_tree_content {
width: 100%;
overflow: hidden;
overflow-y: auto;
position: absolute;
height: 100%;
}
#pma_navigation_tree a {
color: <?php echo $GLOBALS['cfg']['NaviColor']; ?>;

View File

@ -19,7 +19,6 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) {
#pma_navigation {
width: <?php echo $GLOBALS['cfg']['NaviWidth']; ?>px;
overflow: hidden;
overflow-y: auto;
position: fixed;
top: 0;
<?php echo $left; ?>: 0;
@ -31,6 +30,7 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) {
#pma_navigation_content {
width: 100%;
height: 100%;
position: absolute;
top: 0;
<?php echo $left; ?>: 0;
@ -84,7 +84,7 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) {
}
#pma_navigation_content > img.throbber {
display: block;
display: none;
margin: .3em auto 0;
}
@ -93,6 +93,15 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) {
margin: 5px 0 0;
margin-<?php echo $left; ?>: 10px;
color: #444;
height: 74%; /*it needs to be dynamically set*/
position: relative;
}
#pma_navigation_tree_content {
width: 100%;
overflow: hidden;
overflow-y: auto;
position: absolute;
height: 100%;
}
#pma_navigation_tree a {
color: <?php echo $GLOBALS['cfg']['NaviColor']; ?>;