Client: view.js split up into multiple files
[KiwiIRC.git] / client / assets / 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 this.$el = $($('#tmpl_nickchange').html());
9 },
10
11 render: function () {
12 // Add the UI component and give it focus
13 _kiwi.app.controlbox.$el.prepend(this.$el);
14 this.$el.find('input').focus();
15
16 this.$el.css('bottom', _kiwi.app.controlbox.$el.outerHeight(true));
17 },
18
19 close: function () {
20 this.$el.remove();
21
22 },
23
24 changeNick: function (event) {
25 var that = this;
26
27 event.preventDefault();
28
29 _kiwi.app.connections.active_connection.gateway.changeNick(this.$el.find('input').val(), function (err, val) {
30 that.close();
31 });
32 return false;
33 }
34 });