mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-22 09:12:19 -05:00
t Merge branch 'video' of github.com:andyet/otalk into video
This commit is contained in:
commit
383b3d625f
@ -147,6 +147,12 @@ module.exports = function (client, app) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
client.on('subscribe', function (pres) {
|
||||||
|
me.contactRequests.add({
|
||||||
|
jid: pres.from.bare
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
client.on('available', function (pres) {
|
client.on('available', function (pres) {
|
||||||
pres = pres.toJSON();
|
pres = pres.toJSON();
|
||||||
var contact = me.getContact(pres.from);
|
var contact = me.getContact(pres.from);
|
||||||
|
12
clientapp/models/contactRequest.js
Normal file
12
clientapp/models/contactRequest.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/*global app, me*/
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var HumanModel = require('human-model');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = HumanModel.define({
|
||||||
|
type: 'contactRequest',
|
||||||
|
props: {
|
||||||
|
jid: ['string', true, '']
|
||||||
|
}
|
||||||
|
});
|
10
clientapp/models/contactRequests.js
Normal file
10
clientapp/models/contactRequests.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
var BaseCollection = require('./baseCollection');
|
||||||
|
var ContactRequest = require('./contactRequest');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = BaseCollection.extend({
|
||||||
|
type: 'contactRequests',
|
||||||
|
model: ContactRequest
|
||||||
|
});
|
@ -8,6 +8,7 @@ var Calls = require('./calls');
|
|||||||
var Contact = require('./contact');
|
var Contact = require('./contact');
|
||||||
var MUCs = require('./mucs');
|
var MUCs = require('./mucs');
|
||||||
var MUC = require('./muc');
|
var MUC = require('./muc');
|
||||||
|
var ContactRequests = require('./contactRequests');
|
||||||
var fetchAvatar = require('../helpers/fetchAvatar');
|
var fetchAvatar = require('../helpers/fetchAvatar');
|
||||||
|
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ module.exports = HumanModel.define({
|
|||||||
},
|
},
|
||||||
collections: {
|
collections: {
|
||||||
contacts: Contacts,
|
contacts: Contacts,
|
||||||
|
contactRequests: ContactRequests,
|
||||||
mucs: MUCs,
|
mucs: MUCs,
|
||||||
calls: Calls
|
calls: Calls
|
||||||
},
|
},
|
||||||
@ -104,8 +106,9 @@ module.exports = HumanModel.define({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeContact: function (jid) {
|
removeContact: function (jid) {
|
||||||
this.contacts.remove(jid.bare);
|
var contact = this.getContact(jid);
|
||||||
app.storage.roster.remove(jid.bare);
|
this.contacts.remove(contact.jid);
|
||||||
|
app.storage.roster.remove(contact.storageId);
|
||||||
},
|
},
|
||||||
load: function () {
|
load: function () {
|
||||||
if (!this.jid.bare) return;
|
if (!this.jid.bare) return;
|
||||||
|
@ -5,6 +5,8 @@ var crypto = require('crypto');
|
|||||||
var BasePage = require('./base');
|
var BasePage = require('./base');
|
||||||
var templates = require('../templates');
|
var templates = require('../templates');
|
||||||
|
|
||||||
|
var ContactRequestItem = require('../views/contactRequest');
|
||||||
|
|
||||||
|
|
||||||
module.exports = BasePage.extend({
|
module.exports = BasePage.extend({
|
||||||
template: templates.pages.main,
|
template: templates.pages.main,
|
||||||
@ -20,13 +22,19 @@ module.exports = BasePage.extend({
|
|||||||
events: {
|
events: {
|
||||||
'click .enableAlerts': 'enableAlerts',
|
'click .enableAlerts': 'enableAlerts',
|
||||||
'click .installFirefox': 'installFirefox',
|
'click .installFirefox': 'installFirefox',
|
||||||
|
'click .addContact': 'handleAddContact',
|
||||||
'dragover': 'handleAvatarChangeDragOver',
|
'dragover': 'handleAvatarChangeDragOver',
|
||||||
'drop': 'handleAvatarChange',
|
'drop': 'handleAvatarChange',
|
||||||
'change #uploader': 'handleAvatarChange',
|
'change #uploader': 'handleAvatarChange',
|
||||||
'blur .status': 'handleStatusChange'
|
'blur .status': 'handleStatusChange'
|
||||||
},
|
},
|
||||||
initialize: function (spec) {
|
initialize: function (spec) {
|
||||||
|
this.render();
|
||||||
|
},
|
||||||
|
render: function () {
|
||||||
this.renderAndBind();
|
this.renderAndBind();
|
||||||
|
this.renderCollection(this.model.contactRequests, ContactRequestItem, this.$('#contactrequests'));
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
enableAlerts: function () {
|
enableAlerts: function () {
|
||||||
if (app.notifications.permissionNeeded()) {
|
if (app.notifications.permissionNeeded()) {
|
||||||
@ -92,5 +100,16 @@ module.exports = BasePage.extend({
|
|||||||
status: text,
|
status: text,
|
||||||
caps: client.disco.caps
|
caps: client.disco.caps
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
handleAddContact: function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var contact = this.$('#addcontact').val();
|
||||||
|
if (contact) {
|
||||||
|
app.api.sendPresence({to: contact, type: 'subscribe'});
|
||||||
|
}
|
||||||
|
this.$('#addcontact').val('');
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -74,6 +74,15 @@ exports.includes.contactListItemResource = function anonymous(locals) {
|
|||||||
return buf.join("");
|
return buf.join("");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// contactRequest.jade compiled template
|
||||||
|
exports.includes.contactRequest = function anonymous(locals) {
|
||||||
|
var buf = [];
|
||||||
|
with (locals || {}) {
|
||||||
|
buf.push('<li><span class="jid"></span><button class="approve">Approve</button><button class="deny">Deny</button></li>');
|
||||||
|
}
|
||||||
|
return buf.join("");
|
||||||
|
};
|
||||||
|
|
||||||
// message.jade compiled template
|
// message.jade compiled template
|
||||||
exports.includes.message = function anonymous(locals) {
|
exports.includes.message = function anonymous(locals) {
|
||||||
var buf = [];
|
var buf = [];
|
||||||
@ -187,7 +196,7 @@ exports.pages.groupchat = function anonymous(locals) {
|
|||||||
exports.pages.main = function anonymous(locals) {
|
exports.pages.main = function anonymous(locals) {
|
||||||
var buf = [];
|
var buf = [];
|
||||||
with (locals || {}) {
|
with (locals || {}) {
|
||||||
buf.push('<section class="page main"><div><h3>Current status</h3><div contenteditable="true" class="status"></div></div><div id="avatarChanger"><h3>Change Avatar</h3><div class="uploadRegion"><p>Drag and drop a new avatar here</p><img/><form><input id="uploader" type="file"/></form></div></div><div><h3>Desktop Integration</h3><button class="enableAlerts">Enable alerts</button><button class="installFirefox">Install app</button></div></section>');
|
buf.push('<section class="page main"><div><h3>Current status</h3><div contenteditable="true" class="status"></div></div><div id="avatarChanger"><h3>Change Avatar</h3><div class="uploadRegion"><p>Drag and drop a new avatar here</p><img/><form><input id="uploader" type="file"/></form></div></div><div><h3>Add / Approve Contacts</h3><input id="addcontact"/><button class="addContact">Add</button><ul id="contactrequests"></ul></div><div><h3>Desktop Integration</h3><button class="enableAlerts">Enable alerts</button><button class="installFirefox">Install app</button></div></section>');
|
||||||
}
|
}
|
||||||
return buf.join("");
|
return buf.join("");
|
||||||
};
|
};
|
||||||
|
4
clientapp/templates/includes/contactRequest.jade
Normal file
4
clientapp/templates/includes/contactRequest.jade
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
li
|
||||||
|
span.jid
|
||||||
|
button.approve Approve
|
||||||
|
button.deny Deny
|
@ -12,6 +12,12 @@ section.page.main
|
|||||||
form
|
form
|
||||||
input#uploader(type="file")
|
input#uploader(type="file")
|
||||||
|
|
||||||
|
div
|
||||||
|
h3 Add / Approve Contacts
|
||||||
|
input#addcontact
|
||||||
|
button.addContact Add
|
||||||
|
ul#contactrequests
|
||||||
|
|
||||||
div
|
div
|
||||||
h3 Desktop Integration
|
h3 Desktop Integration
|
||||||
button.enableAlerts Enable alerts
|
button.enableAlerts Enable alerts
|
||||||
|
43
clientapp/views/contactRequest.js
Normal file
43
clientapp/views/contactRequest.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*global $, app*/
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var _ = require('underscore');
|
||||||
|
var HumanView = require('human-view');
|
||||||
|
var templates = require('../templates');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = HumanView.extend({
|
||||||
|
template: templates.includes.contactRequest,
|
||||||
|
initialize: function (opts) {
|
||||||
|
this.render();
|
||||||
|
},
|
||||||
|
events: {
|
||||||
|
'click .approve': 'handleApprove',
|
||||||
|
'click .deny': 'handleDeny'
|
||||||
|
},
|
||||||
|
textBindings: {
|
||||||
|
jid: '.jid'
|
||||||
|
},
|
||||||
|
render: function () {
|
||||||
|
this.renderAndBind({message: this.model});
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
handleApprove: function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
app.api.sendPresence({
|
||||||
|
to: this.model.jid,
|
||||||
|
type: 'subscribed'
|
||||||
|
});
|
||||||
|
app.me.contactRequests.remove(this.model);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
handleDeny: function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
app.api.sendPresence({
|
||||||
|
to: this.model.jid,
|
||||||
|
type: 'unsubscribed'
|
||||||
|
});
|
||||||
|
app.me.contactRequests.remove(this.model);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user