PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 7.7
Jetpack – WP Security, Backup, Speed, & Growth v7.7
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / _inc / jetpack-modules.js

jetpack-modules.js in Jetpack – WP Security, Backup, Speed, & Growth 7.7, at _inc/jetpack-modules.js

96 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function( window, $, items, models, views, i18n, modalinfo, nonces ) {
2 'use strict';
3
4 var modules,
5 list_table,
6 handle_module_tag_click,
7 $the_table,
8 $the_filters,
9 $the_search,
10 $jp_frame,
11 $bulk_button;
12
13 $the_table = $( '.wp-list-table.jetpack-modules' );
14 $the_filters = $( '.navbar-form' );
15 $the_search = $( '#srch-term-search-input' );
16 $jp_frame = $( '.jp-frame' );
17 $bulk_button = $( '#doaction' );
18
19 modules = new models.Modules( {
20 items: items,
21 } );
22
23 list_table = new views.List_Table( {
24 el: '#the-list',
25 model: modules,
26 } );
27
28 // Kick off an initial redraw.
29 modules.trigger( 'change' );
30
31 // Handle the filtering of modules.
32 handle_module_tag_click = function( event ) {
33 // Switch the item in the subsubsub list that's flagged as current.
34 $( '.subsubsub' )
35 .find( 'a[data-title="' + $( this ).data( 'title' ) + '"]' )
36 .addClass( 'current' )
37 .closest( 'li' )
38 .siblings()
39 .find( 'a.current' )
40 .removeClass( 'current' );
41
42 event.preventDefault();
43 modules.trigger( 'change' );
44 };
45
46 $( '.subsubsub a' ).on( 'click', { modules: modules }, handle_module_tag_click );
47
48 $the_filters.on( 'click', '.button-group .button', { modules: modules }, function( event ) {
49 event.preventDefault();
50 $( this )
51 .addClass( 'active' )
52 .siblings( '.active' )
53 .removeClass( 'active' );
54 modules.trigger( 'change' );
55 } );
56
57 $the_search.on( 'keyup search', function( e ) {
58 // Don't trigger change on tab, since it's only used for accessibility
59 // anyway, and will remove all checked boxes
60 if ( e.keyCode !== 9 ) {
61 modules.trigger( 'change' );
62 }
63 } );
64
65 $the_search.prop( 'placeholder', i18n.search_placeholder );
66
67 $bulk_button.on( 'click', function( event ) {
68 var selectedModules = $( '.jetpack-modules-list-table-form' ).serialize(),
69 selectedAction = $( this )
70 .siblings( 'select' )
71 .val(),
72 url;
73
74 if ( selectedModules.length && '-1' !== selectedAction ) {
75 url = 'admin.php?page=jetpack&action=' + encodeURIComponent( selectedAction );
76 url += '&' + selectedModules;
77 url += '&_wpnonce=' + encodeURIComponent( nonces.bulk );
78
79 window.location.href = url;
80 } else {
81 // Possibly add in an alert here explaining why nothing's happening?
82 }
83
84 event.preventDefault();
85 } );
86 } )(
87 this,
88 jQuery,
89 window.jetpackModulesData.modules,
90 this.jetpackModules.models,
91 this.jetpackModules.views,
92 window.jetpackModulesData.i18n,
93 window.jetpackModulesData.modalinfo,
94 window.jetpackModulesData.nonces
95 );
96