Skip to content

Updated to latest version of the js files #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from Jan 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
12 changes: 7 additions & 5 deletions vendor/assets/javascripts/jquery-fileupload/cors/jquery.xdr-transport.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* jQuery XDomainRequest Transport Plugin 1.1.2
* jQuery XDomainRequest Transport Plugin 1.1.3
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2011, Sebastian Tschan
Expand Down Expand Up @@ -36,6 +36,7 @@
var xdr;
return {
send: function (headers, completeCallback) {
var addParamChar = /\?/.test(s.url) ? '&' : '?';
function callback(status, statusText, responses, responseHeaders) {
xdr.onload = xdr.onerror = xdr.ontimeout = $.noop;
xdr = null;
Expand All @@ -44,12 +45,13 @@
xdr = new XDomainRequest();
// XDomainRequest only supports GET and POST:
if (s.type === 'DELETE') {
s.url = s.url + (/\?/.test(s.url) ? '&' : '?') +
'_method=DELETE';
s.url = s.url + addParamChar + '_method=DELETE';
s.type = 'POST';
} else if (s.type === 'PUT') {
s.url = s.url + (/\?/.test(s.url) ? '&' : '?') +
'_method=PUT';
s.url = s.url + addParamChar + '_method=PUT';
s.type = 'POST';
} else if (s.type === 'PATCH') {
s.url = s.url + addParamChar + '_method=PATCH';
s.type = 'POST';
}
xdr.open(s.type, s.url);
Expand Down
Empty file.
116 changes: 92 additions & 24 deletions vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* jQuery File Upload User Interface Plugin 6.11
* jQuery File Upload User Interface Plugin 7.3
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
Expand Down Expand Up @@ -83,7 +83,8 @@
// widget (via file input selection, drag & drop or add API call).
// See the basic file upload widget for more information:
add: function (e, data) {
var that = $(this).data('fileupload'),
var that = $(this).data('blueimp-fileupload') ||
$(this).data('fileupload'),
options = that.options,
files = data.files;
$(this).fileupload('process', data).done(function () {
Expand All @@ -94,7 +95,7 @@
options.filesContainer[
options.prependFiles ? 'prepend' : 'append'
](data.context);
that._renderPreviews(files, data.context);
that._renderPreviews(data);
that._forceReflow(data.context);
that._transition(data.context).done(
function () {
Expand All @@ -109,7 +110,8 @@
},
// Callback for the start of each file upload request:
send: function (e, data) {
var that = $(this).data('fileupload');
var that = $(this).data('blueimp-fileupload') ||
$(this).data('fileupload');
if (!data.isValidated) {
if (!data.maxNumberOfFilesAdjusted) {
that._adjustMaxNumberOfFiles(-data.files.length);
Expand Down Expand Up @@ -138,13 +140,16 @@
},
// Callback for successful uploads:
done: function (e, data) {
var that = $(this).data('fileupload'),
template;
var that = $(this).data('blueimp-fileupload') ||
$(this).data('fileupload'),
files = that._getFilesFromResponse(data),
template,
deferred;
if (data.context) {
data.context.each(function (index) {
var file = ($.isArray(data.result) &&
data.result[index]) ||
{error: 'Empty file upload result'};
var file = files[index] ||
{error: 'Empty file upload result'},
deferred = that._addFinishedDeferreds();
if (file.error) {
that._adjustMaxNumberOfFiles(1);
}
Expand All @@ -158,14 +163,16 @@
function () {
data.context = $(this);
that._trigger('completed', e, data);
that._trigger('finished', e, data);
deferred.resolve();
}
);
}
);
});
} else {
if ($.isArray(data.result)) {
$.each(data.result, function (index, file) {
if (files.length) {
$.each(files, function (index, file) {
if (data.maxNumberOfFilesAdjusted && file.error) {
that._adjustMaxNumberOfFiles(1);
} else if (!data.maxNumberOfFilesAdjusted &&
Expand All @@ -175,21 +182,26 @@
});
data.maxNumberOfFilesAdjusted = true;
}
template = that._renderDownload(data.result)
template = that._renderDownload(files)
.appendTo(that.options.filesContainer);
that._forceReflow(template);
deferred = that._addFinishedDeferreds();
that._transition(template).done(
function () {
data.context = $(this);
that._trigger('completed', e, data);
that._trigger('finished', e, data);
deferred.resolve();
}
);
}
},
// Callback for failed (abort or error) uploads:
fail: function (e, data) {
var that = $(this).data('fileupload'),
template;
var that = $(this).data('blueimp-fileupload') ||
$(this).data('fileupload'),
template,
deferred;
if (data.maxNumberOfFilesAdjusted) {
that._adjustMaxNumberOfFiles(data.files.length);
}
Expand All @@ -199,6 +211,7 @@
var file = data.files[index];
file.error = file.error || data.errorThrown ||
true;
deferred = that._addFinishedDeferreds();
that._transition($(this)).done(
function () {
var node = $(this);
Expand All @@ -209,15 +222,20 @@
function () {
data.context = $(this);
that._trigger('failed', e, data);
that._trigger('finished', e, data);
deferred.resolve();
}
);
}
);
} else {
deferred = that._addFinishedDeferreds();
that._transition($(this)).done(
function () {
$(this).remove();
that._trigger('failed', e, data);
that._trigger('finished', e, data);
deferred.resolve();
}
);
}
Expand All @@ -227,14 +245,19 @@
.appendTo(that.options.filesContainer)
.data('data', data);
that._forceReflow(data.context);
deferred = that._addFinishedDeferreds();
that._transition(data.context).done(
function () {
data.context = $(this);
that._trigger('failed', e, data);
that._trigger('finished', e, data);
deferred.resolve();
}
);
} else {
that._trigger('failed', e, data);
that._trigger('finished', e, data);
that._addFinishedDeferreds().resolve();
}
},
// Callback for upload progress events:
Expand All @@ -258,7 +281,8 @@
.find('.progress-extended');
if (extendedProgressNode.length) {
extendedProgressNode.html(
$this.data('fileupload')._renderExtendedProgress(data)
($this.data('blueimp-fileupload') || $this.data('fileupload'))
._renderExtendedProgress(data)
);
}
globalProgressNode
Expand All @@ -271,7 +295,9 @@
},
// Callback for uploads start, equivalent to the global ajaxStart event:
start: function (e) {
var that = $(this).data('fileupload');
var that = $(this).data('blueimp-fileupload') ||
$(this).data('fileupload');
that._resetFinishedDeferreds();
that._transition($(this).find('.fileupload-progress')).done(
function () {
that._trigger('started', e);
Expand All @@ -280,20 +306,27 @@
},
// Callback for uploads stop, equivalent to the global ajaxStop event:
stop: function (e) {
var that = $(this).data('fileupload');
var that = $(this).data('blueimp-fileupload') ||
$(this).data('fileupload'),
deferred = that._addFinishedDeferreds();
$.when.apply($, that._getFinishedDeferreds())
.done(function () {
that._trigger('stopped', e);
});
that._transition($(this).find('.fileupload-progress')).done(
function () {
$(this).find('.progress')
.attr('aria-valuenow', '0')
.find('.bar').css('width', '0%');
$(this).find('.progress-extended').html(' ');
that._trigger('stopped', e);
deferred.resolve();
}
);
},
// Callback for file deletion:
destroy: function (e, data) {
var that = $(this).data('fileupload');
var that = $(this).data('blueimp-fileupload') ||
$(this).data('fileupload');
if (data.url) {
$.ajax(data);
that._adjustMaxNumberOfFiles(1);
Expand All @@ -307,6 +340,29 @@
}
},

_resetFinishedDeferreds: function () {
this._finishedUploads = [];
},

_addFinishedDeferreds: function (deferred) {
if (!deferred) {
deferred = $.Deferred();
}
this._finishedUploads.push(deferred);
return deferred;
},

_getFinishedDeferreds: function () {
return this._finishedUploads;
},

_getFilesFromResponse: function (data) {
if (data.result && $.isArray(data.result.files)) {
return data.result.files;
}
return [];
},

// Link handler, that allows to download files
// by drag & drop of the links to the desktop:
_enableDragToDesktop: function () {
Expand Down Expand Up @@ -361,7 +417,7 @@
if (bits >= 1000) {
return (bits / 1000).toFixed(2) + ' kbit/s';
}
return bits + ' bit/s';
return bits.toFixed(2) + ' bit/s';
},

_formatTime: function (seconds) {
Expand Down Expand Up @@ -472,18 +528,22 @@
)) || dfd.resolveWith(node)) && dfd;
},

_renderPreviews: function (files, nodes) {
_renderPreviews: function (data) {
var that = this,
options = this.options;
nodes.find('.preview span').each(function (index, element) {
var file = files[index];
data.context.find('.preview span').each(function (index, element) {
var file = data.files[index];
if (options.previewSourceFileTypes.test(file.type) &&
($.type(options.previewSourceMaxFileSize) !== 'number' ||
file.size < options.previewSourceMaxFileSize)) {
that._processingQueue = that._processingQueue.pipe(function () {
var dfd = $.Deferred();
var dfd = $.Deferred(),
ev = $.Event('previewdone', {
target: element
});
that._renderPreview(file, $(element)).done(
function () {
that._trigger(ev.type, ev, data);
dfd.resolveWith(that);
}
);
Expand Down Expand Up @@ -691,6 +751,13 @@
this._initRegExpOptions();
},

_setOption: function (key, value) {
this._super(key, value);
if (key === 'maxNumberOfFiles') {
this._adjustMaxNumberOfFiles(0);
}
},

_create: function () {
this._super();
this._refreshOptionsList.push(
Expand All @@ -704,6 +771,7 @@
return this._processingQueue;
};
}
this._resetFinishedDeferreds();
},

enable: function () {
Expand Down
Loading