1
|
(function($) {
|
2
|
|
3
|
Drupal.behaviors.moduleFilterUpdateStatus = {
|
4
|
attach: function(context) {
|
5
|
$('#module-filter-update-status-form').once('update-status', function() {
|
6
|
var filterInput = $('input[name="module_filter[name]"]', context);
|
7
|
filterInput.moduleFilter('table.update > tbody > tr', {
|
8
|
wrapper: $('table.update:first').parent(),
|
9
|
delay: 300,
|
10
|
childSelector: 'div.project a',
|
11
|
rules: [
|
12
|
function(moduleFilter, item) {
|
13
|
switch (moduleFilter.options.show) {
|
14
|
case 'all':
|
15
|
return true;
|
16
|
case 'updates':
|
17
|
if (item.state == 'warning' || item.state == 'error') {
|
18
|
return true;
|
19
|
}
|
20
|
break;
|
21
|
case 'security':
|
22
|
if (item.state == 'error') {
|
23
|
return true;
|
24
|
}
|
25
|
break;
|
26
|
case 'ignore':
|
27
|
if (item.state == 'ignored') {
|
28
|
return true;
|
29
|
}
|
30
|
break;
|
31
|
case 'unknown':
|
32
|
if (item.state == 'unknown') {
|
33
|
return true;
|
34
|
}
|
35
|
break;
|
36
|
}
|
37
|
return false;
|
38
|
}
|
39
|
],
|
40
|
buildIndex: [
|
41
|
function(moduleFilter, item) {
|
42
|
if ($('.version-status', item.element).text() == Drupal.t('Ignored from settings')) {
|
43
|
item.state = 'ignored';
|
44
|
return item;
|
45
|
}
|
46
|
if (item.element.is('.ok')) {
|
47
|
item.state = 'ok';
|
48
|
}
|
49
|
else if (item.element.is('.warning')) {
|
50
|
item.state = 'warning';
|
51
|
}
|
52
|
else if (item.element.is('.error')) {
|
53
|
item.state = 'error';
|
54
|
}
|
55
|
else if (item.element.is('.unknown')) {
|
56
|
item.state = 'unknown';
|
57
|
}
|
58
|
return item;
|
59
|
}
|
60
|
],
|
61
|
show: $('#edit-module-filter-show input[name="module_filter[show]"]', context).val()
|
62
|
});
|
63
|
|
64
|
var moduleFilter = filterInput.data('moduleFilter');
|
65
|
|
66
|
if (Drupal.settings.moduleFilter.rememberUpdateState) {
|
67
|
var updateShow = Drupal.ModuleFilter.getState('updateShow');
|
68
|
if (updateShow) {
|
69
|
moduleFilter.options.show = updateShow;
|
70
|
$('#edit-module-filter-show input[name="module_filter[show]"][value="' + updateShow + '"]', context).click();
|
71
|
}
|
72
|
}
|
73
|
|
74
|
$('#edit-module-filter-show input[name="module_filter[show]"]', context).change(function() {
|
75
|
moduleFilter.options.show = $(this).val();
|
76
|
Drupal.ModuleFilter.setState('updateShow', moduleFilter.options.show);
|
77
|
moduleFilter.applyFilter();
|
78
|
});
|
79
|
|
80
|
moduleFilter.element.bind('moduleFilter:start', function() {
|
81
|
$('.overflow-fix').has('table.update').each(function() {
|
82
|
$(this).show().prev('h3').show();
|
83
|
});
|
84
|
});
|
85
|
|
86
|
moduleFilter.element.bind('moduleFilter:finish', function(e, data) {
|
87
|
$('.overflow-fix').has('table.update').each(function() {
|
88
|
var $table = $(this);
|
89
|
if ($('tbody tr', $(this)).filter(':visible').length == 0) {
|
90
|
$table.hide().prev('h3').hide();
|
91
|
}
|
92
|
});
|
93
|
});
|
94
|
|
95
|
moduleFilter.element.bind('moduleFilter:keyup', function() {
|
96
|
if (moduleFilter.clearOffset == undefined) {
|
97
|
moduleFilter.inputWidth = filterInput.width();
|
98
|
moduleFilter.clearOffset = moduleFilter.element.parent().find('.module-filter-clear a').width();
|
99
|
}
|
100
|
if (moduleFilter.text) {
|
101
|
filterInput.width(moduleFilter.inputWidth - moduleFilter.clearOffset - 5).parent().css('margin-right', moduleFilter.clearOffset + 5);
|
102
|
}
|
103
|
else {
|
104
|
filterInput.width(moduleFilter.inputWidth).parent().css('margin-right', 0);
|
105
|
}
|
106
|
});
|
107
|
|
108
|
moduleFilter.element.parent().find('.module-filter-clear a').click(function() {
|
109
|
filterInput.width(moduleFilter.inputWidth).parent().css('margin-right', 0);
|
110
|
});
|
111
|
|
112
|
moduleFilter.applyFilter();
|
113
|
});
|
114
|
}
|
115
|
};
|
116
|
|
117
|
})(jQuery);
|