Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
uglymunky committed Feb 28, 2014
1 parent 69a2c25 commit 680a45b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
18 changes: 13 additions & 5 deletions dist/amd/jquery.ajaxHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ define(['jquery'], function ($, undefined) {
* (used by unit tests)
*/
, remove: function () {
$.ajax = $.ajaxHandler.origAjax;
if ($.ajaxHandler.origAjax) {
$.ajax = $.ajaxHandler.origAjax;
$.ajaxHandler.origAjax = undefined;
}

delete $.ajaxHandler.options;
$.ajaxHandler.origAjax = undefined;
}


Expand Down Expand Up @@ -155,10 +157,12 @@ define(['jquery'], function ($, undefined) {
* @param jqXhr
*/
, onBeforeSend: function (jqXhr, options) {
var ajaxHandlerOptions = options.ajaxHandlerOptions;
var origUrl
, ajaxHandlerOptions = options.ajaxHandlerOptions;

if (typeof ajaxHandlerOptions.url == 'function') {
options.url = ajaxHandlerOptions.url.call(this, options);
if (typeof ajaxHandlerOptions.corsUrl == 'function') {
origUrl = options.url;
options.url = ajaxHandlerOptions.corsUrl.call(this, options);
}

// Add any custom request headers
Expand All @@ -168,6 +172,10 @@ define(['jquery'], function ($, undefined) {
});
}

if (origUrl) {
options.url = origUrl;
}

// Make sure to call any pre-existing .beforeSend() callbacks
if (typeof ajaxHandlerOptions.origBeforeSend == 'function') {
ajaxHandlerOptions.origBeforeSend.call(this, jqXhr, options);
Expand Down
2 changes: 1 addition & 1 deletion dist/amd/jquery.ajaxHandler.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions dist/iife/jquery.ajaxHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
* (used by unit tests)
*/
, remove: function () {
$.ajax = $.ajaxHandler.origAjax;
if ($.ajaxHandler.origAjax) {
$.ajax = $.ajaxHandler.origAjax;
$.ajaxHandler.origAjax = undefined;
}

delete $.ajaxHandler.options;
$.ajaxHandler.origAjax = undefined;
}


Expand Down Expand Up @@ -155,10 +157,12 @@
* @param jqXhr
*/
, onBeforeSend: function (jqXhr, options) {
var ajaxHandlerOptions = options.ajaxHandlerOptions;
var origUrl
, ajaxHandlerOptions = options.ajaxHandlerOptions;

if (typeof ajaxHandlerOptions.url == 'function') {
options.url = ajaxHandlerOptions.url.call(this, options);
if (typeof ajaxHandlerOptions.corsUrl == 'function') {
origUrl = options.url;
options.url = ajaxHandlerOptions.corsUrl.call(this, options);
}

// Add any custom request headers
Expand All @@ -168,6 +172,10 @@
});
}

if (origUrl) {
options.url = origUrl;
}

// Make sure to call any pre-existing .beforeSend() callbacks
if (typeof ajaxHandlerOptions.origBeforeSend == 'function') {
ajaxHandlerOptions.origBeforeSend.call(this, jqXhr, options);
Expand Down
2 changes: 1 addition & 1 deletion dist/iife/jquery.ajaxHandler.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 680a45b

Please sign in to comment.