diff --git a/js/navigation.js b/js/navigation.js index 843a998675..cd65e595d8 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -202,6 +202,37 @@ function clear_fast_filter() fast_filter(''); } +/** + * hide all LI elements with second A tag which doesn`t contain requested value + * + * @param string value requested value + * + */ +function fast_db_filter(value) +{ + var lowercase_value = value.toLowerCase(); + + $('#databaseList li a').each(function(idx, elem) { + var $elem = $(elem); + if (value && $elem.html().toLowerCase().indexOf(lowercase_value) == -1) { + $elem.parent().hide(); + } else { + $elem.parents('li').show(); + } + }); + +} + +/** + * Clears fast database filter. + */ +function clear_fast_db_filter() +{ + var $elm = $('#fast_db_filter'); + $elm.val(''); + fast_db_filter(''); +} + /** * Reloads the recent tables list. */ @@ -251,6 +282,32 @@ $(function(){ } }); + /* Fast database filter */ + var txtDb = $('#fast_db_filter').val(); + + $('#fast_db_filter.gray').live('focus', function() { + $(this).removeClass('gray'); + clear_fast_db_filter(); + }); + + $('#fast_db_filter:not(.gray)').live('focusout', function() { + var $input = $(this); + if ($input.val() == '') { + $input + .addClass('gray') + .val(txtDb); + } + }); + + $('#clear_fast_db_filter').click(function() { + clear_fast_db_filter(); + $('#fast_db_filter').focus(); + }); + + $('#fast_db_filter').keyup(function(evt) { + fast_db_filter($(this).val()); + }); + /* Jump to recent table */ $('#recentTable').change(function() { if (this.value != '') { diff --git a/libraries/config.default.php b/libraries/config.default.php index b68c175ab8..1f7bf196f6 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -883,6 +883,14 @@ $cfg['DisplayServersList'] = false; */ $cfg['DisplayDatabasesList'] = 'auto'; +/** + * display a JavaScript database filter in the left frame + * when more then x databases are present + * + * @global boolean $cfg['LeftDisplayDatabaseFilterMinimum'] + */ +$cfg['LeftDisplayDatabaseFilterMinimum'] = 30; + /** * target of the navigation panel quick access icon * diff --git a/libraries/config/messages.inc.php b/libraries/config/messages.inc.php index 61d1698bea..8f3a7df878 100644 --- a/libraries/config/messages.inc.php +++ b/libraries/config/messages.inc.php @@ -278,6 +278,7 @@ $strConfigLeftDisplayLogo_name = __('Display logo'); $strConfigLeftDisplayServers_desc = __('Display server choice at the top of the left frame'); $strConfigLeftDisplayServers_name = __('Display servers selection'); $strConfigLeftDisplayTableFilterMinimum_name = __('Minimum number of tables to display the table filter box'); +$strConfigLeftDisplayDatabaseFilterMinimum_name = __('Minimum number of databases to display the database filter box'); $strConfigLeftFrameDBSeparator_desc = __('String that separates databases into different tree levels'); $strConfigLeftFrameDBSeparator_name = __('Database tree separator'); $strConfigLeftFrameDBTree_desc = __('Only light version; display databases in a tree (determined by the separator defined below)'); diff --git a/libraries/config/user_preferences.forms.php b/libraries/config/user_preferences.forms.php index 600099cf4b..308a222c73 100644 --- a/libraries/config/user_preferences.forms.php +++ b/libraries/config/user_preferences.forms.php @@ -84,6 +84,7 @@ $forms['Left_frame']['Left_frame'] = array( 'LeftPointerEnable', 'LeftRecentTable'); $forms['Left_frame']['Left_databases'] = array( + 'LeftDisplayDatabaseFilterMinimum', 'DisplayDatabasesList', 'LeftFrameDBTree', 'LeftFrameDBSeparator', diff --git a/navigation.php b/navigation.php index 46f68af7da..7694ae5d2a 100644 --- a/navigation.php +++ b/navigation.php @@ -201,8 +201,19 @@ if (! $GLOBALS['server']) { .'' . "\n" . '' . "\n"; } else { + + if (count($GLOBALS['pma']->databases) >= $GLOBALS['cfg']['LeftDisplayDatabaseFilterMinimum']) { + ?> + + X + + + databases->getHtmlListGrouped(true, $_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n"; } + $_url_params = array('pos' => $pos); PMA_listNavigator(count($GLOBALS['pma']->databases), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']); } diff --git a/themes/original/css/theme_left.css.php b/themes/original/css/theme_left.css.php index 6591139871..4a593e2cb1 100644 --- a/themes/original/css/theme_left.css.php +++ b/themes/original/css/theme_left.css.php @@ -232,7 +232,8 @@ div#left_tableList ul ul { display: none; } -#clear_fast_filter { +#clear_fast_filter, +#clear_fast_db_filter { background: white; color: black; cursor: pointer; @@ -242,13 +243,16 @@ div#left_tableList ul ul { float: right; } -#fast_filter { +#fast_filter, +#fast_db_filter { width: 100%; padding: 2px 0; margin: 0; border: 0; } -#fast_filter.gray { +#fast_filter.gray, +#fast_db_fiter.gray { color: gray; -} \ No newline at end of file +} + diff --git a/themes/pmahomme/css/theme_left.css.php b/themes/pmahomme/css/theme_left.css.php index 6873681895..92f64b0c9a 100644 --- a/themes/pmahomme/css/theme_left.css.php +++ b/themes/pmahomme/css/theme_left.css.php @@ -292,7 +292,8 @@ div#left_tableList ul ul { display: none; } -#clear_fast_filter { +#clear_fast_filter, +#clear_fast_db_filter { background: white; color: black; cursor: pointer; @@ -302,11 +303,13 @@ div#left_tableList ul ul { right: 3ex; } -#fast_filter { +#fast_filter, +#fast_db_filter { width: 85%; padding: .1em; } -#fast_filter.gray { +#fast_filter.gray, +#fast_db_filter.gray { color: gray; }