? .DS_Store ? sites/.DS_Store ? sites/default/settings.php Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.554 diff -u -p -r1.554 theme.inc --- includes/theme.inc 26 Nov 2009 18:57:16 -0000 1.554 +++ includes/theme.inc 30 Nov 2009 12:42:06 -0000 @@ -1659,6 +1659,11 @@ function theme_table($variables) { $attributes['class'][] = 'sticky-enabled'; } + // Attach tablefilter behavior, if required. + if (isset($attributes['class']) && in_array('tablefilter', $attributes['class'])) { + drupal_add_js('misc/tablefilter.js'); + } + $output = '\n"; if (isset($caption)) { Index: misc/tablefilter.js =================================================================== RCS file: misc/tablefilter.js diff -N misc/tablefilter.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ misc/tablefilter.js 30 Nov 2009 12:42:06 -0000 @@ -0,0 +1,174 @@ +// $Id$ + +(function ($) { + +// Create an object on which each instance of the tableFilter object will be applied to. +Drupal.tablefilters = {}; + +/** + * The tableFilter object. + */ +Drupal.tableFilter = function (container, settings) { + this.settings = settings; + this.container = (container.is('form') ? container.children('div') : container); + + // Create the filter textfield. + this.createTextfield(); +}; + + +/** + * Creates an input textfield inside the container. + */ +Drupal.tableFilter.prototype.createTextfield = function () { + var self = this; + this.container.prepend(Drupal.theme('textfield', this.settings)); + this.textfield = $('#edit-' + this.settings.name, this.container).bind('click keyup', function () { + self.filter(self.container, $.trim($(this).val().toLowerCase())); + }); + + if (this.textfield[0]) { + this.textfield[0].type = 'search'; + this.textfield.attr('results', 5); + }; +}; + +/** + * Adds a DOM element after the textfield element and displays a 'no results' message. + */ +Drupal.tableFilter.prototype.addPlaceholder = function () { + if (!this.container.find('.tablefilter-no-results').length) { + this.textfield.closest('.form-item').after($('

