PluginProbe
Stream – Activity Log & Audit Trail / 3.2.0
Stream – Activity Log & Audit Trail v3.2.0
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
stream / ui / js / settings.js

settings.js in Stream – Activity Log & Audit Trail 3.2.0, at ui/js/settings.js

76 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* globals confirm, wp_stream, ajaxurl, wp_stream_regenerate_alt_rows */
2 jQuery( function( $ ) {
3 var network_affix;
4 if ( 'wp_stream_network' === $( 'input[name="option_page"]' ).val() ) {
5 network_affix = '_network_affix';
6 } else {
7 network_affix = '';
8 }
9 var keepRecordsIndefinitely = $( '#wp_stream' + network_affix + '\\[general_keep_records_indefinitely\\]' ),
10 keepRecordsFor = $( '#wp_stream' + network_affix + '_general_records_ttl' ),
11 keepRecordsForRow = keepRecordsFor.closest( 'tr' );
12
13 function toggleKeepRecordsFor() {
14 if ( keepRecordsIndefinitely.is( ':checked' ) ) {
15 keepRecordsForRow.addClass( 'hidden' );
16 keepRecordsFor.addClass( 'hidden' );
17 } else {
18 keepRecordsForRow.removeClass( 'hidden' );
19 keepRecordsFor.removeClass( 'hidden' );
20 }
21 }
22
23 keepRecordsIndefinitely.on( 'change', function() {
24 toggleKeepRecordsFor();
25 });
26
27 toggleKeepRecordsFor();
28 // Confirmation on some important actions
29 $( '#wp_stream_general_reset_site_settings' ).click( function( e ) {
30 if ( ! confirm( wp_stream.i18n.confirm_defaults ) ) {
31 e.preventDefault();
32 }
33 });
34
35 // Settings page tabs
36 var $tabs = $( '.nav-tab-wrapper' ),
37 $panels = $( '.nav-tab-content table.form-table' ),
38 $activeTab = $tabs.find( '.nav-tab-active' ),
39 defaultIndex = $activeTab.length > 0 ? $tabs.find( 'a' ).index( $activeTab ) : 0,
40 hashIndex = window.location.hash.match( /^#(\d+)$/ ),
41 currentHash = ( null !== hashIndex ? hashIndex[ 1 ] : defaultIndex ),
42 syncFormAction = function( index ) {
43 var $optionsForm = $( 'input[name="option_page"][value^="wp_stream"]' ).closest( 'form' );
44 if ( $optionsForm.length === 0 ) {
45 return;
46 }
47 var currentAction = $optionsForm.attr( 'action' );
48
49 $optionsForm.prop( 'action', currentAction.replace( /(^[^#]*).*$/, '$1#' + index ) );
50 };
51
52 $tabs.on( 'click', 'a', function() {
53 var index = $tabs.find( 'a' ).index( $( this ) ),
54 hashIndex = window.location.hash.match( /^#(\d+)$/ );
55
56 $panels.hide().eq( index ).show();
57
58 $tabs
59 .find( 'a' )
60 .removeClass( 'nav-tab-active' )
61 .filter( $( this ) )
62 .addClass( 'nav-tab-active' );
63
64 if ( '' === window.location.hash || null !== hashIndex ) {
65 window.location.hash = index;
66 }
67
68 syncFormAction( index );
69
70 return false;
71 });
72
73 $tabs.children().eq( currentHash ).trigger( 'click' );
74
75 });
76