2013-09-16 14:16:47 -04:00
|
|
|
/*global $, app, me, client*/
|
2013-08-29 23:38:28 -04:00
|
|
|
"use strict";
|
|
|
|
|
2013-09-03 22:18:31 -04:00
|
|
|
var HumanView = require('human-view');
|
2013-08-29 23:38:28 -04:00
|
|
|
var templates = require('../templates');
|
|
|
|
var ContactListItem = require('../views/contactListItem');
|
2013-09-16 19:12:00 -04:00
|
|
|
var MUCListItem = require('../views/mucListItem');
|
2013-08-29 23:38:28 -04:00
|
|
|
|
|
|
|
|
2013-09-03 22:18:31 -04:00
|
|
|
module.exports = HumanView.extend({
|
2013-08-29 23:38:28 -04:00
|
|
|
template: templates.body,
|
2013-09-27 12:47:54 -04:00
|
|
|
initialize: function () {
|
|
|
|
this.listenTo(app.state, 'change:title', this.handleTitle);
|
2013-10-14 17:02:05 -04:00
|
|
|
app.desktop.updateBadge('');
|
2013-09-27 12:47:54 -04:00
|
|
|
},
|
2013-09-03 18:25:14 -04:00
|
|
|
events: {
|
2013-09-16 14:16:47 -04:00
|
|
|
'click a[href]': 'handleLinkClick',
|
|
|
|
'click .reconnect': 'handleReconnect'
|
2013-09-03 18:25:14 -04:00
|
|
|
},
|
2013-09-11 23:59:50 -04:00
|
|
|
classBindings: {
|
2013-09-12 02:53:35 -04:00
|
|
|
connected: '#connectionOverlay'
|
2013-09-11 23:59:50 -04:00
|
|
|
},
|
2013-08-29 23:38:28 -04:00
|
|
|
render: function () {
|
|
|
|
$('head').append(templates.head());
|
2013-09-13 00:28:59 -04:00
|
|
|
$('body').removeClass('aux');
|
2013-08-29 23:38:28 -04:00
|
|
|
this.renderAndBind();
|
2013-09-16 05:19:07 -04:00
|
|
|
this.renderCollection(me.contacts, ContactListItem, this.$('#roster nav'));
|
2013-09-16 19:12:00 -04:00
|
|
|
this.renderCollection(me.mucs, MUCListItem, this.$('#bookmarks nav'));
|
2013-08-29 23:38:28 -04:00
|
|
|
return this;
|
2013-09-03 18:25:14 -04:00
|
|
|
},
|
2013-09-16 14:16:47 -04:00
|
|
|
handleReconnect: function (e) {
|
|
|
|
client.connect();
|
|
|
|
},
|
2013-09-03 18:25:14 -04:00
|
|
|
handleLinkClick: function (e) {
|
|
|
|
var t = $(e.target);
|
|
|
|
var aEl = t.is('a') ? t[0] : t.closest('a')[0];
|
|
|
|
var local = window.location.host === aEl.host;
|
|
|
|
var path = aEl.pathname.slice(1);
|
|
|
|
|
|
|
|
if (local) {
|
|
|
|
e.preventDefault();
|
|
|
|
app.navigate(path);
|
|
|
|
return false;
|
|
|
|
}
|
2013-09-27 12:47:54 -04:00
|
|
|
},
|
|
|
|
handleTitle: function (e) {
|
|
|
|
document.title = app.state.title;
|
2013-10-14 17:02:05 -04:00
|
|
|
app.desktop.updateBadge(app.state.badge);
|
2013-08-29 23:38:28 -04:00
|
|
|
}
|
|
|
|
});
|