| | 447 | <script type="text/javascript"> |
| | 448 | ( function( $ ) { |
| | 449 | /*** |
| | 450 | * Check the dom for pagination links |
| | 451 | * This could be done better... |
| | 452 | */ |
| | 453 | var pagination = $(".pagination-links").get(0), |
| | 454 | search_input = $( "#plugin-search-input" ), |
| | 455 | plugin_wrap = $( "#the-list"), |
| | 456 | plugin_list = plugin_wrap.find( "tr" ), |
| | 457 | no_plugins_found_inserted = false, |
| | 458 | no_plugins_html = '<tr id="no-plugins-found" class="no-items"><td class="colspanchange" colspan="3">No plugins found.</td></tr>'; // No plugins needs to be translated |
| | 460 | /*** |
| | 461 | * Lisen for the user trying to input something |
| | 462 | */ |
| | 463 | search_input.on('keyup change blur', function( e ) { |
| | 464 | |
| | 465 | e.preventDefault(); |
| | 466 | |
| | 467 | var filter = search_input.val(), |
| | 468 | search_for = new RegExp( filter, "i" ), |
| | 469 | plugins_found = 0; |
| | 470 | |
| | 471 | if( pagination ) { |
| | 472 | /*** |
| | 473 | * Do a ajax request and get all the plugins but hide them from view. |
| | 474 | */ |
| | 475 | // the results should be cached for future searches. |
| | 476 | // should the results also be paginated? |
| | 477 | |
| | 478 | } |
| | 479 | |
| | 480 | plugin_list.each( function( count, plugin ) { |
| | 481 | |
| | 482 | // Only search the text inside the description and title. |
| | 483 | var search_text = $(plugin).find(".plugin-title strong").text(); |
| | 484 | search_text += $(plugin).find(".plugin-description").text(); |
| | 485 | |
| | 486 | if ( search_text.search( search_for ) < 0 ) { |
| | 487 | |
| | 488 | // check if this plugin is selected |
| | 489 | // I think it might be a good idea to keep the plugin visible if the plugin is selected. |
| | 490 | if( !$(plugin).find("input:checked").get(0) ){ |
| | 491 | $(plugin).hide(); |
| | 492 | } else { |
| | 493 | // console.log( "don't hide me" ) |
| | 494 | } |
| | 495 | |
| | 496 | } else { |
| | 497 | $(plugin).show(); |
| | 498 | plugins_found++; |
| | 499 | } |
| | 500 | |
| | 501 | } ); |
| | 502 | if( !plugins_found && !no_plugins_found_inserted) { |
| | 503 | plugin_wrap.append( no_plugins_html ); |
| | 504 | no_plugins_found_inserted = true; |
| | 505 | } else { |
| | 506 | $("#no-plugins-found").remove(); |
| | 507 | no_plugins_found_inserted = false; |
| | 508 | } |
| | 509 | }) |
| | 510 | |
| | 511 | } )( jQuery ); |
| | 512 | </script> |
| | 513 | |