Skip to content

Commit

Permalink
Removed some unused references to the old promise and defer functiona…
Browse files Browse the repository at this point in the history
…lity.
  • Loading branch information
fizker committed Aug 7, 2014
1 parent d8d1773 commit 28a0ebc
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/ajax.js
Expand Up @@ -7,15 +7,11 @@ var defaults = {
headers: {}
}
var orgDefaults = defaults
var defer
var qs
var contentTypes = {
json: /^application\/json/
}

ajax.defer = function(constr) {
defer = constr
}
ajax.qs = function(func) {
qs = func
}
Expand All @@ -29,7 +25,6 @@ ajax.defaults = function(newDefaults) {
}
ajax.reset = function() {
defaults = orgDefaults
defer = null
qs = null
}

Expand All @@ -47,8 +42,6 @@ ajax.patch = ajax.request.bind(ajax, 'PATCH')
ajax.options = ajax.request.bind(ajax, 'OPTIONS')
ajax.head = ajax.request.bind(ajax, 'HEAD')

return ajax

function getOptions(args) {
var opts = {}
var arg
Expand Down Expand Up @@ -109,15 +102,11 @@ function ajax(/*...args*/) {
if(deferred._ans) {
resolve(deferred._ans)
}
}).then(function(xhr) {
delete xhr.then
return xhr
})

if(ret.promise) {
ret.promise = ret.promise.then(function(xhr) {
delete xhr.then
return xhr
})
ret.then = ret.promise.then.bind(ret.promise)
}
ret.then = ret.promise.then.bind(ret.promise)

return ret

Expand All @@ -131,9 +120,7 @@ function ajax(/*...args*/) {
if(opts.onload) {
opts.onload(res)
}
if(deferred) {
deferred.resolve(res)
}
deferred.resolve(res)
}
}

Expand Down

0 comments on commit 28a0ebc

Please sign in to comment.