1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-22 17:22:22 -05:00
This commit is contained in:
Henrik Joreteg 2013-10-15 16:22:53 -07:00
commit 4c89141357
15 changed files with 188 additions and 44 deletions

View File

@ -4,3 +4,4 @@ clientapp/helpers/htmlify.js
clientapp/libraries clientapp/libraries
clientapp/templates.js clientapp/templates.js
clientapp/.build clientapp/.build
clientapp/helpers/callbar.js

View File

@ -32,6 +32,7 @@ module.exports = {
_.extend(this, Backbone.Events); _.extend(this, Backbone.Events);
var profile = {};
async.series([ async.series([
function (cb) { function (cb) {
app.notifications = new Notify(); app.notifications = new Notify();
@ -40,16 +41,17 @@ module.exports = {
app.storage.open(cb); app.storage.open(cb);
}, },
function (cb) { function (cb) {
app.storage.rosterver.get(config.jid, function (err, ver) { app.storage.profiles.get(config.jid, function (err, res) {
if (ver) { if (res) {
config.rosterVer = ver; profile = res;
config.rosterVer = res.rosterVer;
} }
cb(); cb();
}); });
}, },
function (cb) { function (cb) {
app.state = new AppState(); app.state = new AppState();
app.me = window.me = new MeModel(); app.me = window.me = new MeModel(profile);
window.onbeforeunload = function () { window.onbeforeunload = function () {
if (app.api.sessionStarted) { if (app.api.sessionStarted) {

View File

@ -107,7 +107,7 @@ module.exports = function (client, app) {
client.getRoster(function (err, resp) { client.getRoster(function (err, resp) {
resp = resp.toJSON(); resp = resp.toJSON();
app.storage.rosterver.set(me.jid.bare, resp.roster.ver); me.rosterVer = resp.roster.ver;
_.each(resp.roster.items, function (item) { _.each(resp.roster.items, function (item) {
me.setContact(item, true); me.setContact(item, true);
@ -116,6 +116,7 @@ module.exports = function (client, app) {
var caps = client.updateCaps(); var caps = client.updateCaps();
app.storage.disco.add(caps.ver, caps.discoInfo, function () { app.storage.disco.add(caps.ver, caps.discoInfo, function () {
client.sendPresence({ client.sendPresence({
status: me.status,
caps: client.disco.caps caps: client.disco.caps
}); });
client.enableCarbons(); client.enableCarbons();
@ -129,7 +130,7 @@ module.exports = function (client, app) {
iq = iq.toJSON(); iq = iq.toJSON();
var items = iq.roster.items; var items = iq.roster.items;
app.storage.rosterver.set(me.jid.bare, iq.roster.ver); me.rosterVer = iq.roster.ver;
_.each(items, function (item) { _.each(items, function (item) {
var contact = me.getContact(item.jid); var contact = me.getContact(item.jid);

View File

@ -148,6 +148,12 @@ module.exports = HumanModel.define({
return res.supportsJingleMedia; return res.supportsJingleMedia;
}); });
} }
},
callable: {
deps: ['jingleResources'],
fn: function () {
return !!this.jingleResources.length;
}
} }
}, },
collections: { collections: {

View File

@ -11,20 +11,30 @@ var fetchAvatar = require('../helpers/fetchAvatar');
module.exports = HumanModel.define({ module.exports = HumanModel.define({
initialize: function () { initialize: function (opts) {
this.bind('change:jid', this.loadContacts, this); if (opts.avatarID) {
this.setAvatar(opts.avatarID);
}
this.bind('change:jid', this.load, this);
this.bind('change:hasFocus', function () { this.bind('change:hasFocus', function () {
this.setActiveContact(this._activeContact); this.setActiveContact(this._activeContact);
}, this); }, this);
this.calls.bind('add remove reset', this.updateActiveCalls, this); this.calls.bind('add remove reset', this.updateActiveCalls, this);
this.bind('change:avatarID', this.save, this);
this.bind('change:status', this.save, this);
this.bind('change:rosterVer', this.save, this);
this.contacts.bind('change:unreadCount', this.updateUnreadCount, this); this.contacts.bind('change:unreadCount', this.updateUnreadCount, this);
app.state.bind('change:active', this.updateIdlePresence, this); app.state.bind('change:active', this.updateIdlePresence, this);
}, },
session: { props: {
jid: ['object', true], jid: ['object', true],
status: ['string', true, ''], status: ['string', true, ''],
avatar: ['string', true, ''],
avatarID: ['string', true, ''], avatarID: ['string', true, ''],
rosterVer: ['string', true, '']
},
session: {
avatar: ['string', true, ''],
connected: ['bool', true, false], connected: ['bool', true, false],
shouldAskForAlertsPermission: ['bool', true, false], shouldAskForAlertsPermission: ['bool', true, false],
hasFocus: ['bool', true, false], hasFocus: ['bool', true, false],
@ -83,11 +93,18 @@ module.exports = HumanModel.define({
this.contacts.remove(jid.bare); this.contacts.remove(jid.bare);
app.storage.roster.remove(jid.bare); app.storage.roster.remove(jid.bare);
}, },
loadContacts: function () { load: function () {
if (!this.jid.bare) return; if (!this.jid.bare) return;
var self = this; var self = this;
app.storage.roster.getAll(this.jid.bare, function (err, contacts) {
app.storage.profiles.get(this.jid.bare, function (err, profile) {
if (!err) {
self.status = profile.status;
self.avatarID = profile.avatarID;
}
self.save();
app.storage.roster.getAll(self.jid.bare, function (err, contacts) {
if (err) return; if (err) return;
contacts.forEach(function (contact) { contacts.forEach(function (contact) {
@ -100,6 +117,7 @@ module.exports = HumanModel.define({
self.contacts.trigger('loaded'); self.contacts.trigger('loaded');
}); });
});
}, },
isMe: function (jid) { isMe: function (jid) {
return jid.bare === this.jid.bare; return jid.bare === this.jid.bare;
@ -127,5 +145,14 @@ module.exports = HumanModel.define({
}, },
updateActiveCalls: function () { updateActiveCalls: function () {
app.state.hasActiveCall = !!this.calls.length; app.state.hasActiveCall = !!this.calls.length;
},
save: function () {
var data = {
jid: this.jid.bare,
avatarID: this.avatarID,
status: this.status,
rosterVer: this.rosterVer
};
app.storage.profiles.set(data);
} }
}); });

View File

@ -5,7 +5,7 @@ var AvatarStorage = require('./avatars');
var RosterStorage = require('./roster'); var RosterStorage = require('./roster');
var DiscoStorage = require('./disco'); var DiscoStorage = require('./disco');
var ArchiveStorage = require('./archive'); var ArchiveStorage = require('./archive');
var RosterVerStorage = require('./rosterver'); var ProfileStorage = require('./profile');
function Storage() { function Storage() {
@ -16,13 +16,13 @@ function Storage() {
this.roster = new RosterStorage(this); this.roster = new RosterStorage(this);
this.disco = new DiscoStorage(this); this.disco = new DiscoStorage(this);
this.archive = new ArchiveStorage(this); this.archive = new ArchiveStorage(this);
this.rosterver = new RosterVerStorage(this); this.profiles = new ProfileStorage(this);
} }
Storage.prototype = { Storage.prototype = {
constructor: { constructor: {
value: Storage value: Storage
}, },
version: 2, version: 3,
open: function (cb) { open: function (cb) {
cb = cb || function () {}; cb = cb || function () {};
@ -38,7 +38,7 @@ Storage.prototype = {
self.roster.setup(db); self.roster.setup(db);
self.disco.setup(db); self.disco.setup(db);
self.archive.setup(db); self.archive.setup(db);
self.rosterver.setup(db); self.profiles.setup(db);
}; };
request.onerror = cb; request.onerror = cb;
} }

View File

@ -0,0 +1,66 @@
/*global, IDBKeyRange*/
"use strict";
// SCHEMA
// jid: string
// name: string
// avatarID: string
// status: string
// rosterVer: string
function ProfileStorage(storage) {
this.storage = storage;
}
ProfileStorage.prototype = {
constructor: {
value: ProfileStorage
},
setup: function (db) {
if (db.objectStoreNames.contains('profiles')) {
db.deleteObjectStore('profiles');
}
var store = db.createObjectStore('profiles', {
keyPath: 'jid'
});
},
transaction: function (mode) {
var trans = this.storage.db.transaction('profiles', mode);
return trans.objectStore('profiles');
},
set: function (profile, cb) {
cb = cb || function () {};
var request = this.transaction('readwrite').put(profile);
request.onsuccess = function () {
cb(false, profile);
};
request.onerror = cb;
},
get: function (id, cb) {
cb = cb || function () {};
if (!id) {
return cb('not-found');
}
var request = this.transaction('readonly').get(id);
request.onsuccess = function (e) {
var res = request.result;
if (res === undefined) {
return cb('not-found');
}
cb(false, request.result);
};
request.onerror = cb;
},
remove: function (id, cb) {
cb = cb || function () {};
var request = this.transaction('readwrite')['delete'](id);
request.onsuccess = function (e) {
cb(false, request.result);
};
request.onerror = cb;
}
};
module.exports = ProfileStorage;

View File

@ -11,7 +11,7 @@
</header> </header>
<section class="box connect"> <section class="box connect">
<h2>Connecting...</h2> <h2>Connecting...</h2>
<a href="/logout">Cancel</a> <a class="button" href="/logout">Cancel</a>
</section> </section>
</body> </body>
</html> </html>

View File

@ -24,6 +24,10 @@
h2 h2
padding: 0 padding: 0
.button
float: none
margin-top: 20px
.head, .content .head, .content
padding: 0 20px padding: 0 20px

View File

@ -3,7 +3,6 @@
.page.chat .page.chat
padding-top: 0px padding-top: 0px
height: 100%
borderbox() borderbox()
.conversation .conversation
@ -12,7 +11,6 @@
left: 0px left: 0px
right: 0px right: 0px
padding: 0px padding: 0px
height: 100%
width: 100% width: 100%
borderbox() borderbox()
@ -24,9 +22,6 @@
width: 100% width: 100%
display: block display: block
.messages
padding-top: 630px
header header
padding: 5px padding: 5px
border-bottom: 2px solid $grayOutline border-bottom: 2px solid $grayOutline
@ -45,17 +40,21 @@
left: 11px left: 11px
vertical-align: top vertical-align: top
.name, .call
float: left
.name .name
margin: 15px margin: 15px
padding: 0px padding: 0px
margin-left: 45px margin-left: 45px
font-size: 14px font-size: 14px
line-height: 14px line-height: 14px
max-width: 50%
.tzo:not(:empty) .tzo:not(:empty)
position: absolute position: absolute
right: 15px right: 15px
top: 25px top: 28px
height: 20px height: 20px
margin-top: -10px margin-top: -10px
padding: 0 5px padding: 0 5px
@ -67,6 +66,12 @@
color: lighten($baseText, 30%) color: lighten($baseText, 30%)
background: $grayOutline background: $grayOutline
.call
margin-top: 10px
height: 25px
line-height: 25px
min-width: 60px
.messages .messages
margin: 0px margin: 0px
padding: 0px padding: 0px

View File

@ -60,3 +60,6 @@ button, a.button
&:hover &:hover
background: darken($activeBlue, 30%) background: darken($activeBlue, 30%)
.enableAlerts
margin-right: 5px

View File

@ -148,7 +148,7 @@
margin-top: -15px margin-top: -15px
position: absolute position: absolute
left: 10px left: 10px
top: 50% top: 20px
avatar() avatar()
noselect() noselect()
@ -178,7 +178,7 @@
padding-top: 8px padding-top: 8px
roundall(30px) roundall(30px)
position: absolute position: absolute
top: 7px top: 5px
left: 10px left: 10px
font-size: 10px font-size: 10px
font-weight: bold font-weight: bold
@ -191,6 +191,11 @@
font-size: 10px font-size: 10px
color: darken($textSecondary, 50%) color: darken($textSecondary, 50%)
#bookmarks
.name
padding: 10px 15px 10px 40px
@keyframes pulsate @keyframes pulsate
0% 0%
opacity: 1.0 opacity: 1.0

View File

@ -12,6 +12,7 @@
padding: 5px padding: 5px
background: $grayBackground background: $grayBackground
roundall(3px) roundall(3px)
font-size: $fontSmall
.uploadRegion .uploadRegion
padding: 15px padding: 15px
@ -26,3 +27,6 @@
input input
width: 100% width: 100%
img
margin: 10px 0

View File

@ -503,7 +503,7 @@ h3 {
margin-top: -15px; margin-top: -15px;
position: absolute; position: absolute;
left: 10px; left: 10px;
top: 50%; top: 20px;
width: 30px; width: 30px;
height: 30px; height: 30px;
-moz-border-radius: 50px; -moz-border-radius: 50px;
@ -554,7 +554,7 @@ h3 {
-border-radius: 30px; -border-radius: 30px;
border-radius: 30px; border-radius: 30px;
position: absolute; position: absolute;
top: 7px; top: 5px;
left: 10px; left: 10px;
font-size: 10px; font-size: 10px;
font-weight: bold; font-weight: bold;
@ -568,6 +568,9 @@ h3 {
font-size: 10px; font-size: 10px;
color: #5c5c5c; color: #5c5c5c;
} }
#bookmarks .name {
padding: 10px 15px 10px 40px;
}
@-moz-keyframes pulsate { @-moz-keyframes pulsate {
0% { 0% {
opacity: 1; opacity: 1;
@ -635,7 +638,6 @@ h3 {
} }
.page.chat { .page.chat {
padding-top: 0px; padding-top: 0px;
height: 100%;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
@ -646,7 +648,6 @@ h3 {
left: 0px; left: 0px;
right: 0px; right: 0px;
padding: 0px; padding: 0px;
height: 100%;
width: 100%; width: 100%;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
@ -659,9 +660,6 @@ h3 {
width: 100%; width: 100%;
display: block; display: block;
} }
.conversation.activeCall .messages {
padding-top: 630px;
}
.conversation header { .conversation header {
padding: 5px; padding: 5px;
border-bottom: 2px solid #e4e4e4; border-bottom: 2px solid #e4e4e4;
@ -689,17 +687,22 @@ h3 {
left: 11px; left: 11px;
vertical-align: top; vertical-align: top;
} }
.conversation header .name,
.conversation header .call {
float: left;
}
.conversation header .name { .conversation header .name {
margin: 15px; margin: 15px;
padding: 0px; padding: 0px;
margin-left: 45px; margin-left: 45px;
font-size: 14px; font-size: 14px;
line-height: 14px; line-height: 14px;
max-width: 50%;
} }
.conversation header .tzo:not(:empty) { .conversation header .tzo:not(:empty) {
position: absolute; position: absolute;
right: 15px; right: 15px;
top: 25px; top: 28px;
height: 20px; height: 20px;
margin-top: -10px; margin-top: -10px;
padding: 0 5px; padding: 0 5px;
@ -716,6 +719,12 @@ h3 {
color: #898989; color: #898989;
background: #e4e4e4; background: #e4e4e4;
} }
.conversation header .call {
margin-top: 10px;
height: 25px;
line-height: 25px;
min-width: 60px;
}
.messages { .messages {
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
@ -866,6 +875,7 @@ h3 {
-o-border-radius: 3px; -o-border-radius: 3px;
-border-radius: 3px; -border-radius: 3px;
border-radius: 3px; border-radius: 3px;
font-size: 12px;
} }
.uploadRegion { .uploadRegion {
padding: 15px; padding: 15px;
@ -886,6 +896,9 @@ h3 {
.uploadRegion input { .uploadRegion input {
width: 100%; width: 100%;
} }
.uploadRegion img {
margin: 10px 0;
}
.aux { .aux {
background: #f7f7f7; background: #f7f7f7;
} }
@ -917,6 +930,10 @@ h3 {
.box.connect h2 { .box.connect h2 {
padding: 0; padding: 0;
} }
.box.connect .button {
float: none;
margin-top: 20px;
}
.box .head, .box .head,
.box .content { .box .content {
padding: 0 20px; padding: 0 20px;
@ -1027,6 +1044,9 @@ button:hover,
a.button:hover { a.button:hover {
background: #007aa7; background: #007aa7;
} }
.enableAlerts {
margin-right: 5px;
}
#wrapper { #wrapper {
position: relative !important; position: relative !important;
-webkit-transition: all 1s; -webkit-transition: all 1s;

View File

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# 0.0.1 1381879209705 # 0.0.1 1381879352769
CACHE: CACHE:
/app.js /app.js