blocks
2 years ago
build
2 years ago
fonts
3 years ago
genericons
6 years ago
lib
2 years ago
social-logos
2 years ago
accessible-focus.js
5 years ago
blogging-prompts.php
3 years ago
class.jetpack-provision.php
4 years ago
connect-button.js
3 years ago
crowdsignal-shortcode.js
3 years ago
crowdsignal-survey.js
5 years ago
facebook-embed.js
4 years ago
gallery-settings.js
5 years ago
genericons.php
4 years ago
jetpack-admin.js
3 years ago
jetpack-connection-banner.js
3 years ago
jetpack-deactivate-dialog.js
5 years ago
jetpack-modules.js
3 years ago
jetpack-modules.models.js
3 years ago
jetpack-modules.views.js
3 years ago
jetpack-recommendations-banner.js
3 years ago
jetpack-server-sandbox.php
4 years ago
polldaddy-shortcode.js
3 years ago
social-logos.php
3 years ago
twitter-timeline.js
5 years ago
jetpack-modules.js
90 lines
| 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 | $( '.subsubsub' ).find( 'li.current' ).removeClass( 'current' ); |
| 34 | |
| 35 | // Switch the item in the subsubsub list that's flagged as current. |
| 36 | $( '.subsubsub' ) |
| 37 | .find( 'a[data-title="' + $( this ).data( 'title' ) + '"]' ) |
| 38 | .closest( 'li' ) |
| 39 | .addClass( 'current' ); |
| 40 | |
| 41 | event.preventDefault(); |
| 42 | modules.trigger( 'change' ); |
| 43 | }; |
| 44 | |
| 45 | $( '.subsubsub a' ).on( 'click', { modules: modules }, handle_module_tag_click ); |
| 46 | |
| 47 | $the_filters.on( 'click', '.button-group .button', { modules: modules }, function ( event ) { |
| 48 | event.preventDefault(); |
| 49 | $( this ).addClass( 'active' ).siblings( '.active' ).removeClass( 'active' ); |
| 50 | modules.trigger( 'change' ); |
| 51 | } ); |
| 52 | |
| 53 | $the_search.on( 'keyup search', function ( e ) { |
| 54 | // Don't trigger change on tab, since it's only used for accessibility |
| 55 | // anyway, and will remove all checked boxes |
| 56 | if ( e.code !== 'Tab' ) { |
| 57 | modules.trigger( 'change' ); |
| 58 | } |
| 59 | } ); |
| 60 | |
| 61 | $the_search.prop( 'placeholder', i18n.search_placeholder ); |
| 62 | |
| 63 | $bulk_button.on( 'click', function ( event ) { |
| 64 | var selectedModules = $( '.jetpack-modules-list-table-form' ).serialize(), |
| 65 | selectedAction = $( this ).siblings( 'select' ).val(), |
| 66 | url; |
| 67 | |
| 68 | if ( selectedModules.length && '-1' !== selectedAction ) { |
| 69 | url = 'admin.php?page=jetpack&action=' + encodeURIComponent( selectedAction ); |
| 70 | url += '&' + selectedModules; |
| 71 | url += '&_wpnonce=' + encodeURIComponent( nonces.bulk ); |
| 72 | |
| 73 | window.location.href = url; |
| 74 | } else { |
| 75 | // Possibly add in an alert here explaining why nothing's happening? |
| 76 | } |
| 77 | |
| 78 | event.preventDefault(); |
| 79 | } ); |
| 80 | } )( |
| 81 | window, |
| 82 | jQuery, |
| 83 | window.jetpackModulesData.modules, |
| 84 | window.jetpackModules.models, |
| 85 | window.jetpackModules.views, |
| 86 | window.jetpackModulesData.i18n, |
| 87 | window.jetpackModulesData.modalinfo, |
| 88 | window.jetpackModulesData.nonces |
| 89 | ); |
| 90 |