Add server + client versions to CTCP VERSION reply
[KiwiIRC.git] / client / src / views / nickchangebox.js
1 _kiwi.view.NickChangeBox = Backbone.View.extend({
2 events: {
3 'submit': 'changeNick',
4 'click .cancel': 'close'
5 },
6
7 initialize: function () {
8 var text = {
9 new_nick: _kiwi.global.i18n.translate('client_views_nickchangebox_new').fetch(),
10 change: _kiwi.global.i18n.translate('client_views_nickchangebox_change').fetch(),
11 cancel: _kiwi.global.i18n.translate('client_views_nickchangebox_cancel').fetch()
12 };
13 this.$el = $(_.template($('#tmpl_nickchange').html().trim(), text));
14 },
15
16 render: function () {
17 // Add the UI component and give it focus
18 _kiwi.app.controlbox.$el.prepend(this.$el);
19 this.$el.find('input').focus();
20
21 this.$el.css('bottom', _kiwi.app.controlbox.$el.outerHeight(true));
22 },
23
24 close: function () {
25 this.$el.remove();
26 this.trigger('close');
27 },
28
29 changeNick: function (event) {
30 event.preventDefault();
31
32 var connection = _kiwi.app.connections.active_connection;
33 this.listenTo(connection, 'change:nick', function() {
34 this.close();
35 });
36
37 connection.gateway.changeNick(this.$('input').val());
38 }
39 });