From c891b0ebc77d5d4c630e9f23042420662b40caf9 Mon Sep 17 00:00:00 2001 From: scribu Date: Tue, 23 Nov 2010 20:17:22 +0000 Subject: [PATCH] Ajaxify theme feature filter. Props ocean90 for initial patch. See #14936 git-svn-id: http://svn.automattic.com/wordpress/trunk@16553 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/theme.dev.js | 21 ++++++++++++++++++--- wp-admin/js/theme.js | 2 +- wp-admin/themes.php | 8 ++++---- wp-includes/script-loader.php | 20 ++++++++++---------- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/wp-admin/js/theme.dev.js b/wp-admin/js/theme.dev.js index 420cdb9c45..d9d10dcd88 100644 --- a/wp-admin/js/theme.dev.js +++ b/wp-admin/js/theme.dev.js @@ -4,7 +4,7 @@ var ThemeViewer; ThemeViewer = function( args ) { function filter_count() { - var count = $( '#filters :checked' ).length; + var count = $( '#filter-box :checked' ).length; var text = $( '#filter-click' ).text(); if ( text.indexOf( '(' ) != -1 ) @@ -19,14 +19,29 @@ var ThemeViewer; function init() { $( '#filter-click, #mini-filter-click' ).unbind( 'click' ).click( function() { $( '#filter-click' ).toggleClass( 'current' ); - $( '#filters' ).slideToggle(); + $( '#filter-box' ).slideToggle(); $( '#current-theme' ).slideToggle( 300 ); return false; }); - $( '#filters :checkbox' ).unbind( 'click' ).click( function() { + $( '#filter-box :checkbox' ).unbind( 'click' ).click( function() { filter_count(); }); + + $('#filter-box :submit').unbind( 'click' ).click(function() { + var features = []; + $('#filter-box :checked').each(function() { + features.push($(this).val()); + }); + + listTable.update_rows({'features': features}, true, function() { + $( '#filter-click' ).toggleClass( 'current' ); + $( '#filter-box' ).slideToggle(); + $( '#current-theme' ).slideToggle( 300 ); + }); + + return false; + }); } // These are the functions we expose diff --git a/wp-admin/js/theme.js b/wp-admin/js/theme.js index d11e1469f3..5d81fc6be0 100644 --- a/wp-admin/js/theme.js +++ b/wp-admin/js/theme.js @@ -1 +1 @@ -var ThemeViewer;(function(a){ThemeViewer=function(b){function d(){var f=a("#filters :checked").length;var g=a("#filter-click").text();if(g.indexOf("(")!=-1){g=g.substr(0,g.indexOf("("))}if(f==0){a("#filter-click").text(g)}else{a("#filter-click").text(g+" ("+f+")")}}function e(){a("#filter-click, #mini-filter-click").unbind("click").click(function(){a("#filter-click").toggleClass("current");a("#filters").slideToggle();a("#current-theme").slideToggle(300);return false});a("#filters :checkbox").unbind("click").click(function(){d()})}var c={init:e};return c}})(jQuery);jQuery(document).ready(function(a){theme_viewer=new ThemeViewer();theme_viewer.init()}); \ No newline at end of file +var ThemeViewer;(function(a){ThemeViewer=function(b){function d(){var f=a("#filter-box :checked").length;var g=a("#filter-click").text();if(g.indexOf("(")!=-1){g=g.substr(0,g.indexOf("("))}if(f==0){a("#filter-click").text(g)}else{a("#filter-click").text(g+" ("+f+")")}}function e(){a("#filter-click, #mini-filter-click").unbind("click").click(function(){a("#filter-click").toggleClass("current");a("#filter-box").slideToggle();a("#current-theme").slideToggle(300);return false});a("#filter-box :checkbox").unbind("click").click(function(){d()});a("#filter-box :submit").unbind("click").click(function(){var f=[];a("#filter-box :checked").each(function(){f.push(a(this).val())});listTable.update_rows({features:f},true,function(){a("#filter-click").toggleClass("current");a("#filter-box").slideToggle();a("#current-theme").slideToggle(300)});return false})}var c={init:e};return c}})(jQuery);jQuery(document).ready(function(a){theme_viewer=new ThemeViewer();theme_viewer.init()}); \ No newline at end of file diff --git a/wp-admin/themes.php b/wp-admin/themes.php index 80d969c47a..9bb32ef10b 100644 --- a/wp-admin/themes.php +++ b/wp-admin/themes.php @@ -129,7 +129,7 @@ if ( ! current_user_can( 'switch_themes' ) ) { ?>

-
+