Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-01-09 14:12:55 +01:00
commit 6039d15b60
4 changed files with 101 additions and 115 deletions

View File

@ -463,95 +463,79 @@ function PMA_showCurrentNavigation() {
return ret;
}
function loadAndHighlightTableOrView($dbItem, table) {
function loadAndHighlightTableOrView($dbItem, itemName) {
var $container = $dbItem.children('div.list_container');
var $tableContainer = $container
.children('ul')
.children('li.tableContainer');
var $viewContainer = $container
.children('ul')
.children('li.viewContainer');
if ($tableContainer.length > 0) {
var $expander = $tableContainer
.children('div:first')
.children('a.expander');
if (! $expander.hasClass('loaded')) {
loadChildNodes($expander, function (data) {
highlightTableOrView($tableContainer, $viewContainer, table);
});
} else {
highlightTableOrView($tableContainer, $viewContainer, table);
}
} else if ($viewContainer.length > 0) {
highlightView($viewContainer, table);
} else {
// no containers, highlight the item
var $tableOrView = findLoadedItem($container, table, null, true);
if ($tableOrView){
scrollToView($tableOrView, false);
}
}
}
function highlightTableOrView($tableContainer, $viewContainer, table) {
if (isItemInContainer($tableContainer, table, 'table')) {
var $expander = $tableContainer
.children('div:first')
.children('a.expander');
if ($expander.find('img').is('.ic_b_plus')) {
expandTreeNode($expander);
}
var $table = findLoadedItem(
$tableContainer.children('div.list_container'),
table, 'table', true
var $expander;
var $whichItem = isItemInContainer($container, itemName, 'li.table, li.view');
//If item already there in some container
if ($whichItem) {
//get the relevant container while may also be a subcontainer
var $relatedContainer = $whichItem.closest('li.subContainer').length
? $whichItem.closest('li.subContainer')
: $dbItem;
$whichItem = findLoadedItem(
$relatedContainer.children('div.list_container'),
itemName, null, true
);
if ($table) {
scrollToView($table, false);
//Show directly
showTableOrView($whichItem, $relatedContainer.children('div:first').children('a.expander'));
//else if item not there, try loading once
} else {
var $sub_containers = $dbItem.find('.subContainer');
//If there are subContainers i.e. tableContainer or viewContainer
if($sub_containers.length > 0) {
var $containers = new Array();
$sub_containers.each(function (index) {
$containers[index] = $(this);
$expander = $containers[index]
.children('div:first')
.children('a.expander');
collapseTreeNode($expander);
loadAndShowTableOrView($expander, $containers[index], itemName);
});
// else if no subContainers
} else {
$expander = $dbItem
.children('div:first')
.children('a.expander');
collapseTreeNode($expander);
loadAndShowTableOrView($expander, $dbItem, itemName);
}
} else if ($viewContainer.length > 0) {
highlightView($viewContainer, table);
}
}
function isItemInContainer($container, name, clazz) {
$items = $container.find('li.' + clazz);
function loadAndShowTableOrView($expander, $relatedContainer, itemName) {
loadChildNodes($expander, function (data) {
var $whichItem = findLoadedItem(
$relatedContainer.children('div.list_container'),
itemName, null, true
);
if ($whichItem) {
showTableOrView($whichItem, $expander);
}
});
}
function showTableOrView($whichItem, $expander) {
expandTreeNode($expander, function (data) {
if ($whichItem) {
scrollToView($whichItem, false);
}
});
}
function isItemInContainer($container, name, clazz)
{
var $whichItem = null;
$items = $container.find(clazz);
var found = false;
$items.each(function () {
if ($(this).children('a').text() == name) {
found = true;
$whichItem = $(this);
return false;
}
});
return found;
}
function highlightView($viewContainer, view) {
var $expander = $viewContainer
.children('div:first')
.children('a.expander');
if (! $expander.hasClass('loaded') ||
$expander.find('img').is('.ic_b_plus')
) {
expandTreeNode($expander, function () {
var $view = findLoadedItem(
$viewContainer.children('div.list_container'),
view, 'view', true
);
if ($view) {
scrollToView($view, false);
}
});
} else {
var $view = findLoadedItem(
$viewContainer.children('div.list_container'),
view, 'view', true
);
if ($view) {
scrollToView($view, false);
}
}
return $whichItem;
}
}

View File

@ -112,49 +112,21 @@ function PMA_getHtmlForRelationalFieldSelection($db, $table, $field, $foreignDat
// keynames and descriptions for the left section,
// sorted by keynames
$leftKeyname = $keys[$indexByKeyname];
$leftDescription = $descriptions[$indexByKeyname];
list(
$leftDescription,
$leftDescriptionTitle
) = PMA_getDescriptionAndTitle($descriptions[$indexByKeyname]);
// keynames and descriptions for the right section,
// sorted by descriptions
$rightKeyname = $keys[$indexByDescription];
$rightDescription = $descriptions[$indexByDescription];
list(
$rightDescription,
$rightDescriptionTitle
) = PMA_getDescriptionAndTitle($descriptions[$indexByDescription]);
$indexByDescription++;
$pmaString = $GLOBALS['PMA_String'];
$limitChars = $GLOBALS['cfg']['LimitChars'];
if ($pmaString->strlen($rightDescription) <= $limitChars) {
$rightDescription = htmlspecialchars(
$rightDescription
);
$rightDescriptionTitle = '';
} else {
$rightDescriptionTitle = htmlspecialchars(
$rightDescription
);
$rightDescription = htmlspecialchars(
$pmaString->substr(
$rightDescription, 0, $limitChars
)
. '...'
);
}
if ($pmaString->strlen($leftDescription) <= $limitChars) {
$leftDescription = htmlspecialchars(
$leftDescription
);
$leftDescriptionTitle = '';
} else {
$leftDescriptionTitle = htmlspecialchars(
$leftDescription
);
$leftDescription = htmlspecialchars(
$pmaString->substr(
$leftDescription, 0, $limitChars
) . '...'
);
}
if (! empty($data)) {
$rightKeynameIsSelected = $rightKeyname == $data;
$leftKeynameIsSelected = $leftKeyname == $data;
@ -196,6 +168,36 @@ function PMA_getHtmlForRelationalFieldSelection($db, $table, $field, $foreignDat
return $output;
}
/**
* Get the description (possibly truncated) and the title
*
* @param string $description the keyname's description
*
* @return array the new description and title
*/
function PMA_getDescriptionAndTitle($description)
{
$pmaString = $GLOBALS['PMA_String'];
$limitChars = $GLOBALS['cfg']['LimitChars'];
if ($pmaString->strlen($description) <= $limitChars) {
$description = htmlspecialchars(
$description
);
$descriptionTitle = '';
} else {
$descriptionTitle = htmlspecialchars(
$description
);
$description = htmlspecialchars(
$pmaString->substr(
$description, 0, $limitChars
)
. '...'
);
}
return array($description, $descriptionTitle);
}
/**
* Function to get html for each column element
*

View File

@ -40,7 +40,7 @@ class Node_Table_Container extends Node
);
}
$this->real_name = 'tables';
$this->classes = 'tableContainer';
$this->classes = 'tableContainer subContainer';
$new_label = _pgettext('Create new table', 'New');
$new = PMA_NodeFactory::getInstance('Node', $new_label);

View File

@ -39,7 +39,7 @@ class Node_View_Container extends Node
$GLOBALS['cfg']['NavigationTreeTableLevel']
);
}
$this->classes = 'viewContainer';
$this->classes = 'viewContainer subContainer';
$this->real_name = 'views';
$new_label = _pgettext('Create new view', 'New');