Merge pull request #24 from feychenie/patch-1

Remove explicit dependancy to jQuery
This commit is contained in:
Joe Vu 2015-11-12 22:35:43 -08:00
commit 22d4b7c1e0

View File

@ -13,21 +13,21 @@
// AMD // AMD
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
define(['underscore', 'jquery', 'backbone'], function(_, $, Backbone){ define(['underscore', 'backbone'], function(_, Backbone){
factory(root, Backbone, _, $); factory(root, Backbone, _);
}); });
// NodeJS/CommonJS // NodeJS/CommonJS
} else if (typeof exports !== 'undefined') { } else if (typeof exports !== 'undefined') {
var _ = require('underscore'), $ = require('jquery'), Backbone = require('backbone'); var _ = require('underscore'), Backbone = require('backbone');
factory(root, Backbone, _, $); factory(root, Backbone, _);
// Browser global // Browser global
} else { } else {
factory(root, root.Backbone, root._, root.$); factory(root, root.Backbone, root._);
} }
}(this, function(root, Backbone, _, $) { }(this, function(root, Backbone, _) {
'use strict'; 'use strict';
// Clone the original Backbone.Model.prototype as superClass // Clone the original Backbone.Model.prototype as superClass
@ -100,12 +100,14 @@
options.processData = false; options.processData = false;
options.contentType = false; options.contentType = false;
// Apply custom XHR for processing status & listen to "progress" // Handle "progress" events
var that = this; var that = this;
options.xhr = function() { var beforeSend = options.beforeSend;
var xhr = $.ajaxSettings.xhr(); options.beforeSend = function(xhr){
xhr.upload.addEventListener('progress', that._progressHandler.bind(that), false); xhr.upload.addEventListener('progress', that._progressHandler.bind(that), false);
return xhr; if(beforeSend) {
return beforeSend.apply(this, arguments);
}
} }
} }