Making WordPress.org

Changeset 1247


Ignore:
Timestamp:
02/10/2015 09:23:38 PM (10 years ago)
Author:
obenland
Message:

WP.org Themes: Disable "Apply Filters"-button by default.

Avoids submitting an empty tag request and improves general usability.

See #745.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/index.php

    r1242 r1247  
    3737            <div class="filter-drawer">
    3838                <div class="buttons">
    39                     <a class="apply-filters button button-secondary" href="#"><?php _e( 'Apply Filters' ); ?><span></span></a>
    40                     <a class="clear-filters button button-secondary" href="#"><?php _e( 'Clear' ); ?></a>
     39                    <button type="button" disabled="disabled" class="apply-filters button button-secondary"><?php _e( 'Apply Filters' ); ?><span></span></button>
     40                    <button type="button" class="clear-filters button button-secondary"><?php _e( 'Clear' ); ?></button>
    4141                </div>
    4242
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js

    r1241 r1247  
    5454
    5555            $( 'body' ).toggleClass( 'show-filters' );
    56         }
     56        },
     57
     58        // Get the checked filters.
     59        // @return {array} of tags or false.
     60        filtersChecked: function() {
     61            var items  = $( '.filter-group' ).find( ':checkbox' ).filter( ':checked' ),
     62                drawer = $( '.filter-drawer' ),
     63                tags   = [];
     64
     65            _.each( items, function( item ) {
     66                tags.push( $( item ).prop( 'value' ) );
     67            });
     68
     69            // When no filters are checked, restore initial state and return.
     70            if ( 0 === tags.length ) {
     71                drawer.find( '.apply-filters' ).prop( 'disabled', true ).find( 'span' ).text( '' );
     72                drawer.find( '.clear-filters' ).hide();
     73                $( 'body' ).removeClass( 'filters-applied' );
     74                return false;
     75            }
     76
     77            drawer.find( '.apply-filters' ).prop( 'disabled', false ).find( 'span' ).text( tags.length );
     78            drawer.find( '.clear-filters' ).css( 'display', 'inline-block' );
     79
     80            return tags;
     81        },
    5782
    5883    });
Note: See TracChangeset for help on using the changeset viewer.