Skip to content
Browse files

Update strophe plugins

  • Loading branch information...
1 parent aecae1a commit dc163bf1d3b75cd1be66967dddda1581cafa7a17 Yiorgis Gozadinos committed Apr 23, 2012
Showing with 25 additions and 25 deletions.
  1. +9 −9 strophe.pubsub.js
  2. +16 −16 tests/specs/strophe.pubsub_spec.js
View
18 strophe.pubsub.js
@@ -17,7 +17,7 @@
service: null,
events: {},
- // **init** adds the various namespaces we use, as well as extends `events` from
+ // **init** adds the various namespaces we use, as well as extends from
// **Backbone.Events**.
init: function (conn) {
this._connection = conn;
@@ -27,7 +27,7 @@
Strophe.addNamespace('PUBSUB_NODE_CONFIG', Strophe.NS.PUBSUB + '#node_config');
Strophe.addNamespace('ATOM', 'http://www.w3.org/2005/Atom');
Strophe.addNamespace('DELAY', 'urn:xmpp:delay');
- _.extend(this.events, Backbone.Events);
+ _.extend(this, Backbone.Events);
},
// Register to PEP events when connected
@@ -40,7 +40,7 @@
// Handle PEP events and trigger own events.
_onReceivePEPEvent: function (ev) {
- var that = this,
+ var self = this,
delay = $('delay[xmlns="' + Strophe.NS.DELAY + '"]', ev).attr('stamp');
$('item', ev).each(function (idx, item) {
var node = $(item).parent().attr('node'),
@@ -55,26 +55,26 @@
if (delay) {
// PEP event for the last-published item on a node.
- that.events.trigger('xmpp:pubsub:last-published-item', {
+ self.trigger('xmpp:pubsub:last-published-item', {
node: node,
id: id,
entry: entry,
timestamp: delay
});
- that.events.trigger('xmpp:pubsub:last-published-item:' + node, {
+ self.trigger('xmpp:pubsub:last-published-item:' + node, {
id: id,
entry: entry,
timestamp: delay
});
} else {
// PEP event for an item newly published on a node.
- that.events.trigger('xmpp:pubsub:item-published', {
+ self.trigger('xmpp:pubsub:item-published', {
node: node,
id: id,
entry: entry
});
- that.events.trigger('xmpp:pubsub:item-published:' + node, {
+ self.trigger('xmpp:pubsub:item-published:' + node, {
id: id,
entry: entry
});
@@ -85,8 +85,8 @@
$('retract', ev).each(function (idx, item) {
var node = $(item).parent().attr('node'),
id = $(item).attr('id');
- that.events.trigger('xmpp:pubsub:item-deleted', {node: node, id: id});
- that.events.trigger('xmpp:pubsub:item-deleted:' + node, {id: id});
+ self.trigger('xmpp:pubsub:item-deleted', {node: node, id: id});
+ self.trigger('xmpp:pubsub:item-deleted:' + node, {id: id});
});
return true;
View
32 tests/specs/strophe.pubsub_spec.js
@@ -16,9 +16,9 @@
var itemPublishedHandler = jasmine.createSpy('itemPublishedHandler');
var itemPublishedOnNodeHandler = jasmine.createSpy('itemPublishedOnNodeHandler');
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:last-published-item', lastPublishedHandler);
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:item-published', itemPublishedHandler);
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:item-published:anode', itemPublishedOnNodeHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:last-published-item', lastPublishedHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:item-published', itemPublishedHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:item-published:anode', itemPublishedOnNodeHandler);
var message = $msg({from: Strophe.connection.PubSub.service, to: Strophe.connection.jid})
.c('event', {xmlns: Strophe.NS.PUBSUB_EVENT})
@@ -41,9 +41,9 @@
var itemPublishedHandler = jasmine.createSpy('itemPublishedHandler');
var itemPublishedOnNodeHandler = jasmine.createSpy('itemPublishedOnNodeHandler');
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:last-published-item', lastPublishedHandler);
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:item-published', itemPublishedHandler);
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:item-published:anode', itemPublishedOnNodeHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:last-published-item', lastPublishedHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:item-published', itemPublishedHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:item-published:anode', itemPublishedOnNodeHandler);
var message = $msg({from: Strophe.connection.PubSub.service, to: Strophe.connection.jid})
.c('event', {xmlns: Strophe.NS.PUBSUB_EVENT})
@@ -64,9 +64,9 @@
var lastPublishedHandler = jasmine.createSpy('lastPublishedHandler');
var lastPublishedOnNodeHandler = jasmine.createSpy('lastPublishedOnNodeHandler');
var itemPublishedHandler = jasmine.createSpy('itemPublishedHandler');
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:last-published-item', lastPublishedHandler);
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:item-published', itemPublishedHandler);
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:last-published-item:anode', lastPublishedOnNodeHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:last-published-item', lastPublishedHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:item-published', itemPublishedHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:last-published-item:anode', lastPublishedOnNodeHandler);
var message = $msg({from: Strophe.connection.PubSub.service, to: Strophe.connection.jid})
.c('delay', {xmlns: Strophe.NS.DELAY, stamp: '2011-12-01T10:00:00Z'}).up()
@@ -89,9 +89,9 @@
var lastPublishedHandler = jasmine.createSpy('lastPublishedHandler');
var lastPublishedOnNodeHandler = jasmine.createSpy('lastPublishedOnNodeHandler');
var itemPublishedHandler = jasmine.createSpy('itemPublishedHandler');
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:last-published-item', lastPublishedHandler);
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:item-published', itemPublishedHandler);
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:last-published-item:anode', lastPublishedOnNodeHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:last-published-item', lastPublishedHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:item-published', itemPublishedHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:last-published-item:anode', lastPublishedOnNodeHandler);
var message = $msg({from: Strophe.connection.PubSub.service, to: Strophe.connection.jid})
.c('delay', {xmlns: Strophe.NS.DELAY, stamp: '2011-12-01T10:00:00Z'}).up()
@@ -112,8 +112,8 @@
it('fires the "xmpp:pubsub:item-deleted" event when a PEP message is received for a retracted item', function () {
var itemDeletedHandler = jasmine.createSpy('itemDeletedHandler');
var itemDeletedOnNodeHandler = jasmine.createSpy('itemDeletedOnNodeHandler');
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:item-deleted', itemDeletedHandler);
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:item-deleted:anode', itemDeletedOnNodeHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:item-deleted', itemDeletedHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:item-deleted:anode', itemDeletedOnNodeHandler);
var message = $msg({from: Strophe.connection.PubSub.service, to: Strophe.connection.jid})
.c('event', {xmlns: Strophe.NS.PUBSUB_EVENT})
.c('items', {node: 'anode'})
@@ -129,8 +129,8 @@
it('does not fire an event when a transient PEP message is received', function () {
var lastPublishedHandler = jasmine.createSpy('lastPublishedHandler');
var itemPublishedHandler = jasmine.createSpy('itemPublishedHandler');
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:last-published-item', lastPublishedHandler);
- Strophe.connection.PubSub.events.bind('xmpp:pubsub:item-published', itemPublishedHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:last-published-item', lastPublishedHandler);
+ Strophe.connection.PubSub.bind('xmpp:pubsub:item-published', itemPublishedHandler);
var message = $msg({from: Strophe.connection.PubSub.service, to: Strophe.connection.jid})
.c('event', {xmlns: Strophe.NS.PUBSUB_EVENT})

0 comments on commit dc163bf

Please sign in to comment.
Something went wrong with that request. Please try again.