diff --git a/clientapp/app.js b/clientapp/app.js index 08ce27d..b51150f 100644 --- a/clientapp/app.js +++ b/clientapp/app.js @@ -66,6 +66,12 @@ module.exports = { self.api.connect(); }, function (cb) { + function start() { + // start our router and show the appropriate page + app.history.start({pushState: true, root: '/'}); + cb(); + } + new Router(); app.history = Backbone.history; @@ -75,9 +81,11 @@ module.exports = { }); self.view.render(); - // we have what we need, we can now start our router and show the appropriate page - app.history.start({pushState: true, root: '/'}); - cb(); + if (me.contacts.length) { + start(); + } else { + me.contacts.once('loaded', start); + } } ]); }, diff --git a/clientapp/models/me.js b/clientapp/models/me.js index 075f801..dfb9b1e 100644 --- a/clientapp/models/me.js +++ b/clientapp/models/me.js @@ -97,6 +97,8 @@ module.exports = HumanModel.define({ contact.save(); self.contacts.add(contact); }); + + self.contacts.trigger('loaded'); }); }, isMe: function (jid) { diff --git a/clientapp/pages/chat.js b/clientapp/pages/chat.js index d70833f..96bd59e 100644 --- a/clientapp/pages/chat.js +++ b/clientapp/pages/chat.js @@ -26,7 +26,8 @@ module.exports = BasePage.extend(chatHelpers).extend({ }, events: { 'keydown textarea': 'handleKeyDown', - 'keyup textarea': 'handleKeyUp' + 'keyup textarea': 'handleKeyUp', + 'click .call': 'handleCallClick' }, srcBindings: { avatar: 'header .avatar' @@ -62,6 +63,7 @@ module.exports = BasePage.extend(chatHelpers).extend({ this.$scrollContainer = this.$messageList; this.listenTo(this.model.messages, 'add', this.handleChatAdded); + this.listenToAndRun(this.model, 'change:jingleResources', this.handleJingleResourcesChanged); this.renderCollection(); @@ -78,6 +80,10 @@ module.exports = BasePage.extend(chatHelpers).extend({ handlePageUnloaded: function () { this.scrollPageUnload(); }, + handleCallClick: function () { + this.model.call(); + return false; + }, renderCollection: function () { var self = this; var previous; @@ -181,6 +187,10 @@ module.exports = BasePage.extend(chatHelpers).extend({ var existing = this.$('#chat' + model.cid); existing.replaceWith(model.partialTemplateHtml); }, + handleJingleResourcesChanged: function (model, val) { + var resources = val || this.model.jingleResources; + this.$('button.call').prop('disabled', !resources.length); + }, appendModel: function (model, preload) { var self = this; var isGrouped = model.shouldGroupWith(this.lastModel); diff --git a/clientapp/templates.js b/clientapp/templates.js index 0c8123c..c2b0ad7 100644 --- a/clientapp/templates.js +++ b/clientapp/templates.js @@ -160,7 +160,7 @@ exports.misc.growlMessage = function anonymous(locals) { exports.pages.chat = function anonymous(locals) { var buf = []; with (locals || {}) { - buf.push('

'); + buf.push('

'); } return buf.join(""); }; diff --git a/clientapp/templates/pages/chat.jade b/clientapp/templates/pages/chat.jade index 4d45522..aed9795 100644 --- a/clientapp/templates/pages/chat.jade +++ b/clientapp/templates/pages/chat.jade @@ -4,6 +4,7 @@ section.page.chat img.avatar h1.name .tzo + button.call call ul.messages.scroll-container .chatBox form diff --git a/package.json b/package.json index 84f09c8..d05f204 100644 --- a/package.json +++ b/package.json @@ -13,13 +13,13 @@ "express": "3.3.7", "getconfig": "0.0.5", "jade": "0.35.0", - "moonboots": "0.4.1", + "moonboots": "0.7.0", "helmet": "0.1.0", "node-uuid": "1.4.1", "semi-static": "0.0.4", "sound-effect-manager": "0.0.5", "human-model": "1.4.0", - "human-view": "1.1.2", + "human-view": "1.2.0", "templatizer": "0.1.2", "underscore": "1.5.1", "raf-component": "1.1.1", diff --git a/public/x-manifest.cache b/public/x-manifest.cache index 9f8d00b..d907103 100644 --- a/public/x-manifest.cache +++ b/public/x-manifest.cache @@ -1,5 +1,5 @@ CACHE MANIFEST -# 0.0.1 1381784954237 +# 0.0.1 1381790561081 CACHE: /app.js