Skip to content

Commit 8db1d2b

Browse files
author
Dan Lasky
committed
extract utils to iife
1 parent e6c447d commit 8db1d2b

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

src/shared/js/ajax.html

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,27 @@
3838
return output;
3939
}
4040

41+
var DataUtils = StrandLib.DataUtils;
42+
var BehaviorUtils = StrandLib.BehaviorUtils;
43+
var Request = StrandLib.Request;
44+
var RequestQueue = StrandLib.RequestQueue;
45+
4146
function Ajax(options) {
4247
this._eventPrefix = _eventPrefix;
4348
this.recent = {};
4449
this.requests = [];
45-
this.options = StrandLib.DataUtils.copy({},{
50+
this.options = DataUtils.copy({},{
4651
"contentType":"application/x-www-form-urlencoded",
47-
"method":StrandLib.Request.GET,
52+
"method":Request.GET,
4853
"withCredentials":false,
4954
"timeout":10000
5055
}, options);
5156
}
5257

53-
Ajax.GET = StrandLib.Request.GET;
54-
Ajax.POST = StrandLib.Request.POST;
55-
Ajax.PUT = StrandLib.Request.PUT;
56-
Ajax.DELETE = StrandLib.Request.DELETE;
58+
Ajax.GET = Request.GET;
59+
Ajax.POST = Request.POST;
60+
Ajax.PUT = Request.PUT;
61+
Ajax.DELETE = Request.DELETE;
5762

5863
Ajax.prototype = {
5964

@@ -66,7 +71,7 @@
6671

6772
execQueue: function(queueName) {
6873
var q = this._getQueue(queueName);
69-
var rq = new StrandLib.RequestQueue(q, this.options.concurrency, function(r) {
74+
var rq = new RequestQueue(q, this.options.concurrency, function(r) {
7075
this.current = r;
7176
}.bind(this));
7277
rq.exec();
@@ -101,15 +106,15 @@
101106

102107
_requestFactory: function(data, options) {
103108

104-
var copy = StrandLib.DataUtils.copy;
109+
var copy = DataUtils.copy;
105110

106111
options = copy({}, this.options, options);
107112

108113
var url = this.serializeUrl(options.url, options.urlParams);
109114
url = this.serializeQuery(url, options.query);
110115
data = this.setRequestData(options.method, options.contentType, data, options.body);
111116

112-
return new StrandLib.Request(copy(options, {
117+
return new Request(copy(options, {
113118
url: url,
114119
body: data,
115120
}));
@@ -165,7 +170,7 @@
165170
if (typeof override === "string") {
166171
return override;
167172
} else {
168-
input = StrandLib.DataUtils.copy({}, body, override);
173+
input = DataUtils.copy({}, body, override);
169174
}
170175
} else {
171176
input = body;
@@ -232,7 +237,7 @@
232237
// this.dispatchEvent(new CustomEvent(_eventPrefix + "error", {error:e, instance:this}));
233238
}
234239
}
235-
if ( StrandLib.DataUtils.isType(data, "array") ) {
240+
if ( DataUtils.isType(data, "array") ) {
236241
for (i = data.length - 1; i >= 0; i--) {
237242
obj = data[i];
238243
if (obj.name !== null && obj.value !== null) {
@@ -275,7 +280,7 @@
275280

276281

277282
Ajax.getBehavior = function() {
278-
var beh = StrandLib.BehaviorUtils.extend({},Ajax.prototype,{
283+
var beh = BehaviorUtils.extend({},Ajax.prototype,{
279284
properties: {
280285
url: {
281286
notify: true

0 commit comments

Comments
 (0)