blocks
6 years ago
build
6 years ago
fonts
8 years ago
genericons
6 years ago
lib
6 years ago
social-logos
7 years ago
accessible-focus.js
8 years ago
class.jetpack-provision.php
6 years ago
connect-button.js
6 years ago
crowdsignal-shortcode.js
7 years ago
crowdsignal-survey.js
7 years ago
facebook-embed.js
7 years ago
footer.php
7 years ago
gallery-settings.js
7 years ago
genericons.php
11 years ago
header.php
7 years ago
idc-notice.js
7 years ago
jetpack-admin.js
7 years ago
jetpack-connection-banner.js
6 years ago
jetpack-jitm.js
7 years ago
jetpack-modules.js
7 years ago
jetpack-modules.models.js
6 years ago
jetpack-modules.views.js
7 years ago
jetpack-server-sandbox.php
6 years ago
jetpack-strings.php
6 years ago
jquery.jetpack-resize.js
7 years ago
jquery.spin.js
8 years ago
polldaddy-shortcode.js
6 years ago
postmessage.js
8 years ago
social-logos.php
9 years ago
spin.js
8 years ago
twitter-timeline.js
6 years ago
jetpack-modules.views.js
63 lines
| 1 | this.jetpackModules = this.jetpackModules || {}; |
| 2 | |
| 3 | window.jetpackModules.views = ( function( window, $, _, Backbone, wp ) { |
| 4 | 'use strict'; |
| 5 | |
| 6 | var views = {}; |
| 7 | |
| 8 | views.List_Table = Backbone.View.extend( { |
| 9 | template: wp.template( 'Jetpack_Modules_List_Table_Template' ), |
| 10 | |
| 11 | /** |
| 12 | * If we can, use replaceState to change the URL and indicate the new filtering. |
| 13 | * This will be handy with redirecting back to the same state after activating/deactivating. |
| 14 | */ |
| 15 | updateUrl: function() { |
| 16 | if ( ! window.history.replaceState ) { |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | var url = window.location.href.split( '?' )[ 0 ] + '?page=jetpack_modules', |
| 21 | m_tag = $( '.subsubsub .current' ), |
| 22 | m_filter = $( '.button-group.filter-active .active' ), |
| 23 | m_sort = $( '.button-group.sort .active' ), |
| 24 | m_search = $( '#srch-term-search-input' ).val(); |
| 25 | |
| 26 | if ( m_search.length ) { |
| 27 | url += '&s=' + encodeURIComponent( m_search ); |
| 28 | } |
| 29 | |
| 30 | if ( ! m_tag.hasClass( 'all' ) ) { |
| 31 | url += '&module_tag=' + encodeURIComponent( m_tag.data( 'title' ) ); |
| 32 | } |
| 33 | |
| 34 | if ( m_filter.data( 'filter-by' ) ) { |
| 35 | url += |
| 36 | '&' + |
| 37 | encodeURIComponent( m_filter.data( 'filter-by' ) ) + |
| 38 | '=' + |
| 39 | encodeURIComponent( m_filter.data( 'filter-value' ) ); |
| 40 | } |
| 41 | |
| 42 | if ( 'name' !== m_sort.data( 'sort-by' ) ) { |
| 43 | url += '&sort_by=' + encodeURIComponent( m_sort.data( 'sort-by' ) ); |
| 44 | } |
| 45 | |
| 46 | window.history.replaceState( {}, '', url ); |
| 47 | }, |
| 48 | |
| 49 | render: function() { |
| 50 | this.model.filter_and_sort(); |
| 51 | this.$el.html( this.template( this.model.attributes ) ); |
| 52 | this.updateUrl(); |
| 53 | return this; |
| 54 | }, |
| 55 | |
| 56 | initialize: function() { |
| 57 | this.listenTo( this.model, 'change', this.render ); |
| 58 | }, |
| 59 | } ); |
| 60 | |
| 61 | return views; |
| 62 | } )( this, jQuery, _, Backbone, wp ); |
| 63 |