From dc51c7ad47ba158a3a1637bd3af758a7c753e485 Mon Sep 17 00:00:00 2001 From: Yiorgis Gozadinos Date: Thu, 2 Jun 2016 11:19:41 +0200 Subject: [PATCH] Adapt to strophe being wrapped with require.js --- .jshintrc | 9 +++++++++ strophe.disco.js | 10 +++++----- strophe.forms.js | 10 +++++----- strophe.messaging.js | 8 ++++---- strophe.private.js | 8 ++++---- strophe.pubsub.js | 8 ++++---- strophe.roster.js | 8 ++++---- strophe.vcard.js | 8 ++++---- 8 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..8bde3fd --- /dev/null +++ b/.jshintrc @@ -0,0 +1,9 @@ +{ + "undef": true, + "strict": false, + "browser": true, + "debug": true, + "devel": true, + "jquery": false, + "predef": ["define", "require"] +} \ No newline at end of file diff --git a/strophe.disco.js b/strophe.disco.js index 797a7be..e1eccc0 100644 --- a/strophe.disco.js +++ b/strophe.disco.js @@ -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', { @@ -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) { diff --git a/strophe.forms.js b/strophe.forms.js index 8123693..d62d740 100644 --- a/strophe.forms.js +++ b/strophe.forms.js @@ -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) { @@ -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) { diff --git a/strophe.messaging.js b/strophe.messaging.js index 942bd96..6b16253 100644 --- a/strophe.messaging.js +++ b/strophe.messaging.js @@ -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', { diff --git a/strophe.private.js b/strophe.private.js index 93b415d..ffc2cf6 100644 --- a/strophe.private.js +++ b/strophe.private.js @@ -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', { diff --git a/strophe.pubsub.js b/strophe.pubsub.js index 843170e..3d7351d 100644 --- a/strophe.pubsub.js +++ b/strophe.pubsub.js @@ -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', { diff --git a/strophe.roster.js b/strophe.roster.js index 52959c3..225c94d 100644 --- a/strophe.roster.js +++ b/strophe.roster.js @@ -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, diff --git a/strophe.vcard.js b/strophe.vcard.js index f831115..6bb48e6 100644 --- a/strophe.vcard.js +++ b/strophe.vcard.js @@ -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,