]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/theme.js
WordPress 4.7-scripts
[autoinstalls/wordpress.git] / wp-admin / js / theme.js
index 18596e824d30048f9013b332235cf2889becf12c..924f29971643749069dc294641693ec89e24da67 100644 (file)
@@ -610,6 +610,11 @@ themes.view.Theme = wp.Backbone.View.extend({
 
        updateTheme: function( event ) {
                var _this = this;
+
+               if ( ! this.model.get( 'hasPackage' ) ) {
+                       return;
+               }
+
                event.preventDefault();
 
                wp.updates.maybeRequestFilesystemCredentials( event );
@@ -866,8 +871,12 @@ themes.view.Preview = themes.view.Details.extend({
        html: themes.template( 'theme-preview' ),
 
        render: function() {
-               var self = this, currentPreviewDevice,
-                       data = this.model.toJSON();
+               var self = this,
+                       currentPreviewDevice,
+                       data = this.model.toJSON(),
+                       $body = $( document.body );
+
+               $body.attr( 'aria-busy', 'true' );
 
                this.$el.removeClass( 'iframe-ready' ).html( this.html( data ) );
 
@@ -879,8 +888,7 @@ themes.view.Preview = themes.view.Details.extend({
                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' );
-                       $( '.close-full-overlay' ).focus();
+                       $body.addClass( 'theme-installer-active full-overlay-active' );
                });
 
                this.$el.find( 'iframe' ).one( 'load', function() {
@@ -890,6 +898,7 @@ themes.view.Preview = themes.view.Details.extend({
 
        iframeLoaded: function() {
                this.$el.addClass( 'iframe-ready' );
+               $( document.body ).attr( 'aria-busy', 'false' );
        },
 
        close: function() {
@@ -1519,6 +1528,7 @@ themes.view.InstallerSearch =  themes.view.Search.extend({
 
                $( '.filter-links li > a.current' ).removeClass( 'current' );
                $( 'body' ).removeClass( 'show-filters filters-applied show-favorites-form' );
+               $( '.drawer-toggle' ).attr( 'aria-expanded', 'false' );
 
                // Get the themes by sending Ajax POST request to api.wordpress.org/themes
                // or searching the local cache
@@ -1541,7 +1551,7 @@ themes.view.Installer = themes.view.Appearance.extend({
                'click .filter-drawer .apply-filters': 'applyFilters',
                'click .filter-group [type="checkbox"]': 'addFilter',
                'click .filter-drawer .clear-filters': 'clearFilters',
-               'click .filtered-by': 'backToFilters',
+               'click .edit-filters': 'backToFilters',
                'click .favorites-form-submit' : 'saveUsername',
                'keyup #wporg-username-input': 'saveUsername'
        },
@@ -1617,6 +1627,7 @@ themes.view.Installer = themes.view.Appearance.extend({
                event.preventDefault();
 
                $( 'body' ).removeClass( 'filters-applied show-filters' );
+               $( '.drawer-toggle' ).attr( 'aria-expanded', 'false' );
 
                // Bail if this is already active
                if ( $el.hasClass( this.activeClass ) ) {
@@ -1636,9 +1647,9 @@ themes.view.Installer = themes.view.Appearance.extend({
                $( '[data-sort="' + sort + '"]' ).addClass( this.activeClass );
 
                if ( 'favorites' === sort ) {
-                       $ ( 'body' ).addClass( 'show-favorites-form' );
+                       $( 'body' ).addClass( 'show-favorites-form' );
                } else {
-                       $ ( 'body' ).removeClass( 'show-favorites-form' );
+                       $( 'body' ).removeClass( 'show-favorites-form' );
                }
 
                this.browse( sort );
@@ -1688,6 +1699,11 @@ themes.view.Installer = themes.view.Appearance.extend({
                        event.preventDefault();
                }
 
+               if ( ! tags ) {
+                       wp.a11y.speak( l10n.selectFeatureFilter );
+                       return;
+               }
+
                $( 'body' ).addClass( 'filters-applied' );
                $( '.filter-links li > a.current' ).removeClass( 'current' );
                filteringBy.empty();
@@ -1778,22 +1794,22 @@ themes.view.Installer = themes.view.Appearance.extend({
 
        // Toggle the full filters navigation
        moreFilters: function( event ) {
+               var $body = $( 'body' ),
+                       $toggleButton = $( '.drawer-toggle' );
+
                event.preventDefault();
 
-               if ( $( 'body' ).hasClass( 'filters-applied' ) ) {
+               if ( $body.hasClass( 'filters-applied' ) ) {
                        return this.backToFilters();
                }
 
-               // If the filters section is opened and filters are checked
-               // run the relevant query collapsing to filtered-by state
-               if ( $( 'body' ).hasClass( 'show-filters' ) && this.filtersChecked() ) {
-                       return this.addFilter();
-               }
-
                this.clearSearch();
 
                themes.router.navigate( themes.router.baseUrl( '' ) );
-               $( 'body' ).toggleClass( 'show-filters' );
+               // Toggle the feature filters view.
+               $body.toggleClass( 'show-filters' );
+               // Toggle the `aria-expanded` button attribute.
+               $toggleButton.attr( 'aria-expanded', $body.hasClass( 'show-filters' ) );
        },
 
        // Clears all the checked filters