Add AMD support for strophe.muc and strophe.vcard.
This commit is contained in:
parent
eb272c39e0
commit
5a253e32e1
@ -16,7 +16,6 @@
|
||||
"backbone.browserStorage": "*",
|
||||
"backbone.overview": "*",
|
||||
"strophe": "~1.1.3",
|
||||
"strophe.muc": "https://raw.githubusercontent.com/strophe/strophejs-plugins/master/muc/strophe.muc.js",
|
||||
"otr": "0.2.12",
|
||||
"crypto-js-evanvosberg": "~3.1.2",
|
||||
"almond": "~0.2.9",
|
||||
|
4
main.js
4
main.js
@ -36,9 +36,9 @@ require.config({
|
||||
"strophe-websocket": "components/strophe/src/websocket",
|
||||
"strophe-polyfill": "components/strophe/src/polyfill",
|
||||
"strophe.disco": "components/strophejs-plugins/disco/strophe.disco",
|
||||
"strophe.muc": "components/strophe.muc/index",
|
||||
"strophe.muc": "src/strophe.muc",
|
||||
"strophe.roster": "src/strophe.roster",
|
||||
"strophe.vcard": "components/strophejs-plugins/vcard/strophe.vcard",
|
||||
"strophe.vcard": "src/strophe.vcard",
|
||||
"text": 'components/requirejs-text/text',
|
||||
"tpl": 'components/requirejs-tpl-jcbrand/tpl',
|
||||
"typeahead": "components/typeahead.js/index",
|
||||
|
1168
src/strophe.muc.js
Normal file
1168
src/strophe.muc.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -26,6 +26,7 @@
|
||||
Strophe.$msg,
|
||||
Strophe.$pres
|
||||
);
|
||||
return Strophe;
|
||||
});
|
||||
} else {
|
||||
// Browser globals
|
||||
|
71
src/strophe.vcard.js
Normal file
71
src/strophe.vcard.js
Normal file
@ -0,0 +1,71 @@
|
||||
/* Plugin to implement the vCard extension.
|
||||
* http://xmpp.org/extensions/xep-0054.html
|
||||
*
|
||||
* Author: Nathan Zorn (nathan.zorn@gmail.com)
|
||||
* AMD support by JC Brand
|
||||
*/
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define([
|
||||
"strophe-full"
|
||||
], function (Strophe) {
|
||||
factory(
|
||||
Strophe.Strophe,
|
||||
Strophe.$build,
|
||||
Strophe.$iq ,
|
||||
Strophe.$msg,
|
||||
Strophe.$pres
|
||||
);
|
||||
return Strophe;
|
||||
});
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(
|
||||
root.Strophe,
|
||||
root.$build,
|
||||
root.$iq ,
|
||||
root.$msg,
|
||||
root.$pres
|
||||
);
|
||||
}
|
||||
}(this, function (Strophe, $build, $iq, $msg, $pres) {
|
||||
|
||||
var buildIq = function(type, jid, vCardEl) {
|
||||
var iq = $iq(jid ? {type: type, to: jid} : {type: type});
|
||||
iq.c("vCard", {xmlns: Strophe.NS.VCARD});
|
||||
if (vCardEl) {
|
||||
iq.cnode(vCardEl);
|
||||
}
|
||||
return iq;
|
||||
};
|
||||
|
||||
Strophe.addConnectionPlugin('vcard', {
|
||||
_connection: null,
|
||||
init: function(conn) {
|
||||
this._connection = conn;
|
||||
return Strophe.addNamespace('VCARD', 'vcard-temp');
|
||||
},
|
||||
|
||||
/*Function
|
||||
Retrieve a vCard for a JID/Entity
|
||||
Parameters:
|
||||
(Function) handler_cb - The callback function used to handle the request.
|
||||
(String) jid - optional - The name of the entity to request the vCard
|
||||
If no jid is given, this function retrieves the current user's vcard.
|
||||
*/
|
||||
get: function(handler_cb, jid, error_cb) {
|
||||
var iq = buildIq("get", jid);
|
||||
return this._connection.sendIQ(iq, handler_cb, error_cb);
|
||||
},
|
||||
|
||||
/* Function
|
||||
Set an entity's vCard.
|
||||
*/
|
||||
set: function(handler_cb, vCardEl, jid, error_cb) {
|
||||
var iq = buildIq("set", jid, vCardEl);
|
||||
return this._connection.sendIQ(iq, handler_cb, error_cb);
|
||||
}
|
||||
});
|
||||
}));
|
Loading…
Reference in New Issue
Block a user