1 _kiwi
.view
.UserBox
= Backbone
.View
.extend({
3 'click .query': 'queryClick',
4 'click .info': 'infoClick',
5 'change .ignore': 'ignoreChange',
6 'click .ignore': 'ignoreClick',
7 'click .op': 'opClick',
8 'click .deop': 'deopClick',
9 'click .voice': 'voiceClick',
10 'click .devoice': 'devoiceClick',
11 'click .kick': 'kickClick',
12 'click .ban': 'banClick'
15 initialize: function () {
17 op
: _kiwi
.global
.i18n
.translate('client_views_userbox_op').fetch(),
18 de_op
: _kiwi
.global
.i18n
.translate('client_views_userbox_deop').fetch(),
19 voice
: _kiwi
.global
.i18n
.translate('client_views_userbox_voice').fetch(),
20 de_voice
: _kiwi
.global
.i18n
.translate('client_views_userbox_devoice').fetch(),
21 kick
: _kiwi
.global
.i18n
.translate('client_views_userbox_kick').fetch(),
22 ban
: _kiwi
.global
.i18n
.translate('client_views_userbox_ban').fetch(),
23 message
: _kiwi
.global
.i18n
.translate('client_views_userbox_query').fetch(),
24 info
: _kiwi
.global
.i18n
.translate('client_views_userbox_whois').fetch(),
25 ignore
: _kiwi
.global
.i18n
.translate('client_views_userbox_ignore').fetch()
27 this.$el
= $(_
.template($('#tmpl_userbox').html().trim(), text
));
30 setTargets: function (user
, channel
) {
32 this.channel
= channel
;
34 var is_ignored
= _kiwi
.app
.connections
.active_connection
.isNickIgnored(this.user
.get('nick'));
35 this.$('.ignore input').attr('checked', is_ignored
? 'checked' : false);
38 displayOpItems: function(display_items
) {
40 this.$el
.find('.if_op').css('display', 'block');
42 this.$el
.find('.if_op').css('display', 'none');
46 queryClick: function (event
) {
47 var nick
= this.user
.get('nick'),
48 panel
= _kiwi
.app
.connections
.active_connection
.panels
.getByName(nick
);
51 panel
= new _kiwi
.model
.Query({name
: nick
});
52 _kiwi
.app
.connections
.active_connection
.panels
.add(panel
);
58 infoClick: function (event
) {
59 _kiwi
.app
.controlbox
.processInput('/whois ' + this.user
.get('nick'));
62 ignoreClick: function (event
) {
63 // Stop the menubox from closing since it will not update the checkbox otherwise
64 event
.stopPropagation();
67 ignoreChange: function (event
) {
68 if ($(event
.currentTarget
).find('input').is(':checked')) {
69 _kiwi
.app
.controlbox
.processInput('/ignore ' + this.user
.get('nick'));
71 _kiwi
.app
.controlbox
.processInput('/unignore ' + this.user
.get('nick'));
75 opClick: function (event
) {
76 _kiwi
.app
.controlbox
.processInput('/mode ' + this.channel
.get('name') + ' +o ' + this.user
.get('nick'));
79 deopClick: function (event
) {
80 _kiwi
.app
.controlbox
.processInput('/mode ' + this.channel
.get('name') + ' -o ' + this.user
.get('nick'));
83 voiceClick: function (event
) {
84 _kiwi
.app
.controlbox
.processInput('/mode ' + this.channel
.get('name') + ' +v ' + this.user
.get('nick'));
87 devoiceClick: function (event
) {
88 _kiwi
.app
.controlbox
.processInput('/mode ' + this.channel
.get('name') + ' -v ' + this.user
.get('nick'));
91 kickClick: function (event
) {
92 // TODO: Enable the use of a custom kick message
93 _kiwi
.app
.controlbox
.processInput('/kick ' + this.user
.get('nick') + ' Bye!');
96 banClick: function (event
) {
97 // TODO: Set ban on host, not just on nick
98 _kiwi
.app
.controlbox
.processInput('/mode ' + this.channel
.get('name') + ' +b ' + this.user
.get('nick') + '!*');