equal
deleted
inserted
replaced
|
1 (function( $ ) { |
|
2 const container = $( '#wpdb' ); |
|
3 const nav = container.find( '.subnav' ); |
|
4 |
|
5 function toggle_nav( type ) { |
|
6 $( '#wpdb .subnav a' ).removeClass( 'active' ); |
|
7 $( '#wpdb .subnav a[data-type="' + type + '"]' ).addClass( 'active' ); |
|
8 |
|
9 const visibleClass = type + '-content'; |
|
10 container.find( 'fieldset' ).hide(); |
|
11 container.find( '.' + visibleClass ).show(); |
|
12 |
|
13 history.replaceState(null, null, ' '); |
|
14 if ( type !== 'backup') { |
|
15 window.location.hash = type; |
|
16 } else { |
|
17 $( '.wp-db-backup-schedule-updated').remove(); |
|
18 } |
|
19 } |
|
20 |
|
21 nav.on( 'click', 'a', function( e ) { |
|
22 e.preventDefault(); |
|
23 toggle_nav( $( this ).attr( 'href' ).substr( 1 ) ); |
|
24 } ); |
|
25 |
|
26 $( document ).on( 'ready', function() { |
|
27 var type = window.location.hash.substr( 1 ); |
|
28 if ( type.length && ['backup', 'schedule'].includes( type ) ) { |
|
29 toggle_nav( type ); |
|
30 } |
|
31 } ); |
|
32 |
|
33 })( jQuery ); |