Skip to content

Commit

Permalink
Adapt to strophe being wrapped with require.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ggozad committed Jun 2, 2016
1 parent 68814a7 commit dc51c7a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 30 deletions.
9 changes: 9 additions & 0 deletions .jshintrc
@@ -0,0 +1,9 @@
{
"undef": true,
"strict": false,
"browser": true,
"debug": true,
"devel": true,
"jquery": false,
"predef": ["define", "require"]
}
10 changes: 5 additions & 5 deletions strophe.disco.js
Expand Up @@ -11,17 +11,17 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', 'underscore', 'backbone', 'strophe'], function ($, _, Backbone, Strophe) {
define(['jquery', 'underscore', 'backbone', 'strophe'], function ($, _, Backbone, wrapper) {
// Also create a global in case some scripts
// that are loaded still are looking for
// a global even when an AMD loader is in use.
return factory($, _, Backbone, Strophe);
return factory($, _, Backbone, wrapper.Strophe, wrapper.$iq);
});
} else {
// Browser globals
factory(root.$, root._, root.Backbone, root.Strophe);
factory(root.$, root._, root.Backbone, root.Strophe, root.$iq);
}
}(this,function ($, _, Backbone, Strophe) {
}(this,function ($, _, Backbone, Strophe, $iq) {

// Add the **PubSub** plugin to Strophe
Strophe.addConnectionPlugin('Disco', {
Expand Down Expand Up @@ -64,7 +64,7 @@
query.node = node;
}

iq = $iq({to: to, type: 'get'})
var iq = $iq({to: to, type: 'get'})
.c('query', query);
this._connection.sendIQ(iq, function (response) {
_.each($('identity', response), function (node) {
Expand Down
10 changes: 5 additions & 5 deletions strophe.forms.js
Expand Up @@ -11,17 +11,17 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', 'underscore', 'strophe'], function ($, _, Strophe) {
define(['jquery', 'underscore', 'strophe'], function ($, _, wrapper) {
// Also create a global in case some scripts
// that are loaded still are looking for
// a global even when an AMD loader is in use.
return (Strophe.x = factory($, _, Strophe));
return (wrapper.Strophe.x = factory($, _, wrapper.Strophe, wrapper.$build));
});
} else {
// Browser globals
Strophe.x = factory(root.$, root._, root.Strophe);
root.Strophe.x = factory(root.$, root._, root.Strophe, root.$build);
}
}(this,function ($, _, Strophe) {
}(this,function ($, _, Strophe, $build) {

// **Option** contructor
var Option = function (opts) {
Expand Down Expand Up @@ -88,7 +88,7 @@
'var': this['var']
};
if (this.label) attrs.label = this.label;
xml = $build('field', attrs);
var xml = $build('field', attrs);
if (this.desc) xml.c('desc').t(this.desc).up();
if (this.required) xml.c('required').up();
_.each(this.values, function (value) {
Expand Down
8 changes: 4 additions & 4 deletions strophe.messaging.js
Expand Up @@ -10,17 +10,17 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', 'underscore', 'backbone', 'strophe'], function ($, _, Backbone, Strophe) {
define(['jquery', 'underscore', 'backbone', 'strophe'], function ($, _, Backbone, wrapper) {
// Also create a global in case some scripts
// that are loaded still are looking for
// a global even when an AMD loader is in use.
return factory($, _, Backbone, Strophe);
return factory($, _, Backbone, wrapper.Strophe, wrapper.$msg);
});
} else {
// Browser globals
factory(root.$, root._, root.Backbone, root.Strophe);
factory(root.$, root._, root.Backbone, root.Strophe, root.$msg);
}
}(this,function ($, _, Backbone, Strophe) {
}(this,function ($, _, Backbone, Strophe, $msg) {

Strophe.addConnectionPlugin('Messaging', {

Expand Down
8 changes: 4 additions & 4 deletions strophe.private.js
Expand Up @@ -11,17 +11,17 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', 'underscore', 'backbone', 'strophe'], function ($, _, Backbone, Strophe) {
define(['jquery', 'underscore', 'backbone', 'strophe'], function ($, _, Backbone, wrapper) {
// Also create a global in case some scripts
// that are loaded still are looking for
// a global even when an AMD loader is in use.
return factory($, _, Backbone, Strophe);
return factory($, _, Backbone, wrapper.Strophe, wrapper.$iq);
});
} else {
// Browser globals
factory(root.$, root._, root.Backbone, root.Strophe);
factory(root.$, root._, root.Backbone, root.Strophe, root.$iq);
}
}(this,function ($, _, Backbone, Strophe) {
}(this,function ($, _, Backbone, Strophe, $iq) {

Strophe.addConnectionPlugin('Private', {

Expand Down
8 changes: 4 additions & 4 deletions strophe.pubsub.js
Expand Up @@ -11,17 +11,17 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', 'underscore', 'backbone', 'strophe'], function ($, _, Backbone, Strophe) {
define(['jquery', 'underscore', 'backbone', 'strophe'], function ($, _, Backbone, wrapper) {
// Also create a global in case some scripts
// that are loaded still are looking for
// a global even when an AMD loader is in use.
return factory($, _, Backbone, Strophe);
return factory($, _, Backbone, wrapper.Strophe, wrapper.$build, wrapper.$iq);
});
} else {
// Browser globals
factory(root.$, root._, root.Backbone, root.Strophe);
factory(root.$, root._, root.Backbone, root.Strophe, root.$build, root.$iq);
}
}(this,function ($, _, Backbone, Strophe) {
}(this,function ($, _, Backbone, Strophe, $build, $iq) {

// Add the **PubSub** plugin to Strophe
Strophe.addConnectionPlugin('PubSub', {
Expand Down
8 changes: 4 additions & 4 deletions strophe.roster.js
Expand Up @@ -11,17 +11,17 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', 'underscore', 'backbone', 'strophe'], function ($, _, Backbone, Strophe) {
define(['jquery', 'underscore', 'backbone', 'strophe'], function ($, _, Backbone, wrapper) {
// Also create a global in case some scripts
// that are loaded still are looking for
// a global even when an AMD loader is in use.
return factory($, _, Backbone, Strophe);
return factory($, _, Backbone, wrapper.Strophe, wrapper.$iq, wrapper.$pres);
});
} else {
// Browser globals
factory(root.$, root._, root.Backbone, root.Strophe);
factory(root.$, root._, root.Backbone, root.Strophe, root.$iq, root.$pres);
}
}(this,function ($, _, Backbone, Strophe) {
}(this,function ($, _, Backbone, Strophe, $iq, $pres) {

Strophe.addConnectionPlugin('roster', {
_connection: null,
Expand Down
8 changes: 4 additions & 4 deletions strophe.vcard.js
Expand Up @@ -11,17 +11,17 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery', 'underscore', 'backbone', 'strophe'], function ($, _, Backbone, Strophe) {
define(['jquery', 'underscore', 'backbone', 'strophe'], function ($, _, Backbone, wrapper) {
// Also create a global in case some scripts
// that are loaded still are looking for
// a global even when an AMD loader is in use.
return factory($, _, Backbone, Strophe);
return factory($, _, Backbone, wrapper.Strophe, wrapper.$build, wrapper.$iq);
});
} else {
// Browser globals
factory(root.$, root._, root.Backbone, root.Strophe);
factory(root.$, root._, root.Backbone, root.Strophe, root.$build, root.$iq);
}
}(this,function ($, _, Backbone, Strophe) {
}(this,function ($, _, Backbone, Strophe, $build, $iq) {

Strophe.addConnectionPlugin('vCard', {
_connection: null,
Expand Down

0 comments on commit dc51c7a

Please sign in to comment.