Permalink
Browse files

update jquery-ui-rails to 3.0 which allows us to bump jquery-fileuplo…

…ad to 5.19.x
  • Loading branch information...
1 parent 6f894c5 commit ac7f6127d0ab9925d671bc5b83c524c7bb763c7a @agrobbin committed Dec 27, 2012
Showing with 61 additions and 84 deletions.
  1. +1 −1 Gemfile
  2. +2 −2 Gemfile.lock
  3. +1 −1 app/assets/javascripts/application.js
  4. +57 −80 vendor/assets/javascripts/jquery-fileupload.js
View
@@ -7,7 +7,7 @@ gem 'google-api', '~> 0.3.0'
gem 'haml-rails', '~> 0.3.5'
gem 'highcharts-js-rails', path: '~/Rails/gems/highcharts-js-rails' # '~> 0.1.11'
gem 'jquery-rails', '2.1.4'
-gem 'jquery-ui-rails', '2.0.2'
+gem 'jquery-ui-rails', '~> 3.0.0'
gem 'kaminari', '~> 0.14.1'
gem 'mysql2', '~> 0.3.11'
gem 'omniauth-google-oauth2', '~> 0.1.13'
View
@@ -90,7 +90,7 @@ GEM
jquery-rails (2.1.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
- jquery-ui-rails (2.0.2)
+ jquery-ui-rails (3.0.0)
jquery-rails
railties (>= 3.1.0)
json (1.7.5)
@@ -246,7 +246,7 @@ DEPENDENCIES
haml-rails (~> 0.3.5)
highcharts-js-rails!
jquery-rails (= 2.1.4)
- jquery-ui-rails (= 2.0.2)
+ jquery-ui-rails (~> 3.0.0)
kaminari (~> 0.14.1)
letter_opener (~> 1.0.0)
mysql2 (~> 0.3.11)
@@ -12,7 +12,7 @@
//
//= require jquery
//= require jquery_ujs
-//= require jquery.effects.slide
+//= require jquery.ui.effect-slide
//= require jquery.ui.sortable
//= require jquery-cookie
//= require jquery-fileupload
@@ -1,5 +1,5 @@
/*
- * jQuery File Upload Plugin 5.18
+ * jQuery File Upload Plugin 5.19.7
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
@@ -10,7 +10,7 @@
*/
/*jslint nomen: true, unparam: true, regexp: true */
-/*global define, window, document, Blob, FormData, location */
+/*global define, window, document, File, Blob, FormData, location */
(function (factory) {
'use strict';
@@ -44,10 +44,6 @@
$.widget('blueimp.fileupload', {
options: {
- // The namespace used for event handler binding on the fileInput,
- // dropZone and pasteZone document nodes.
- // If not set, the name of the widget ("fileupload") is used.
- namespace: undefined,
// The drop target element(s), by the default the complete document.
// Set to null to disable drag & drop support:
dropZone: $(document),
@@ -180,7 +176,6 @@
// A list of options that require a refresh after assigning a new value:
_refreshOptionsList: [
- 'namespace',
'fileInput',
'dropZone',
'pasteZone',
@@ -310,10 +305,8 @@
options.headers['Content-Range'] = options.contentRange;
}
if (!multipart) {
- // For cross domain requests, the X-File-Name header
- // must be allowed via Access-Control-Allow-Headers
- // or removed using the beforeSend callback:
- options.headers['X-File-Name'] = file.name;
+ options.headers['Content-Disposition'] = 'attachment; filename="' +
+ encodeURI(file.name) + '"';
options.contentType = file.type;
options.data = options.blob || file;
} else if ($.support.xhrFormDataFileUpload) {
@@ -346,18 +339,17 @@
});
}
if (options.blob) {
- // For cross domain requests, the X-File-* headers
- // must be allowed via Access-Control-Allow-Headers
- // or removed using the beforeSend callback:
- options.headers['X-File-Name'] = file.name;
- options.headers['X-File-Type'] = file.type;
+ options.headers['Content-Disposition'] = 'attachment; filename="' +
+ encodeURI(file.name) + '"';
formData.append(paramName, options.blob, file.name);
} else {
$.each(options.files, function (index, file) {
- // File objects are also Blob instances.
+ // Files are also Blob instances, but some browsers
+ // (Firefox 3.6) support the File API but not Blobs.
// This check allows the tests to run with
// dummy objects:
- if (file instanceof Blob) {
+ if ((window.Blob && file instanceof Blob) ||
+ (window.File && file instanceof File)) {
formData.append(
options.paramName[index] || paramName,
file,
@@ -534,7 +526,8 @@
o.blob = slice.call(
file,
ub,
- ub + mcs
+ ub + mcs,
+ file.type
);
// Store the current chunk size, as the blob itself
// will be dereferenced after data processing:
@@ -653,18 +646,18 @@
_onSend: function (e, data) {
var that = this,
jqXHR,
+ aborted,
slot,
pipe,
options = that._getAJAXSettings(data),
- send = function (resolve, args) {
+ send = function () {
that._sending += 1;
// Set timer for bitrate progress calculation:
options._bitrateTimer = new that._BitrateTimer();
jqXHR = jqXHR || (
- (resolve !== false &&
- that._trigger('send', e, options) !== false &&
- (that._chunkedUpload(options) || $.ajax(options))) ||
- that._getXHRPromise(false, options.context, args)
+ ((aborted || that._trigger('send', e, options) === false) &&
+ that._getXHRPromise(false, options.context, aborted)) ||
+ that._chunkedUpload(options) || $.ajax(options)
).done(function (result, textStatus, jqXHR) {
that._onDone(result, textStatus, jqXHR, options);
}).fail(function (jqXHR, textStatus, errorThrown) {
@@ -714,12 +707,12 @@
// which is delegated to the jqXHR object of the current upload,
// and jqXHR callbacks mapped to the equivalent Promise methods:
pipe.abort = function () {
- var args = [undefined, 'abort', 'abort'];
+ aborted = [undefined, 'abort', 'abort'];
if (!jqXHR) {
if (slot) {
- slot.rejectWith(pipe, args);
+ slot.rejectWith(options.context, aborted);
}
- return send(false, args);
+ return send();
}
return jqXHR.abort();
};
@@ -767,7 +760,8 @@
that._onSend(e, this);
return this.jqXHR;
};
- return (result = that._trigger('add', e, newData));
+ result = that._trigger('add', e, newData);
+ return result;
});
return result;
},
@@ -899,6 +893,12 @@
// support the File API and we add a pseudo File object with
// the input value as name with path information removed:
files = [{name: value.replace(/^.*\\/, '')}];
+ } else if (files[0].name === undefined && files[0].fileName) {
+ // File normalization for Safari 4 and Firefox 3:
+ $.each(files, function (index, file) {
+ file.name = file.fileName;
+ file.size = file.fileSize;
+ });
}
return $.Deferred().resolve(files).promise();
},
@@ -919,12 +919,12 @@
},
_onChange: function (e) {
- var that = e.data.fileupload,
+ var that = this,
data = {
fileInput: $(e.target),
form: $(e.target.form)
};
- that._getFileInputFiles(data.fileInput).always(function (files) {
+ this._getFileInputFiles(data.fileInput).always(function (files) {
data.files = files;
if (that.options.replaceFileInput) {
that._replaceFileInput(data.fileInput);
@@ -936,8 +936,7 @@
},
_onPaste: function (e) {
- var that = e.data.fileupload,
- cbd = e.originalEvent.clipboardData,
+ var cbd = e.originalEvent.clipboardData,
items = (cbd && cbd.items) || [],
data = {files: []};
$.each(items, function (index, item) {
@@ -946,18 +945,20 @@
data.files.push(file);
}
});
- if (that._trigger('paste', e, data) === false ||
- that._onAdd(e, data) === false) {
+ if (this._trigger('paste', e, data) === false ||
+ this._onAdd(e, data) === false) {
return false;
}
},
_onDrop: function (e) {
- e.preventDefault();
- var that = e.data.fileupload,
+ var that = this,
dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer,
data = {};
- that._getDroppedFiles(dataTransfer).always(function (files) {
+ if (dataTransfer && dataTransfer.files && dataTransfer.files.length) {
+ e.preventDefault();
+ }
+ this._getDroppedFiles(dataTransfer).always(function (files) {
data.files = files;
if (that._trigger('drop', e, data) !== false) {
that._onAdd(e, data);
@@ -966,47 +967,43 @@
},
_onDragOver: function (e) {
- var that = e.data.fileupload,
- dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer;
- if (that._trigger('dragover', e) === false) {
+ var dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer;
+ if (this._trigger('dragover', e) === false) {
return false;
}
- if (dataTransfer) {
+ if (dataTransfer && $.inArray('Files', dataTransfer.types) !== -1) {
dataTransfer.dropEffect = 'copy';
+ e.preventDefault();
}
- e.preventDefault();
},
_initEventHandlers: function () {
- var ns = this.options.namespace;
if (this._isXHRUpload(this.options)) {
- this.options.dropZone
- .bind('dragover.' + ns, {fileupload: this}, this._onDragOver)
- .bind('drop.' + ns, {fileupload: this}, this._onDrop);
- this.options.pasteZone
- .bind('paste.' + ns, {fileupload: this}, this._onPaste);
+ this._on(this.options.dropZone, {
+ dragover: this._onDragOver,
+ drop: this._onDrop
+ });
+ this._on(this.options.pasteZone, {
+ paste: this._onPaste
+ });
}
- this.options.fileInput
- .bind('change.' + ns, {fileupload: this}, this._onChange);
+ this._on(this.options.fileInput, {
+ change: this._onChange
+ });
},
_destroyEventHandlers: function () {
- var ns = this.options.namespace;
- this.options.dropZone
- .unbind('dragover.' + ns, this._onDragOver)
- .unbind('drop.' + ns, this._onDrop);
- this.options.pasteZone
- .unbind('paste.' + ns, this._onPaste);
- this.options.fileInput
- .unbind('change.' + ns, this._onChange);
+ this._off(this.options.dropZone, 'dragover drop');
+ this._off(this.options.pasteZone, 'paste');
+ this._off(this.options.fileInput, 'change');
},
_setOption: function (key, value) {
var refresh = $.inArray(key, this._refreshOptionsList) !== -1;
if (refresh) {
this._destroyEventHandlers();
}
- $.Widget.prototype._setOption.call(this, key, value);
+ this._super(key, value);
if (refresh) {
this._initSpecialOptions();
this._initEventHandlers();
@@ -1033,35 +1030,15 @@
var options = this.options;
// Initialize options set via HTML5 data-attributes:
$.extend(options, $(this.element[0].cloneNode(false)).data());
- options.namespace = options.namespace || this.widgetName;
this._initSpecialOptions();
this._slots = [];
this._sequence = this._getXHRPromise(true);
this._sending = this._active = this._loaded = this._total = 0;
this._initEventHandlers();
},
- destroy: function () {
+ _destroy: function () {
this._destroyEventHandlers();
- $.Widget.prototype.destroy.call(this);
- },
-
- enable: function () {
- var wasDisabled = false;
- if (this.options.disabled) {
- wasDisabled = true;
- }
- $.Widget.prototype.enable.call(this);
- if (wasDisabled) {
- this._initEventHandlers();
- }
- },
-
- disable: function () {
- if (!this.options.disabled) {
- this._destroyEventHandlers();
- }
- $.Widget.prototype.disable.call(this);
},
// This method is exposed to the widget API and allows adding files

0 comments on commit ac7f612

Please sign in to comment.