blob: ae9d7d897b3809f9906b55f36883ff9d50ae4347 (
plain)
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
51
|
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
/*
* Aspects view for the publishers aspect dropdown and the aspect membership dropdown.
*/
app.views.AspectsDropdown = app.views.Base.extend({
_toggleCheckbox: function(target) {
this.$('.dropdown-menu > li.radio').removeClass('selected');
target.toggleClass('selected');
},
_toggleRadio: function(target) {
this.$('.dropdown-menu > li').removeClass('selected');
target.toggleClass('selected');
},
// select aspects in the dropdown by a given list of ids
_selectAspects: function(ids) {
this.$('.dropdown-menu > li').each(function() {
var el = $(this);
if (_.contains(ids, el.data('aspect_id'))) {
el.addClass('selected');
} else {
el.removeClass('selected');
}
});
},
// change class and text of the dropdown button
_updateButton: function(inAspectClass) {
var button = this.$('.btn.dropdown-toggle'),
selectedAspects = this.$(".dropdown-menu > li.selected").length,
buttonText;
if (selectedAspects === 0) {
button.removeClass(inAspectClass).addClass('btn-default');
buttonText = Diaspora.I18n.t("aspect_dropdown.select_aspects");
} else {
button.removeClass('btn-default').addClass(inAspectClass);
if (selectedAspects === 1) {
buttonText = this.$(".dropdown-menu > li.selected .text").first().text();
} else {
buttonText = Diaspora.I18n.t("aspect_dropdown.toggle", { count: selectedAspects.toString() });
}
}
button.find('.text').text(buttonText);
}
});
// @license-end
|