@@ -6,17 +6,10 @@ import { getConfigValue, setConfigValue } from './functions/config.ts';
66import handleRedirectAndReload from './functions/handleRedirectAndReload.ts' ;
77import isStorageSupported from './functions/isStorageSupported.ts' ;
88
9- /**
10- * function used in or for navigation panel
11- *
12- * @package phpMyAdmin-Navigation
13- */
14- const Navigation = { } ;
15-
169/**
1710 * updates the tree state in sessionStorage
1811 */
19- Navigation . treeStateUpdate = function ( ) : void {
12+ function treeStateUpdate ( ) : void {
2013 // update if session storage is supported
2114 if ( isStorageSupported ( 'sessionStorage' ) ) {
2215 var storage = window . sessionStorage ;
@@ -34,15 +27,15 @@ Navigation.treeStateUpdate = function (): void {
3427 storage . removeItem ( 'token' ) ;
3528 }
3629 }
37- } ;
30+ }
3831
3932/**
4033 * updates the filter state in sessionStorage
4134 *
4235 * @param {string } filterName
4336 * @param {string } filterValue
4437 */
45- Navigation . filterStateUpdate = function ( filterName , filterValue ) : void {
38+ function filterStateUpdate ( filterName , filterValue ) : void {
4639 if ( isStorageSupported ( 'sessionStorage' ) ) {
4740 var storage = window . sessionStorage ;
4841 try {
@@ -55,12 +48,12 @@ Navigation.filterStateUpdate = function (filterName, filterValue): void {
5548 storage . removeItem ( 'navTreeSearchFilters' ) ;
5649 }
5750 }
58- } ;
51+ }
5952
6053/**
6154 * restores the filter state on navigation reload
6255 */
63- Navigation . filterStateRestore = function ( ) : void {
56+ function filterStateRestore ( ) : void {
6457 if ( isStorageSupported ( 'sessionStorage' )
6558 && typeof window . sessionStorage . navTreeSearchFilters !== 'undefined'
6659 ) {
@@ -120,7 +113,7 @@ Navigation.filterStateRestore = function (): void {
120113 }
121114 } ) ;
122115 }
123- } ;
116+ }
124117
125118/**
126119 * Loads child items of a node and executes a given callback
@@ -129,7 +122,7 @@ Navigation.filterStateRestore = function (): void {
129122 * @param $expandElem expander
130123 * @param callback callback function
131124 */
132- Navigation . loadChildNodes = function ( isNode , $expandElem , callback ) : void {
125+ function loadChildNodes ( isNode , $expandElem , callback ) : void {
133126 var $destination = null ;
134127 var params = null ;
135128
@@ -214,14 +207,14 @@ Navigation.loadChildNodes = function (isNode, $expandElem, callback): void {
214207 ajaxShowMessage ( data . error , false ) ;
215208 }
216209 } ) ;
217- } ;
210+ }
218211
219212/**
220213 * Collapses a node in navigation tree.
221214 *
222215 * @param $expandElem expander
223216 */
224- Navigation . collapseTreeNode = function ( $expandElem ) : void {
217+ function collapseTreeNode ( $expandElem ) : void {
225218 var $children = $expandElem . closest ( 'li' ) . children ( 'div.list_container' ) ;
226219 var $icon = $expandElem . find ( 'img' ) ;
227220 if ( $expandElem . hasClass ( 'loaded' ) ) {
@@ -233,7 +226,7 @@ Navigation.collapseTreeNode = function ($expandElem): void {
233226
234227 $expandElem . trigger ( 'blur' ) ;
235228 $children . promise ( ) . done ( Navigation . treeStateUpdate ) ;
236- } ;
229+ }
237230
238231/**
239232 * Traverse the navigation tree backwards to generate all the actual
@@ -242,7 +235,7 @@ Navigation.collapseTreeNode = function ($expandElem): void {
242235 *
243236 * @return {object }
244237 */
245- Navigation . traverseForPaths = function ( ) {
238+ function traverseForPaths ( ) {
246239 var params = {
247240 pos : $ ( '#pma_navigation_tree' ) . find ( 'div.dbselector select' ) . val ( )
248241 } ;
@@ -280,15 +273,15 @@ Navigation.traverseForPaths = function () {
280273 } ) ;
281274
282275 return params ;
283- } ;
276+ }
284277
285278/**
286279 * Expands a node in navigation tree.
287280 *
288281 * @param $expandElem expander
289282 * @param callback callback function
290283 */
291- Navigation . expandTreeNode = function ( $expandElem , callback ) : void {
284+ function expandTreeNode ( $expandElem , callback = undefined ) : void {
292285 var $children = $expandElem . closest ( 'li' ) . children ( 'div.list_container' ) ;
293286 var $icon = $expandElem . find ( 'img' ) ;
294287 if ( $expandElem . hasClass ( 'loaded' ) ) {
@@ -339,7 +332,7 @@ Navigation.expandTreeNode = function ($expandElem, callback): void {
339332 }
340333
341334 $expandElem . trigger ( 'blur' ) ;
342- } ;
335+ }
343336
344337/**
345338 * Auto-scrolls the newly chosen database
@@ -348,7 +341,7 @@ Navigation.expandTreeNode = function ($expandElem, callback): void {
348341 * @param {boolean } $forceToTop Whether to force scroll to top
349342 *
350343 */
351- Navigation . scrollToView = function ( $element , $forceToTop ) {
344+ function scrollToView ( $element , $forceToTop ) {
352345 Navigation . filterStateRestore ( ) ;
353346 var $container = $ ( '#pma_navigation_tree_content' ) ;
354347 var elemTop = $element . offset ( ) . top - $container . offset ( ) . top ;
@@ -363,12 +356,12 @@ Navigation.scrollToView = function ($element, $forceToTop) {
363356 scrollTop : elemTop + textHeight - $container . height ( ) + $container . scrollTop ( ) + scrollPadding
364357 } ) ;
365358 }
366- } ;
359+ }
367360
368361/**
369362 * Expand the navigation and highlight the current database or table/view
370363 */
371- Navigation . showCurrent = function ( ) : void {
364+ function showCurrent ( ) : void {
372365 var db = CommonParams . get ( 'db' ) ;
373366 var table = CommonParams . get ( 'table' ) ;
374367
@@ -585,23 +578,23 @@ Navigation.showCurrent = function (): void {
585578
586579 return $whichItem ;
587580 }
588- } ;
581+ }
589582
590583/**
591584 * Disable navigation panel settings
592585 */
593- Navigation . disableSettings = function ( ) : void {
586+ function disableSettings ( ) : void {
594587 $ ( '#pma_navigation_settings_icon' ) . addClass ( 'hide' ) ;
595588 $ ( '#pma_navigation_settings' ) . remove ( ) ;
596- } ;
589+ }
597590
598591/**
599592 * Ensure that navigation panel settings is properly setup.
600593 * If not, set it up
601594 *
602595 * @param {string } selflink
603596 */
604- Navigation . ensureSettings = function ( selflink ) : void {
597+ function ensureSettings ( selflink ) : void {
605598 $ ( '#pma_navigation_settings_icon' ) . removeClass ( 'hide' ) ;
606599
607600 if ( ! $ ( '#pma_navigation_settings' ) . length ) {
@@ -622,15 +615,15 @@ Navigation.ensureSettings = function (selflink): void {
622615 } else {
623616 $ ( '#pma_navigation_settings' ) . find ( 'form' ) . attr ( 'action' , selflink ) ;
624617 }
625- } ;
618+ }
626619
627620/**
628621 * Reloads the whole navigation tree while preserving its state
629622 *
630623 * @param {Function } callback the callback function
631624 * @param {object } paths stored navigation paths
632625 */
633- Navigation . reload = function ( callback = null , paths = null ) : void {
626+ function reload ( callback = null , paths = null ) : void {
634627 var params = {
635628 'reload' : true ,
636629 'no_debug' : true ,
@@ -667,9 +660,9 @@ Navigation.reload = function (callback = null, paths = null): void {
667660 }
668661 } ) ;
669662 }
670- } ;
663+ }
671664
672- Navigation . selectCurrentDatabase = function ( ) {
665+ function selectCurrentDatabase ( ) {
673666 var $naviDbSelect = $ ( '#navi_db_select' ) ;
674667
675668 if ( ! $naviDbSelect . length ) {
@@ -683,7 +676,7 @@ Navigation.selectCurrentDatabase = function () {
683676 $naviDbSelect . val ( CommonParams . get ( 'db' ) ) ;
684677
685678 return $naviDbSelect . val ( ) === CommonParams . get ( 'db' ) ;
686- } ;
679+ }
687680
688681/**
689682 * Handles any requests to change the page in a branch of a tree
@@ -693,7 +686,7 @@ Navigation.selectCurrentDatabase = function () {
693686 * @param {object } $this A jQuery object that points to the element that
694687 * initiated the action of changing the page
695688 */
696- Navigation . treePagination = function ( $this ) : void {
689+ function treePagination ( $this ) : void {
697690 var $msgbox = ajaxShowMessage ( ) ;
698691 var isDbSelector = $this . closest ( 'div.pageselector' ) . is ( '.dbselector' ) ;
699692 var url = 'index.php?route=/navigation' ;
@@ -760,15 +753,15 @@ Navigation.treePagination = function ($this): void {
760753
761754 Navigation . treeStateUpdate ( ) ;
762755 } ) ;
763- } ;
756+ }
764757
765758/**
766759 * ResizeHandler Custom object that manages the resizing of the navigation
767760 *
768761 * XXX: Must only be ever instanciated once
769762 * XXX: Inside event handlers the 'this' object is accessed as 'event.data.resize_handler'
770763 */
771- Navigation . ResizeHandler = function ( ) {
764+ const ResizeHandler = function ( ) {
772765 /**
773766 * @var {number} panelWidth Used by the collapser to know where to go
774767 * back to when uncollapsing the panel
@@ -1028,7 +1021,7 @@ Navigation.ResizeHandler = function () {
10281021 * @var {object} FastFilter Handles the functionality that allows filtering
10291022 * of the items in a branch of the navigation tree
10301023 */
1031- Navigation . FastFilter = {
1024+ const FastFilter = {
10321025 /**
10331026 * Construct for the asynchronous fast filter functionality
10341027 *
@@ -1254,7 +1247,7 @@ Navigation.FastFilter = {
12541247 *
12551248 * @param {string } searchClause The query string for the filter
12561249 */
1257- Navigation . FastFilter . Filter . prototype . update = function ( searchClause ) : void {
1250+ FastFilter . Filter . prototype . update = function ( searchClause ) : void {
12581251 if ( this . searchClause !== searchClause ) {
12591252 this . searchClause = searchClause ;
12601253 this . request ( ) ;
@@ -1265,7 +1258,7 @@ Navigation.FastFilter.Filter.prototype.update = function (searchClause): void {
12651258 * After a delay of 250mS, initiates a request to retrieve search results
12661259 * Multiple calls to this function will always abort the previous request
12671260 */
1268- Navigation . FastFilter . Filter . prototype . request = function ( ) : void {
1261+ FastFilter . Filter . prototype . request = function ( ) : void {
12691262 var self = this ;
12701263 if ( self . $this . find ( 'li.fast_filter' ) . find ( 'img.throbber' ) . length === 0 ) {
12711264 self . $this . find ( 'li.fast_filter' ) . append (
@@ -1313,7 +1306,7 @@ Navigation.FastFilter.Filter.prototype.request = function (): void {
13131306 *
13141307 * @param {string } list The search results
13151308 */
1316- Navigation . FastFilter . Filter . prototype . swap = function ( list ) : void {
1309+ FastFilter . Filter . prototype . swap = function ( list ) : void {
13171310 this . $this
13181311 . html ( $ ( list ) . html ( ) )
13191312 . children ( )
@@ -1330,7 +1323,7 @@ Navigation.FastFilter.Filter.prototype.swap = function (list): void {
13301323 *
13311324 * @param {boolean } focus Whether to also focus the input box of the fast filter
13321325 */
1333- Navigation . FastFilter . Filter . prototype . restore = function ( focus ) : void {
1326+ FastFilter . Filter . prototype . restore = function ( focus ) : void {
13341327 if ( this . $this . children ( 'ul' ) . first ( ) . hasClass ( 'search_results' ) ) {
13351328 this . $this . html ( this . $clone . html ( ) ) . children ( ) . show ( ) ;
13361329 this . $this . data ( 'fastFilter' , this ) ;
@@ -1349,7 +1342,7 @@ Navigation.FastFilter.Filter.prototype.restore = function (focus): void {
13491342 *
13501343 * @param {object } $containerELem Container element
13511344 */
1352- Navigation . showFullName = function ( $containerELem ) : void {
1345+ function showFullName ( $containerELem ) : void {
13531346 $containerELem . find ( '.hover_show_full' ) . on ( 'mouseenter' , function ( ) {
13541347 /** mouseenter */
13551348 var $this = $ ( this ) ;
@@ -1386,15 +1379,39 @@ Navigation.showFullName = function ($containerELem): void {
13861379 } , 200 ) ;
13871380 }
13881381 } ) ;
1389- } ;
1382+ }
13901383
13911384/**
13921385 * @param {boolean } update
13931386 */
1394- Navigation . update = ( update ) : void => {
1387+ function update ( update ) : void {
13951388 if ( update && $ ( '#pma_navigation_tree' ) . hasClass ( 'synced' ) ) {
13961389 Navigation . showCurrent ( ) ;
13971390 }
1391+ }
1392+
1393+ /**
1394+ * Used in or for navigation panel.
1395+ */
1396+ const Navigation = {
1397+ treeStateUpdate : treeStateUpdate ,
1398+ filterStateUpdate : filterStateUpdate ,
1399+ filterStateRestore : filterStateRestore ,
1400+ loadChildNodes : loadChildNodes ,
1401+ collapseTreeNode : collapseTreeNode ,
1402+ traverseForPaths : traverseForPaths ,
1403+ expandTreeNode : expandTreeNode ,
1404+ scrollToView : scrollToView ,
1405+ showCurrent : showCurrent ,
1406+ disableSettings : disableSettings ,
1407+ ensureSettings : ensureSettings ,
1408+ reload : reload ,
1409+ selectCurrentDatabase : selectCurrentDatabase ,
1410+ treePagination : treePagination ,
1411+ ResizeHandler : ResizeHandler ,
1412+ FastFilter : FastFilter ,
1413+ showFullName : showFullName ,
1414+ update : update ,
13981415} ;
13991416
14001417window . Navigation = Navigation ;
0 commit comments