1 |
85ad3d82
|
Assos Assos
|
|
2 |
|
|
(function ($) {
|
3 |
|
|
var moduleFilterTimeOut;
|
4 |
|
|
var moduleFilterTextFilter = '';
|
5 |
|
|
|
6 |
|
|
Drupal.behaviors.moduleFilter = {
|
7 |
|
|
attach: function() {
|
8 |
|
|
$("#module-filter-wrapper").show();
|
9 |
|
|
$('input[name="module_filter[name]"]').focus();
|
10 |
|
|
$('input[name="module_filter[name]"]').keyup(function(e) {
|
11 |
|
|
switch (e.which) {
|
12 |
|
|
case 13:
|
13 |
|
|
if (moduleFilterTimeOut) {
|
14 |
|
|
clearTimeout(moduleFilterTimeOut);
|
15 |
|
|
}
|
16 |
|
|
|
17 |
|
|
moduleFilter(moduleFilterTextFilter);
|
18 |
|
|
break;
|
19 |
|
|
default:
|
20 |
|
|
if (moduleFilterTextFilter != $(this).val()) {
|
21 |
|
|
moduleFilterTextFilter = this.value;
|
22 |
|
|
if (moduleFilterTimeOut) {
|
23 |
|
|
clearTimeout(moduleFilterTimeOut);
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
moduleFilterTimeOut = setTimeout('moduleFilter("' + moduleFilterTextFilter + '")', 500);
|
27 |
|
|
}
|
28 |
|
|
break;
|
29 |
|
|
}
|
30 |
|
|
});
|
31 |
|
|
$('input[name="module_filter[name]"]').keypress(function(e) {
|
32 |
|
|
if (e.which == 13) e.preventDefault();
|
33 |
|
|
});
|
34 |
|
|
|
35 |
|
|
$('#edit-module-filter-show-enabled').change(function() {
|
36 |
|
|
moduleFilter($('input[name="module_filter[name]"]').val());
|
37 |
|
|
});
|
38 |
|
|
$('#edit-module-filter-show-disabled').change(function() {
|
39 |
|
|
moduleFilter($('input[name="module_filter[name]"]').val());
|
40 |
|
|
});
|
41 |
|
|
$('#edit-module-filter-show-required').change(function() {
|
42 |
|
|
moduleFilter($('input[name="module_filter[name]"]').val());
|
43 |
|
|
});
|
44 |
|
|
$('#edit-module-filter-show-unavailable').change(function() {
|
45 |
|
|
moduleFilter($('input[name="module_filter[name]"]').val());
|
46 |
|
|
});
|
47 |
|
|
}
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
moduleFilter = function(string) {
|
51 |
|
|
stringLowerCase = string.toLowerCase();
|
52 |
|
|
|
53 |
|
|
$("fieldset table tbody tr td label strong").each(function(i) {
|
54 |
|
|
var $row = $(this).parents('tr');
|
55 |
|
|
var module = $(this).text();
|
56 |
|
|
var moduleLowerCase = module.toLowerCase();
|
57 |
|
|
var $fieldset = $row.parents('fieldset');
|
58 |
|
|
|
59 |
|
|
if (string != '') {
|
60 |
|
|
if ($fieldset.hasClass('collapsed')) {
|
61 |
|
|
$fieldset.removeClass('collapsed');
|
62 |
|
|
}
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
if (moduleLowerCase.match(stringLowerCase)) {
|
66 |
|
|
if (moduleFilterVisible($('td.checkbox input', $row))) {
|
67 |
|
|
if (!$row.is(':visible')) {
|
68 |
|
|
$row.show();
|
69 |
|
|
if ($fieldset.hasClass('collapsed')) {
|
70 |
|
|
$fieldset.removeClass('collapsed');
|
71 |
|
|
}
|
72 |
|
|
if (!$fieldset.is(':visible')) {
|
73 |
|
|
$fieldset.show();
|
74 |
|
|
}
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
|
|
else {
|
78 |
|
|
$row.hide();
|
79 |
|
|
if ($row.siblings(':visible').html() == null) {
|
80 |
|
|
$fieldset.hide();
|
81 |
|
|
}
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
else {
|
85 |
|
|
if ($row.is(':visible')) {
|
86 |
|
|
$row.hide();
|
87 |
|
|
if ($row.siblings(':visible').html() == null) {
|
88 |
|
|
$fieldset.hide();
|
89 |
|
|
}
|
90 |
|
|
}
|
91 |
|
|
}
|
92 |
|
|
});
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
moduleFilterVisible = function(checkbox) {
|
96 |
|
|
if (checkbox.length > 0) {
|
97 |
|
|
if ($('#edit-module-filter-show-enabled').is(':checked')) {
|
98 |
|
|
if ($(checkbox).is(':checked') && !$(checkbox).is(':disabled')) {
|
99 |
|
|
return true;
|
100 |
|
|
}
|
101 |
|
|
}
|
102 |
|
|
if ($('#edit-module-filter-show-disabled').is(':checked')) {
|
103 |
|
|
if (!$(checkbox).is(':checked') && !$(checkbox).is(':disabled')) {
|
104 |
|
|
return true;
|
105 |
|
|
}
|
106 |
|
|
}
|
107 |
|
|
if ($('#edit-module-filter-show-required').is(':checked')) {
|
108 |
|
|
if ($(checkbox).is(':checked') && $(checkbox).is(':disabled')) {
|
109 |
|
|
return true;
|
110 |
|
|
}
|
111 |
|
|
}
|
112 |
|
|
}
|
113 |
|
|
if ($('#edit-module-filter-show-unavailable').is(':checked')) {
|
114 |
|
|
if (checkbox.length == 0 || ($(checkbox).size() > 0 && !$(checkbox).is(':checked') && $(checkbox).is(':disabled'))) {
|
115 |
|
|
return true;
|
116 |
|
|
}
|
117 |
|
|
}
|
118 |
|
|
return false;
|
119 |
|
|
}
|
120 |
|
|
})(jQuery); |