1 _kiwi
.model
.NewConnection
= Backbone
.Collection
.extend({
2 initialize: function() {
3 this.view
= new _kiwi
.view
.ServerSelect();
5 this.view
.bind('server_connect', this.onMakeConnection
, this);
10 onMakeConnection: function(new_connection_event
) {
13 auto_connect_details
= new_connection_event
;
15 this.view
.networkConnecting();
18 _kiwi
.gateway
.set('kiwi_server', _kiwi
.app
.kiwi_server
);
19 _kiwi
.gateway
.connect(function() {
20 that
.makeConnection(new_connection_event
);
27 onKiwiServerNotFound: function() {
28 this.view
.showError();
32 makeConnection: function(new_connection_event
) {
35 this.connect_details
= new_connection_event
;
37 _kiwi
.gateway
.newConnection({
38 nick
: new_connection_event
.nick
,
39 host
: new_connection_event
.server
,
40 port
: new_connection_event
.port
,
41 ssl
: new_connection_event
.ssl
,
42 password
: new_connection_event
.password
,
43 options
: new_connection_event
.options
44 }, function(err
, network
) {
45 that
.onNewNetwork(err
, network
);
50 onNewNetwork: function(err
, network
) {
51 // Show any errors if given
53 this.view
.showError(err
);
56 if (network
&& this.connect_details
) {
58 channel
: this.connect_details
.channel
,
59 key
: this.connect_details
.channel_key
64 // Show the server panel if this is our first network
65 if (network
&& network
.get('connection_id') === 0) {
66 network
.panels
.server
.view
.show();