').text(this.settings.empty)); + }; +}; + +/** + * Removes the 'no results' message. + */ +Drupal.tableFilter.prototype.removePlaceholder = function () { + this.container.find('.tablefilter-no-results').remove(); +}; + +/** + * Filters all affected table rows for the given string. + * All table row containing the string will stay visible, + * while other rows are hidden. + */ +Drupal.tableFilter.prototype.filter = function (container, string) { + + // Keep track of whether or not we'll find any results. + var results = false; + + // Walk through each tbody inside the container element. + container.find('tbody').each(function () { + var num_trs = $('tr', this).size(); + var zebra = 'even'; + + // Walk through each tr inside the current tbody element. + $(this).find('tr').each(function () { + str_exists = false; + + // Walk through each td inside the current tr element. + $(this).find('td').each(function () { + // Check whether or not the string exists in the current td. + if ($(this).text().toLowerCase().indexOf(string) > -1) { + // The string is found. + str_exists = true; + results = true; + }; + }); + // If the variable string_exists returns true, the string exists in the current tr. + if (!str_exists) { + num_trs--; + $(this).removeClass('tablefilter-match').addClass('tablefilter-irrelevant').hide(); + } + else { + num_trs++; + zebra = (zebra == 'odd' ? 'even' : 'odd'); + $(this).removeClass('tablefilter-irrelevant odd even').addClass('tablefilter-match ' + (zebra)).show(); + }; + }); + // If the matched tr's equals 0, hide its parent container. + if (num_trs == 0) { + $(this).parents('table, .tablefilter-group').hide(); + } + else { + $(this).parents('table, .tablefilter-group').show(); + }; + }); + + // If any results are found, remove the 'no results' message. + // Otherwise dipslay the 'no results message. + if (results) { + this.removePlaceholder(); + } + else { + this.addPlaceholder(); + }; + + // Allow other scripts to interact with this event. + container.trigger('tablefilter'); +}; + +/** + * Attaches the tablefilter bahavior to Drupal behaviours. + */ +Drupal.behaviors.tablefilter = { + attach: function (context) { + + // Avoid the behavior being attached more than once to this dom element. + $('.tablefilter', context).once('tablefilter-processed', function () { + + // Create an unique identifier for the new tablefilter instance. + window.table_filter_index = (window.table_filter_index == undefined ? 0 : window.table_filter_index + 1); + + // Specify which element is the container of the table(s) on which to apply the behavior. + // This can either be the parent element of an table or a parent element with classname 'tablefilter-container'. + var container = ($(this).parents('.tablefilter-container').size() > 0 ? $(this).parents('.tablefilter-container') : $(this).parent()); + + // If the container hasn't got an ID, create one + if (!container.attr('id')) { + container.attr('id', 'tablefilter-' + window.table_filter_index); + }; + + // Create a default setting object. + var settings = { + 'label': Drupal.t('Filter'), + 'description': Drupal.t('Enter text to filter the table below.'), + 'empty': Drupal.t('There were no results.'), + 'name': 'tablefilter-' + window.table_filter_index + }; + + // Allow other scripts to overwrite the settings object. + if (Drupal.settings && Drupal.settings.tablefilter && Drupal.settings.tablefilter[settings.id]) { + for (var i in Drupal.settings.tablefilter[settings.id]) { + settings[i] = Drupal.settings.tablefilter[settings.id][i]; + }; + }; + + // Create a new instance of the tableFilter object and initialize the instance. + if (!Drupal.tablefilters[settings.id]) { + Drupal.tablefilters[settings.id] = new Drupal.tableFilter(container, settings); + }; + }); + } +}; + +/** + * Theme an input textfield + */ +Drupal.theme.textfield = function (element) { + var output = ''; + if (element.label) { + output += ''; + }; + output += ''; + + if (element.description) { + output += '
' + element.description + '
'; + }; + + return '
' + output + '
'; +}; + +})(jQuery); Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.228 diff -u -p -r1.228 system.admin.inc --- modules/system/system.admin.inc 26 Nov 2009 05:54:48 -0000 1.228 +++ modules/system/system.admin.inc 30 Nov 2009 12:42:07 -0000 @@ -776,6 +776,7 @@ function system_modules($form, $form_sta '#title' => t($package), '#collapsible' => TRUE, '#theme' => 'system_modules_fieldset', + '#attributes' => array('class' => array('tablefilter-group')), '#header' => array( array('data' => t('Enabled'), 'class' => array('checkbox')), t('Name'), @@ -791,7 +792,15 @@ function system_modules($form, $form_sta '#value' => t('Save configuration'), ); $form['#action'] = url('admin/config/modules/list/confirm'); - + $form['#attributes']['class'] = 'tablefilter-container'; + $form['#attached'] = array( + 'js' => array( + array( + 'data' => array('tablefilter' => array('system-modules' => array('label' => t('Filter modules'), 'description' => t('Enter the name of a module to filter the list.')))), + 'type' => 'setting' + ), + ), + ); return $form; } @@ -2347,7 +2356,7 @@ function theme_system_modules_fieldset($ $rows[] = $row; } - return theme('table', array('header' => $form['#header'], 'rows' => $rows)); + return theme('table', array('header' => $form['#header'], 'rows' => $rows, 'attributes' => array('class' => array('tablefilter')))); } /** Index: modules/user/user.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v retrieving revision 1.90 diff -u -p -r1.90 user.admin.inc --- modules/user/user.admin.inc 28 Nov 2009 21:44:54 -0000 1.90 +++ modules/user/user.admin.inc 30 Nov 2009 12:42:07 -0000 @@ -744,7 +744,7 @@ function theme_user_admin_permissions($v $header[] = array('data' => drupal_render($form['role_names'][$rid]), 'class' => array('checkbox')); } $output = theme('system_compact_link'); - $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions'))); + $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions', 'class' => array('tablefilter')))); $output .= drupal_render_children($form); return $output; }