diff options
author | Atul Pratap Singh <atulpratapsingh05@gmail.com> | 2013-08-17 01:32:38 +0400 |
---|---|---|
committer | Atul Pratap Singh <atulpratapsingh05@gmail.com> | 2013-08-17 01:32:38 +0400 |
commit | 15d03b227305a46c6ab9b6c1b9ad8c38c35f558f (patch) | |
tree | 8d90e3d00e99be71ccbe02bda95a10aaf6be1005 | |
parent | 42a8ad5abbeccc98109a25d93d13e2033339bfa8 (diff) |
Move autoexpand to a function
-rw-r--r-- | js/common.js | 20 | ||||
-rw-r--r-- | js/navigation.js | 23 |
2 files changed, 30 insertions, 13 deletions
diff --git a/js/common.js b/js/common.js index 00521c2473..0fe08b6328 100644 --- a/js/common.js +++ b/js/common.js @@ -43,19 +43,7 @@ var PMA_commonParams = (function () { } // 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); + PMA_autoExpandDatabaseInUse(params['db'], obj[i]); } params[i] = obj[i]; } @@ -87,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; }, @@ -124,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(); } diff --git a/js/navigation.js b/js/navigation.js index c3996f4f66..a17c8213ff 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -227,6 +227,29 @@ function PMA_expandNavigationTree($expandElem) { $expandElem.blur(); } +/* + * Auto-expands the newly chosen database + * + * @param string $oldDb + * @param string $newDb + * + */ +function PMA_autoExpandDatabaseInUse($oldDb, $newDb) { + var $expandElem, $icon; + 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); + } + $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); +} + /** * Reloads the whole navigation tree while preserving its state * |