Thanks for great module! I've ocassionally created the clone of this module, and then I found 'module_filter'. I don't want to maintain the module with same functionality, but I think that may be my javascript code can help you a bit. It is more 'jquery-like'. You may see that the 'filtering' process is ~2 times shorter then yours.


// :contains jquery selector is case sensitive. here is new selector for case-insensitive :contains. comment out these lines and unsomment the lines below if using jQuery 1.3
jQuery.extend(jQuery.expr[':'], {
    containsNC :
"jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
  });
  

// $.extend($.expr[":"], {  
//     "containsNC": function(elem, i, match, array) {  
//         return (elem.textContent || elem.innerText || "").toLowerCase  
// ().indexOf((match[3] || "").toLowerCase()) >= 0;  
//     }  
// });

   
  
// :visible selector returns false positive in 1.2.6 if element is hidden because its parent is hidden. so we have to implement new selector.  Comment out if using jQuery 1.3
jQuery.extend(
  jQuery.expr[ ":" ], 
  { reallyvisible : function (a) { return !(jQuery(a).is(':hidden') || jQuery(a).parents(':hidden').length); }}
);  
  
$(function(){
  var $form = $('form#system-modules');
 $('<input type="text"/><div class="description">Find modules quickly by typing module name</div>').keyup(function(event){ 
  var searchText = $(event.currentTarget).val();
  $("table.package tbody td strong label:containsNC('" + searchText + "')", $form).each(function() {
    $(this).parents('tr').show();
  }); 
  
  $("table.package tbody td strong label").not(":containsNC('" + searchText + "')", $form).each(function() {
    $(this).parents('tr').hide();
  }); 
  
  // hide fieldsets, that doesn't contain any visible rows
  $("fieldset", $form).each( function() {
    $(this).show();
    
    if ($('table.package tbody td strong label:reallyvisible', this).length == 0) {
      $(this).hide();
    }
  } );
  
 }).prependTo($form);
});

Comments

picardo’s picture

Kickass. Great idea with extending jQuery's contains filter. I'm going to test this out next chance I get. But I found that the greatest slowdown is happening when the script is unhiding a whole lot of items. That's probably because the script is using css() method to set the display attribute to table-row in order to unhide an item. So it's going from display:none to display: table-row. I wonder if the performance would be improved if it just removed the style attribute, instead.

andypost’s picture

subscribe

greenSkin’s picture

Status: Active » Closed (outdated)