forked from JesperDramsch/python-deadlines
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiselect_handler.js
More file actions
50 lines (50 loc) · 1.44 KB
/
Copy pathmultiselect_handler.js
File metadata and controls
50 lines (50 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Multi-select handler
$('#subject-select').multiselect({
includeSelectAllOption: true,
numberDisplayed: 5,
onChange: function (option, checked, select) {
var csub = $(option).val();
if (checked == true) {
if (subs.indexOf(csub) < 0) subs.push(csub);
} else {
var idx = subs.indexOf(csub);
if (idx >= 0) subs.splice(idx, 1);
// In case a conf with multiple types (including this type) is wrongly hid, show all confs with at least one checked type.
for (var i = 0; i < subs.length; i++) {
// $('.' + subs[i] + '-conf').show();
}
}
update_filtering({ subs: subs, all_subs: all_subs });
},
onSelectAll: function (options) {
subs = all_subs;
update_filtering({ subs: subs, all_subs: all_subs });
},
onDeselectAll: function (options) {
subs = [];
update_filtering({ subs: subs, all_subs: all_subs });
},
buttonText: function (options, select) {
if (options.length === 0) {
return '{% t buttons.none_selected %}';
} else if (options.length === select.children('option').length) {
return '{% t buttons.all_selected %}';
} else {
var labels = [];
options.each(function () {
if ($(this).attr('value') !== undefined) {
labels.push($(this).attr('value').slice(0, 3));
} else {
labels.push($(this).html());
}
});
return labels.join(', ') + '';
}
},
buttonTitle: function (options, select) {
return '';
},
optionClass: function (element) {
return $(element).val() + '-select';
},
});