X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/41578db67d72562346e4dbb2a14889b23d522813..caeaf8dc94b5e3f75dc98ec92dc7b76049cdddb6:/wp-admin/js/theme.js diff --git a/wp-admin/js/theme.js b/wp-admin/js/theme.js index 77054b5c..344a8178 100644 --- a/wp-admin/js/theme.js +++ b/wp-admin/js/theme.js @@ -105,7 +105,7 @@ themes.view.Appearance = wp.Backbone.View.extend({ // Render and append after screen title view.render(); this.searchContainer - .append( $.parseHTML( '' ) ) + .append( $.parseHTML( '' ) ) .append( view.el ); }, @@ -190,6 +190,12 @@ themes.Collection = Backbone.Collection.extend({ return match.test( haystack ); }); + if ( results.length === 0 ) { + this.trigger( 'query:empty' ); + } else { + $( 'body' ).removeClass( 'no-results' ); + } + this.reset( results ); }, @@ -336,7 +342,7 @@ themes.Collection = Backbone.Collection.extend({ beforeSend: function() { if ( ! paginated ) { // Spin it - $( 'body' ).addClass( 'loading-themes' ).removeClass( 'no-results' ); + $( 'body' ).addClass( 'loading-content' ).removeClass( 'no-results' ); } } }); @@ -362,7 +368,6 @@ themes.view.Theme = wp.Backbone.View.extend({ events: { 'click': themes.isInstall ? 'preview': 'expand', - 'click .preview': 'preview', 'keydown': themes.isInstall ? 'preview': 'expand', 'touchend': themes.isInstall ? 'preview': 'expand', 'keyup': 'addFocus', @@ -487,7 +492,7 @@ themes.view.Theme = wp.Backbone.View.extend({ preview.$el.removeClass( 'no-navigation' ); } - // Apend preview + // Append preview $( 'div.wrap' ).append( preview.el ); // Listen to our preview object @@ -502,7 +507,7 @@ themes.view.Theme = wp.Backbone.View.extend({ current = self.current; } - // Get previous theme model. + // Get next theme model. self.current = self.model.collection.at( self.model.collection.indexOf( current ) + 1 ); // If we have no more themes, bail. @@ -511,15 +516,11 @@ themes.view.Theme = wp.Backbone.View.extend({ return self.current = current; } - // Construct a new Preview view. - preview = new themes.view.Preview({ - model: self.current - }); + preview.model = self.current; // Render and append. preview.render(); this.setNavButtonsState(); - $( 'div.wrap' ).append( preview.el ); $( '.next-theme' ).focus(); }) .listenTo( preview, 'theme:previous', function() { @@ -545,15 +546,11 @@ themes.view.Theme = wp.Backbone.View.extend({ return; } - // Construct a new Preview view. - preview = new themes.view.Preview({ - model: self.current - }); + preview.model = self.current; // Render and append. preview.render(); this.setNavButtonsState(); - $( 'div.wrap' ).append( preview.el ); $( '.previous-theme' ).focus(); }); @@ -704,7 +701,7 @@ themes.view.Details = wp.Backbone.View.extend({ // Performs the actions to effectively close // the theme details overlay closeOverlay: function() { - $( 'body' ).removeClass( 'theme-overlay-open' ); + $( 'body' ).removeClass( 'modal-open' ); this.remove(); this.unbind(); this.trigger( 'theme:collapse' ); @@ -766,7 +763,7 @@ themes.view.Preview = themes.view.Details.extend({ this.$el.html( this.html( data ) ); - themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.get( 'id' ) ), { replace: true } ); + themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.get( 'id' ) ), { replace: true } ); this.$el.fadeIn( 200, function() { $( 'body' ).addClass( 'theme-installer-active full-overlay-active' ); @@ -786,6 +783,7 @@ themes.view.Preview = themes.view.Details.extend({ themes.router.navigate( themes.router.baseUrl( '' ) ); this.trigger( 'preview:close' ); + this.undelegateEvents(); this.unbind(); return false; }, @@ -826,7 +824,7 @@ themes.view.Themes = wp.Backbone.View.extend({ index: 0, // The theme count element - count: $( '.theme-count' ), + count: $( '.wp-filter .theme-count' ), initialize: function( options ) { var self = this; @@ -998,11 +996,11 @@ themes.view.Themes = wp.Backbone.View.extend({ this.model = self.collection.get( id ); // Trigger a route update for the current model - themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.id ) ); + themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.id ) ); // Sets this.view to 'detail' this.setView( 'detail' ); - $( 'body' ).addClass( 'theme-overlay-open' ); + $( 'body' ).addClass( 'modal-open' ); // Set up the theme details view this.overlay = new themes.view.Details({ @@ -1082,8 +1080,8 @@ themes.view.Themes = wp.Backbone.View.extend({ themes.view.Search = wp.Backbone.View.extend({ tagName: 'input', - className: 'theme-search', - id: 'theme-search-input', + className: 'wp-filter-search', + id: 'wp-filter-search-input', searching: false, attributes: { @@ -1134,7 +1132,7 @@ themes.view.Search = wp.Backbone.View.extend({ // Update the URL hash if ( event.target.value ) { - themes.router.navigate( themes.router.baseUrl( '?search=' + event.target.value ), options ); + themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + event.target.value ), options ); } else { themes.router.navigate( themes.router.baseUrl( '' ) ); } @@ -1144,7 +1142,7 @@ themes.view.Search = wp.Backbone.View.extend({ var url = themes.router.baseUrl( '' ); if ( event.target.value ) { - url = themes.router.baseUrl( '?search=' + event.target.value ); + url = themes.router.baseUrl( themes.router.searchPath + event.target.value ); } this.searching = false; @@ -1169,12 +1167,15 @@ themes.Router = Backbone.Router.extend({ return 'themes.php' + url; }, + themePath: '?theme=', + searchPath: '?search=', + search: function( query ) { - $( '.theme-search' ).val( query ); + $( '.wp-filter-search' ).val( query ); }, themes: function() { - $( '.theme-search' ).val( '' ); + $( '.wp-filter-search' ).val( '' ); }, navigate: function() { @@ -1231,7 +1232,7 @@ themes.Run = { // Handles search route event themes.router.on( 'route:search', function() { - $( '.theme-search' ).trigger( 'keyup' ); + $( '.wp-filter-search' ).trigger( 'keyup' ); }); this.extraRoutes(); @@ -1290,15 +1291,15 @@ themes.view.InstallerSearch = themes.view.Search.extend({ request.tag = [ value.slice( 4 ) ]; } - $( '.theme-section.current' ).removeClass( 'current' ); - $( 'body' ).removeClass( 'more-filters-opened filters-applied' ); + $( '.filter-links li > a.current' ).removeClass( 'current' ); + $( 'body' ).removeClass( 'show-filters filters-applied' ); // Get the themes by sending Ajax POST request to api.wordpress.org/themes // or searching the local cache this.collection.query( request ); // Set route - themes.router.navigate( themes.router.baseUrl( '?search=' + value ), { replace: true } ); + themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + value ), { replace: true } ); }, 300 ) }); @@ -1308,14 +1309,13 @@ themes.view.Installer = themes.view.Appearance.extend({ // Register events for sorting and filters in theme-navigation events: { - 'click .theme-section': 'onSort', + 'click .filter-links li > a': 'onSort', 'click .theme-filter': 'onFilter', - 'click .more-filters': 'moreFilters', - 'click .apply-filters': 'applyFilters', - 'click [type="checkbox"]': 'addFilter', - 'click .clear-filters': 'clearFilters', - 'click .feature-name': 'filterSection', - 'click .filtering-by a': 'backToFilters' + 'click .drawer-toggle': 'moreFilters', + 'click .filter-drawer .apply-filters': 'applyFilters', + 'click .filter-group [type="checkbox"]': 'addFilter', + 'click .filter-drawer .clear-filters': 'clearFilters', + 'click .filtered-by': 'backToFilters' }, // Initial render method @@ -1345,12 +1345,12 @@ themes.view.Installer = themes.view.Appearance.extend({ }); this.listenTo( this.collection, 'query:success', function() { - $( 'body' ).removeClass( 'loading-themes' ); + $( 'body' ).removeClass( 'loading-content' ); $( '.theme-browser' ).find( 'div.error' ).remove(); }); this.listenTo( this.collection, 'query:fail', function() { - $( 'body' ).removeClass( 'loading-themes' ); + $( 'body' ).removeClass( 'loading-content' ); $( '.theme-browser' ).find( 'div.error' ).remove(); $( '.theme-browser' ).find( 'div.themes' ).before( '
' + l10n.error + '