1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-08-13 17:03:51 -04:00

Refine styles

This commit is contained in:
Lance Stout 2013-12-19 23:04:14 -08:00
parent b9a40a6d58
commit 02983e2bfd
11 changed files with 225 additions and 50 deletions

View File

@ -4,7 +4,7 @@
var _ = require('underscore'); var _ = require('underscore');
var async = require('async'); var async = require('async');
var crypto = require('crypto'); var crypto = require('crypto');
var log = require('andlog'); var bows = require('bows');
var uuid = require('node-uuid'); var uuid = require('node-uuid');
var HumanModel = require('human-model'); var HumanModel = require('human-model');
var Contact = require('../models/contact'); var Contact = require('../models/contact');
@ -13,11 +13,16 @@ var Message = require('../models/message');
var Call = require('../models/call'); var Call = require('../models/call');
var log = bows('Otalk');
var ioLogIn = bows('<< in');
var ioLogOut = bows('>> out');
var discoCapsQueue = async.queue(function (pres, cb) { var discoCapsQueue = async.queue(function (pres, cb) {
var jid = pres.from; var jid = pres.from;
var caps = pres.caps; var caps = pres.caps;
log.debug('Checking storage for ' + caps.ver); log.info('Checking storage for ' + caps.ver);
var contact = me.getContact(jid); var contact = me.getContact(jid);
var resource = null; var resource = null;
@ -26,28 +31,26 @@ var discoCapsQueue = async.queue(function (pres, cb) {
} }
app.storage.disco.get(caps.ver, function (err, existing) { app.storage.disco.get(caps.ver, function (err, existing) {
log.debug(err, existing);
if (existing) { if (existing) {
log.debug('Already found info for ' + caps.ver); log.info('Already found info for ' + caps.ver);
if (resource) resource.discoInfo = existing; if (resource) resource.discoInfo = existing;
return cb(); return cb();
} }
log.debug('getting info for ' + caps.ver + ' from ' + jid); log.info('getting info for ' + caps.ver + ' from ' + jid);
client.getDiscoInfo(jid, caps.node + '#' + caps.ver, function (err, result) { client.getDiscoInfo(jid, caps.node + '#' + caps.ver, function (err, result) {
log.debug(caps.ver, err, result);
if (err) { if (err) {
log.debug('Couldnt get info for ' + caps.ver); log.error('Couldnt get info for ' + caps.ver);
return cb(); return cb();
} }
if (client.verifyVerString(result.discoInfo, caps.hash, caps.ver)) { if (client.verifyVerString(result.discoInfo, caps.hash, caps.ver)) {
log.debug('Saving info for ' + caps.ver); log.info('Saving info for ' + caps.ver);
var data = result.discoInfo.toJSON(); var data = result.discoInfo.toJSON();
app.storage.disco.add(caps.ver, data, function () { app.storage.disco.add(caps.ver, data, function () {
if (resource) resource.discoInfo = existing; if (resource) resource.discoInfo = existing;
cb(); cb();
}); });
} else { } else {
log.debug('Couldnt verify info for ' + caps.ver + ' from ' + jid); log.info('Couldnt verify info for ' + caps.ver + ' from ' + jid);
cb(); cb();
} }
}); });
@ -58,9 +61,10 @@ var discoCapsQueue = async.queue(function (pres, cb) {
module.exports = function (client, app) { module.exports = function (client, app) {
client.on('*', function (name, data) { client.on('*', function (name, data) {
log.debug(name, data); if (name === 'raw:incoming') {
if (name === 'raw:outgoing') { ioLogIn.debug(data.toString());
log.debug(data.toString()); } else if (name === 'raw:outgoing') {
ioLogOut.debug(data.toString());
} }
}); });
@ -93,7 +97,7 @@ module.exports = function (client, app) {
}); });
client.on('auth:failed', function () { client.on('auth:failed', function () {
log.debug('auth failed'); log.warning('auth failed');
window.location = '/login'; window.location = '/login';
}); });
@ -287,6 +291,13 @@ module.exports = function (client, app) {
} }
}); });
client.on('groupchat:subject', function (msg) {
var contact = me.getContact(msg.from, msg.to);
if (contact) {
contact.subject = msg.subject;
}
});
client.on('replace', function (msg) { client.on('replace', function (msg) {
msg = msg.toJSON(); msg = msg.toJSON();
msg.mid = msg.id; msg.mid = msg.id;
@ -336,7 +347,7 @@ module.exports = function (client, app) {
client.on('disco:caps', function (pres) { client.on('disco:caps', function (pres) {
if (pres.caps.hash) { if (pres.caps.hash) {
log.debug('Caps from ' + pres.from + ' ver: ' + pres.caps.ver); log.info('Caps from ' + pres.from + ' ver: ' + pres.caps.ver);
discoCapsQueue.push(pres); discoCapsQueue.push(pres);
} }
}); });

View File

@ -4,6 +4,7 @@
var _ = require('underscore'); var _ = require('underscore');
var async = require('async'); var async = require('async');
var uuid = require('node-uuid'); var uuid = require('node-uuid');
var htmlify = require('../helpers/htmlify');
var HumanModel = require('human-model'); var HumanModel = require('human-model');
var Resources = require('./resources'); var Resources = require('./resources');
var Messages = require('./messages'); var Messages = require('./messages');
@ -25,6 +26,7 @@ module.exports = HumanModel.define({
jid: 'object' jid: 'object'
}, },
session: { session: {
subject: 'string',
activeContact: ['bool', true, false], activeContact: ['bool', true, false],
lastInteraction: 'data', lastInteraction: 'data',
lastSentMessage: 'object', lastSentMessage: 'object',
@ -47,6 +49,12 @@ module.exports = HumanModel.define({
return ''; return '';
} }
}, },
displaySubject: {
deps: ['subject'],
fn: function () {
return htmlify.toHTML(this.subject);
}
},
hasUnread: { hasUnread: {
deps: ['unreadCount'], deps: ['unreadCount'],
fn: function () { fn: function () {

View File

@ -36,10 +36,14 @@ module.exports = BasePage.extend(chatHelpers).extend({
}, },
textBindings: { textBindings: {
displayName: 'header .name', displayName: 'header .name',
formattedTZO: 'header .tzo' formattedTZO: 'header .tzo',
status: 'header .status'
}, },
classBindings: { classBindings: {
onCall: '.messages' chatState: 'header',
idle: 'header',
show: 'header',
onCall: '.conversation'
}, },
show: function (animation) { show: function (animation) {
BasePage.prototype.show.apply(this, [animation]); BasePage.prototype.show.apply(this, [animation]);
@ -104,10 +108,10 @@ module.exports = BasePage.extend(chatHelpers).extend({
}); });
this.scrollIfPinned(); this.scrollIfPinned();
}, },
handleWindowResize: function () { handleWindowResize: _.debounce(function () {
this.scrollIfPinned(); this.scrollIfPinned();
this.resizeInput(); this.resizeInput();
}, }),
handleKeyDown: function (e) { handleKeyDown: function (e) {
if (e.which === 13 && !e.shiftKey) { if (e.which === 13 && !e.shiftKey) {
this.sendChat(); this.sendChat();

View File

@ -31,7 +31,8 @@ module.exports = BasePage.extend(chatHelpers).extend({
joined: '.controls' joined: '.controls'
}, },
textBindings: { textBindings: {
displayName: 'header .name' displayName: 'header .name',
subject: 'header .status'
}, },
show: function (animation) { show: function (animation) {
BasePage.prototype.show.apply(this, [animation]); BasePage.prototype.show.apply(this, [animation]);

View File

@ -194,7 +194,7 @@ exports.misc.growlMessage = function anonymous(locals) {
exports.pages.chat = function anonymous(locals) { exports.pages.chat = function anonymous(locals) {
var buf = []; var buf = [];
with (locals || {}) { with (locals || {}) {
buf.push('<section class="page chat"><section class="conversation"><header><img class="avatar"/><h1 class="name"></h1><div class="tzo"></div><button class="primary small call">call</button><div class="activeCall"><video autoplay="autoplay" class="remote"></video><video autoplay="autoplay" muted="muted" class="local"></video><aside class="button-wrap"><button class="end primary">End</button><div class="button-group outlined"><button class="mute">Mute</button><button class="unmute">Unmute</button></div></aside></div></header><ul class="messages scroll-container"></ul><div class="chatBox"><form><textarea name="chatInput" type="text" placeholder="Send a message..." autocomplete="off"></textarea></form></div></section></section>'); buf.push('<section class="page chat"><section class="conversation"><header><h1 class="name"></h1><div class="status"></div><div class="idleTime"></div><div class="tzo"></div><button class="primary small call">call</button><div class="activeCall"><video autoplay="autoplay" class="remote"></video><video autoplay="autoplay" muted="muted" class="local"></video><aside class="button-wrap"><button class="end primary">End</button><div class="button-group outlined"><button class="mute">Mute</button><button class="unmute">Unmute</button></div></aside></div></header><ul class="messages scroll-container"></ul><div class="chatBox"><form><textarea name="chatInput" type="text" placeholder="Send a message..." autocomplete="off"></textarea></form></div></section></section>');
} }
return buf.join(""); return buf.join("");
}; };
@ -203,7 +203,7 @@ exports.pages.chat = function anonymous(locals) {
exports.pages.groupchat = function anonymous(locals) { exports.pages.groupchat = function anonymous(locals) {
var buf = []; var buf = [];
with (locals || {}) { with (locals || {}) {
buf.push('<section class="page chat"><section class="conversation"><header><h1 class="name"></h1><div class="controls"><button class="primary joinRoom">Join</button><button class="secondary leaveRoom">Leave</button></div></header><ul class="messages"></ul><div class="chatBox"><form><textarea name="chatInput" type="text" placeholder="Send a message..." autocomplete="off"></textarea></form></div></section></section>'); buf.push('<section class="page chat"><section class="conversation"><header class="online"><h1 class="name"></h1><div class="status"></div><div class="controls"><button class="primary small joinRoom">Join</button><button class="secondary small leaveRoom">Leave</button></div></header><ul class="messages"></ul><div class="chatBox"><form><textarea name="chatInput" type="text" placeholder="Send a message..." autocomplete="off"></textarea></form></div></section></section>');
} }
return buf.join(""); return buf.join("");
}; };

View File

@ -1,8 +1,9 @@
section.page.chat section.page.chat
section.conversation section.conversation
header header
img.avatar
h1.name h1.name
.status
.idleTime
.tzo .tzo
button.primary.small.call call button.primary.small.call call
.activeCall .activeCall

View File

@ -1,10 +1,11 @@
section.page.chat section.page.chat
section.conversation section.conversation
header header.online
h1.name h1.name
.status
.controls .controls
button.primary.joinRoom Join button.primary.small.joinRoom Join
button.secondary.leaveRoom Leave button.secondary.small.leaveRoom Leave
ul.messages ul.messages
.chatBox .chatBox
form form

View File

@ -7,7 +7,7 @@
"url": "git@github.com:andyet/otalk.git" "url": "git@github.com:andyet/otalk.git"
}, },
"dependencies": { "dependencies": {
"andlog": "0.0.4", "bows": "",
"async": "0.2.9", "async": "0.2.9",
"backbone": "1.0.0", "backbone": "1.0.0",
"express": "3.3.7", "express": "3.3.7",
@ -22,7 +22,7 @@
"human-view": "1.2.0", "human-view": "1.2.0",
"templatizer": "0.1.2", "templatizer": "0.1.2",
"underscore": "1.5.1", "underscore": "1.5.1",
"stanza.io": "2.9.3", "stanza.io": "2.9.4",
"notify.js": "0.0.3", "notify.js": "0.0.3",
"wildemitter": "0.0.5", "wildemitter": "0.0.5",
"attachmediastream": "1.0.1", "attachmediastream": "1.0.1",

View File

@ -878,7 +878,8 @@ button.secondary:hover:not(:disabled) {
box-sizing: border-box; box-sizing: border-box;
} }
.conversation header { .conversation header {
padding: 5px; padding: 0px;
padding-left: 8px;
border-bottom: 2px solid #eee; border-bottom: 2px solid #eee;
position: fixed; position: fixed;
right: 0px; right: 0px;
@ -889,6 +890,59 @@ button.secondary:hover:not(:disabled) {
box-sizing: border-box; box-sizing: border-box;
background: #f7f7f7; background: #f7f7f7;
} }
.conversation header.online:not(.idle):before,
.conversation header.chat:before,
.conversation header.dnd:before,
.conversation header.away:before,
.conversation header.xa:before {
content: '';
position: absolute;
top: 50%;
height: 8px;
width: 8px;
margin-top: -4px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
-khtml-border-radius: 10px;
-o-border-radius: 10px;
-border-radius: 10px;
border-radius: 10px;
}
.conversation header.online:before,
.conversation header.chat:before {
background: #43bb6e;
}
.conversation header.dnd:before {
background: #de0a32;
}
.conversation header.away:before,
.conversation header.xa:before {
background: #f18902;
}
.conversation header.offline:not(:hover) .name {
color: #515151;
}
.conversation header.offline:not(:hover) .status {
color: #2f2f2f;
}
.conversation header.offline:not(:hover) .avatar {
opacity: 0.25;
}
.conversation header.composing:before {
animation: pulsate 1.5s infinite ease-in;
-webkit-animation: pulsate 1.5s infinite ease-in;
-moz-animation: pulsate 1.5s infinite ease-in;
}
.conversation header.paused:before {
background: #878787;
}
.conversation header.idle {
padding-right: 15px;
}
.conversation header.idle .name {
color: #878787;
max-width: 60%;
}
.conversation header .controls { .conversation header .controls {
float: right; float: right;
} }
@ -898,10 +952,13 @@ button.secondary:hover:not(:disabled) {
.conversation header .controls .joinRoom { .conversation header .controls .joinRoom {
display: block; display: block;
} }
.conversation header .joined .joinRoom { .conversation header .controls button {
margin-top: 4px;
}
.conversation header .controls.joined .joinRoom {
display: none; display: none;
} }
.conversation header .joined .leaveRoom { .conversation header .controls.joined .leaveRoom {
display: block; display: block;
} }
.conversation header .avatar { .conversation header .avatar {
@ -924,17 +981,33 @@ button.secondary:hover:not(:disabled) {
float: left; float: left;
} }
.conversation header .name { .conversation header .name {
margin: 15px; margin: 10px;
margin-left: 15px;
margin-right: 5px;
padding: 0px; padding: 0px;
margin-left: 45px;
font-size: 14px; font-size: 14px;
line-height: 14px; line-height: 14px;
max-width: 50%; max-width: 50%;
} }
.conversation header .status {
margin: 10px;
margin-left: 0px;
padding: 0px;
font-size: 14px;
line-height: 14px;
max-width: 75%;
float: left;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.conversation header .status:not(:empty):before {
content: '- ';
}
.conversation header .tzo:not(:empty) { .conversation header .tzo:not(:empty) {
position: absolute; position: absolute;
right: 15px; right: 15px;
top: 28px; top: 18px;
height: 20px; height: 20px;
margin-top: -10px; margin-top: -10px;
padding: 0 5px; padding: 0 5px;
@ -944,15 +1017,18 @@ button.secondary:hover:not(:disabled) {
-o-border-radius: 3px; -o-border-radius: 3px;
-border-radius: 3px; -border-radius: 3px;
border-radius: 3px; border-radius: 3px;
text-transform: uppercase;
font-size: 12px; font-size: 12px;
font-weight: 800; font-weight: 800;
line-height: 20px; line-height: 20px;
color: #898989; color: #898989;
background: #eee; background: #eee;
} }
.conversation header .tzo:not(:empty):before {
content: 'Current Time: ';
font-weight: bold;
}
.conversation header .call { .conversation header .call {
margin-top: 9px; margin-top: 4px;
text-transform: capitalize; text-transform: capitalize;
} }
.conversation header .activeCall { .conversation header .activeCall {
@ -996,7 +1072,7 @@ button.secondary:hover:not(:disabled) {
position: absolute; position: absolute;
top: 0px; top: 0px;
bottom: 0px; bottom: 0px;
padding-top: 55px; padding-top: 35px;
padding-bottom: 55px; padding-bottom: 55px;
width: 100%; width: 100%;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;

View File

@ -16,7 +16,8 @@
borderbox() borderbox()
header header
padding: 5px padding: 0px
padding-left: 8px
border-bottom: 2px solid $gray-lighter border-bottom: 2px solid $gray-lighter
position: fixed position: fixed
right: 0px right: 0px
@ -25,6 +26,56 @@
borderbox() borderbox()
background: lighten($gray-light, 93%) background: lighten($gray-light, 93%)
&.online:not(.idle), &.chat, &.dnd, &.away, &.xa
&:before
content: ''
position: absolute
top: 50%
height: 8px
width: 8px
margin-top: -4px
roundall(10px)
&.online,
&.chat
&:before
background: $green
&.dnd
&:before
background: $red
&.away,
&.xa
&:before
background: $orange
&.offline:not(:hover)
.name
color: darken($gray-light, 40%)
.status
color: darken($gray-light, 65%)
.avatar
opacity: .25
&.composing
&:before
animation: pulsate 1.5s infinite ease-in
-webkit-animation: pulsate 1.5s infinite ease-in
-moz-animation: pulsate 1.5s infinite ease-in
&.paused
&:before
background: $gray-light
&.idle
padding-right: 15px
.name
color: $gray-light
max-width: 60%
.controls .controls
float: right float: right
@ -34,12 +85,15 @@
.joinRoom .joinRoom
display: block display: block
.joined button
.joinRoom margin-top: 4px
display: none
.leaveRoom &.joined
display: block .joinRoom
display: none
.leaveRoom
display: block
.avatar .avatar
margin-right: 5px margin-right: 5px
@ -53,30 +107,49 @@
float: left float: left
.name .name
margin: 15px margin: 10px
margin-left: 15px
margin-right: 5px
padding: 0px padding: 0px
margin-left: 45px
font-size: $font-size-base font-size: $font-size-base
line-height: 14px line-height: 14px
max-width: 50% max-width: 50%
.status
margin: 10px
margin-left: 0px
padding: 0px
font-size: $font-size-base
line-height: 14px
max-width: 75%
float: left
overflow: hidden
text-overflow: ellipsis
white-space: nowrap
&:not(:empty):before
content: '- '
.tzo:not(:empty) .tzo:not(:empty)
position: absolute position: absolute
right: 15px right: 15px
top: 28px top: 18px
height: 20px height: 20px
margin-top: -10px margin-top: -10px
padding: 0 5px padding: 0 5px
roundall(3px) roundall(3px)
text-transform: uppercase
font-size: $font-size-small font-size: $font-size-small
font-weight: $font-weight-bold font-weight: $font-weight-bold
line-height: 20px line-height: 20px
color: lighten($gray, 30%) color: lighten($gray, 30%)
background: $gray-lighter background: $gray-lighter
&:before
content: 'Current Time: '
font-weight: bold
.call .call
margin-top: 9px margin-top: 4px
text-transform: capitalize text-transform: capitalize
.activeCall .activeCall
@ -84,7 +157,7 @@
height: 0px height: 0px
position: relative position: relative
top: 0px top: 0px
.remote .remote
position: absolute position: absolute
top: 60px top: 60px
@ -121,7 +194,7 @@
position: absolute position: absolute
top: 0px top: 0px
bottom: 0px bottom: 0px
padding-top: 55px padding-top: 35px
padding-bottom: 55px padding-bottom: 55px
width: 100% width: 100%
borderbox() borderbox()

View File

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# 0.0.1 1387497051758 # 0.0.1 1387522881010
CACHE: CACHE:
/app.js /app.js