Skip to content

Commit 9729c26

Browse files
author
scribu
committed
Ajaxify theme feature filter. Props ocean90 for initial patch. See #14936
git-svn-id: https://develop.svn.wordpress.org/trunk@16553 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 81e04a8 commit 9729c26

4 files changed

Lines changed: 33 additions & 18 deletions

File tree

wp-admin/js/theme.dev.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var ThemeViewer;
44
ThemeViewer = function( args ) {
55

66
function filter_count() {
7-
var count = $( '#filters :checked' ).length;
7+
var count = $( '#filter-box :checked' ).length;
88
var text = $( '#filter-click' ).text();
99

1010
if ( text.indexOf( '(' ) != -1 )
@@ -19,14 +19,29 @@ var ThemeViewer;
1919
function init() {
2020
$( '#filter-click, #mini-filter-click' ).unbind( 'click' ).click( function() {
2121
$( '#filter-click' ).toggleClass( 'current' );
22-
$( '#filters' ).slideToggle();
22+
$( '#filter-box' ).slideToggle();
2323
$( '#current-theme' ).slideToggle( 300 );
2424
return false;
2525
});
2626

27-
$( '#filters :checkbox' ).unbind( 'click' ).click( function() {
27+
$( '#filter-box :checkbox' ).unbind( 'click' ).click( function() {
2828
filter_count();
2929
});
30+
31+
$('#filter-box :submit').unbind( 'click' ).click(function() {
32+
var features = [];
33+
$('#filter-box :checked').each(function() {
34+
features.push($(this).val());
35+
});
36+
37+
listTable.update_rows({'features': features}, true, function() {
38+
$( '#filter-click' ).toggleClass( 'current' );
39+
$( '#filter-box' ).slideToggle();
40+
$( '#current-theme' ).slideToggle( 300 );
41+
});
42+
43+
return false;
44+
});
3045
}
3146

3247
// These are the functions we expose

wp-admin/js/theme.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wp-admin/themes.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
?>
130130
<h3><?php _e('Available Themes'); ?></h3>
131131

132-
<form class="search-form" action="" method="get">
132+
<form class="search-form filter-form" action="" method="get">
133133
<p class="search-box">
134134
<label class="screen-reader-text" for="theme-search-input"><?php _e('Search Themes'); ?>:</label>
135135
<input type="text" id="theme-search-input" name="s" value="<?php _admin_search_query(); ?>" />
@@ -139,7 +139,7 @@
139139

140140
<br class="clear"/>
141141

142-
<div id="filters" style="display: none;">
142+
<div id="filter-box" style="display: none;">
143143
<?php $feature_list = get_theme_feature_list(); ?>
144144
<div class="feature-filter">
145145
<p class="install-help"><?php _e('Theme filters') ?></p>
@@ -154,10 +154,10 @@
154154
<?php foreach ( $features as $key => $feature ) :
155155
$feature_name = $feature;
156156
$feature_name = esc_html( $feature_name );
157-
$feature = esc_attr($feature);
157+
$feature = esc_attr( $feature );
158158
?>
159159
<li>
160-
<input type="checkbox" name="features[<?php echo $key; ?>]" id="feature-id-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( in_array( $key, $wp_list_table->features ) ); ?>/>
160+
<input type="checkbox" name="features[]" id="feature-id-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( in_array( $key, $wp_list_table->features ) ); ?>/>
161161
<label for="feature-id-<?php echo $key; ?>"><?php echo $feature_name; ?></label>
162162
</li>
163163
<?php endforeach; ?>

wp-includes/script-loader.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,15 @@ function wp_default_scripts( &$scripts ) {
304304
$scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' );
305305
$scripts->add_data( 'admin-custom-fields', 'group', 1 );
306306

307+
$scripts->add( 'list-table', "/wp-admin/js/list-table$suffix.js", array( 'jquery-query', 'jquery-serialize-object' ), '20101121' );
308+
$scripts->add_data( 'list-table', 'group', 1 );
309+
$scripts->localize( 'list-table', 'listTableL10n', array(
310+
'loading' => __('Loading...'),
311+
'error' => __('An error has occurred while loading the items.'),
312+
'search' => __('Search results for &#8220;%s&#8221;'),
313+
'l10n_print_after' => 'try{convertEntities(listTableL10n);}catch(e){};'
314+
) );
315+
307316
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'list-table', 'jquery-ui-resizable', 'quicktags'), '20101121' );
308317
$scripts->add_data( 'admin-comments', 'group', 1 );
309318
$scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
@@ -373,21 +382,12 @@ function wp_default_scripts( &$scripts ) {
373382
'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};'
374383
));
375384

376-
$scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'thickbox', 'jquery' ), '20101123' );
385+
$scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'thickbox', 'list-table' ), '20101123' );
377386
$scripts->add_data( 'theme', 'group', 1 );
378387

379388
$scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20100407' );
380389
$scripts->add_data( 'theme-preview', 'group', 1 );
381390

382-
$scripts->add( 'list-table', "/wp-admin/js/list-table$suffix.js", array( 'jquery-query', 'jquery-serialize-object' ), '20101121' );
383-
$scripts->add_data( 'list-table', 'group', 1 );
384-
$scripts->localize( 'list-table', 'listTableL10n', array(
385-
'loading' => __('Loading...'),
386-
'error' => __('An error has occurred while loading the items.'),
387-
'search' => __('Search results for &#8220;%s&#8221;'),
388-
'l10n_print_after' => 'try{convertEntities(listTableL10n);}catch(e){};'
389-
) );
390-
391391
$scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), '20100707' );
392392
$scripts->add_data( 'inline-edit-post', 'group', 1 );
393393
$scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(

0 commit comments

Comments
 (0)