<?php
/*
Plugin Name: Plugin Filter
Description: Filter dem plugins
Version:     1.2
Author:      John Blackbourn
Author URI:  http://lud.icro.us/

© 2012 John Blackbourn

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

*/

class PluginFilterPlugin {

	function __construct() {

		add_action( 'admin_head-plugins.php', array( $this, 'output' ) );

	}

	function output() {
		?>
		<script type="text/javascript">

			(function($){

				// Case-insensitive version of :contains()
				$.expr[':'].icontains = function( obj, index, meta, stack ) {

					return (
						obj.textContent ||
						obj.innerText ||
						$(obj).text() ||
						''
					).toLowerCase().indexOf(meta[3].toLowerCase()) >= 0;

				};

			})(jQuery);

			jQuery(function($){

				var tr = $('#the-list').find('tr');

				$('#plugin-search-input').focus().bind('keyup change blur input',function(e){

					if ( $(this).val() )
						tr.hide().filter(':icontains("' + $(this).val() + '")').show();
					else
						tr.show();

				});


			});

		</script>
		<?php
	}

}

if ( !defined( 'ABSPATH' ) )
    die();

$pluginfilterplugin = new PluginFilterPlugin;
