Skip to content

Commit

Permalink
Merge pull request tors#9 from davekaro/master
Browse files Browse the repository at this point in the history
Updated javascripts
  • Loading branch information
tors committed Jul 27, 2012
2 parents f0efe6a + 97708d3 commit 7fdc655
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 121 deletions.
72 changes: 52 additions & 20 deletions vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js
@@ -1,5 +1,5 @@
/*
* jQuery File Upload User Interface Plugin 6.8.2
* jQuery File Upload User Interface Plugin 6.9.3
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
Expand Down Expand Up @@ -128,9 +128,10 @@
.find('.progress').addClass(
!$.support.transition && 'progress-animated'
)
.attr('aria-valuenow', 100)
.find('.bar').css(
'width',
parseInt(100, 10) + '%'
'100%'
);
}
return that._trigger('sent', e, data);
Expand All @@ -150,7 +151,6 @@
function () {
var node = $(this);
template = that._renderDownload([file])
.css('height', node.height())
.replaceAll(node);
that._forceReflow(template);
that._transition(template).done(
Expand Down Expand Up @@ -227,26 +227,34 @@
// Callback for upload progress events:
progress: function (e, data) {
if (data.context) {
data.context.find('.bar').css(
'width',
parseInt(data.loaded / data.total * 100, 10) + '%'
);
var progress = parseInt(data.loaded / data.total * 100, 10);
data.context.find('.progress')
.attr('aria-valuenow', progress)
.find('.bar').css(
'width',
progress + '%'
);
}
},
// Callback for global upload progress events:
progressall: function (e, data) {
var $this = $(this);
$this.find('.fileupload-progress')
var $this = $(this),
progress = parseInt(data.loaded / data.total * 100, 10),
globalProgressNode = $this.find('.fileupload-progress'),
extendedProgressNode = globalProgressNode
.find('.progress-extended');
if (extendedProgressNode.length) {
extendedProgressNode.html(
$this.data('fileupload')._renderExtendedProgress(data)
);
}
globalProgressNode
.find('.progress')
.attr('aria-valuenow', progress)
.find('.bar').css(
'width',
parseInt(data.loaded / data.total * 100, 10) + '%'
).end()
.find('.progress-extended').each(function () {
$(this).html(
$this.data('fileupload')
._renderExtendedProgress(data)
);
});
progress + '%'
);
},
// Callback for uploads start, equivalent to the global ajaxStart event:
start: function (e) {
Expand All @@ -262,7 +270,9 @@
var that = $(this).data('fileupload');
that._transition($(this).find('.fileupload-progress')).done(
function () {
$(this).find('.bar').css('width', '0%');
$(this).find('.progress')
.attr('aria-valuenow', '0')
.find('.bar').css('width', '0%');
$(this).find('.progress-extended').html(' ');
that._trigger('stopped', e);
}
Expand Down Expand Up @@ -519,8 +529,8 @@
},

_forceReflow: function (node) {
this._reflow = $.support.transition &&
node.length && node[0].offsetWidth;
return $.support.transition && node.length &&
node[0].offsetWidth;
},

_transition: function (node) {
Expand Down Expand Up @@ -653,10 +663,32 @@
}
},

_stringToRegExp: function (str) {
var parts = str.split('/'),
modifiers = parts.pop();
parts.shift();
return new RegExp(parts.join('/'), modifiers);
},

_initRegExpOptions: function () {
var options = this.options;
if ($.type(options.acceptFileTypes) === 'string') {
options.acceptFileTypes = this._stringToRegExp(
options.acceptFileTypes
);
}
if ($.type(options.previewSourceFileTypes) === 'string') {
options.previewSourceFileTypes = this._stringToRegExp(
options.previewSourceFileTypes
);
}
},

_initSpecialOptions: function () {
parentWidget.prototype._initSpecialOptions.call(this);
this._initFilesContainer();
this._initTemplates();
this._initRegExpOptions();
},

_create: function () {
Expand Down
49 changes: 36 additions & 13 deletions vendor/assets/javascripts/jquery-fileupload/jquery.fileupload.js
@@ -1,5 +1,5 @@
/*
* jQuery File Upload Plugin 5.11.2
* jQuery File Upload Plugin 5.13
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
Expand Down Expand Up @@ -210,10 +210,10 @@
if (typeof options.formData === 'function') {
return options.formData(options.form);
}
if ($.isArray(options.formData)) {
if ($.isArray(options.formData)) {
return options.formData;
}
if (options.formData) {
if (options.formData) {
formData = [];
$.each(options.formData, function (name, value) {
formData.push({name: name, value: value});
Expand Down Expand Up @@ -530,6 +530,10 @@
ub + i * mcs,
ub + (i + 1) * mcs
);
// Expose the chunk index:
o.chunkIndex = i;
// Expose the number of chunks:
o.chunksNumber = n;
// Store the current chunk size, as the blob itself
// will be dereferenced after data processing:
o.chunkSize = o.blob.size;
Expand Down Expand Up @@ -776,19 +780,30 @@
}
},

_getFileInputFiles: function (fileInput) {
fileInput = $(fileInput);
var files = $.each($.makeArray(fileInput.prop('files')), this._normalizeFile),
value;
if (!files.length) {
value = fileInput.prop('value');
if (!value) {
return [];
}
// If the files property is not available, the browser does not
// 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(/^.*\\/, '')}];
}
return files;
},

_onChange: function (e) {
var that = e.data.fileupload,
data = {
files: $.each($.makeArray(e.target.files), that._normalizeFile),
fileInput: $(e.target),
form: $(e.target.form)
};
if (!data.files.length) {
// If the files property is not available, the browser does not
// support the File API and we add a pseudo File object with
// the input value as name with path information removed:
data.files = [{name: e.target.value.replace(/^.*\\/, '')}];
}
data.files = that._getFileInputFiles(data.fileInput);
if (that.options.replaceFileInput) {
that._replaceFileInput(data.fileInput);
}
Expand Down Expand Up @@ -838,7 +853,7 @@
return false;
}
if (dataTransfer) {
dataTransfer.dropEffect = dataTransfer.effectAllowed = 'copy';
dataTransfer.dropEffect = 'copy';
}
e.preventDefault();
},
Expand Down Expand Up @@ -925,7 +940,11 @@
if (!data || this.options.disabled) {
return;
}
data.files = $.each($.makeArray(data.files), this._normalizeFile);
if (data.fileInput && !data.files) {
data.files = this._getFileInputFiles(data.fileInput);
} else {
data.files = $.each($.makeArray(data.files), this._normalizeFile);
}
this._onAdd(null, data);
},

Expand All @@ -936,7 +955,11 @@
// The method returns a Promise object for the file upload call.
send: function (data) {
if (data && !this.options.disabled) {
data.files = $.each($.makeArray(data.files), this._normalizeFile);
if (data.fileInput && !data.files) {
data.files = this._getFileInputFiles(data.fileInput);
} else {
data.files = $.each($.makeArray(data.files), this._normalizeFile);
}
if (data.files.length) {
return this._onSend(null, data);
}
Expand Down
107 changes: 46 additions & 61 deletions vendor/assets/javascripts/jquery-fileupload/vendor/canvas-to-blob.js
@@ -1,5 +1,5 @@
/*
* JavaScript Canvas to Blob 1.0.1
* JavaScript Canvas to Blob 2.0.1
* https://github.com/blueimp/JavaScript-Canvas-to-Blob
*
* Copyright 2012, Sebastian Tschan
Expand All @@ -15,71 +15,56 @@
/*jslint nomen: true, regexp: true */
/*global window, atob, ArrayBuffer, Uint8Array, define */

(function ($) {
(function (window) {
'use strict';

var BlobBuilder = window.MozBlobBuilder ||
window.WebKitBlobBuilder || window.BlobBuilder,
blobTypes = /^image\/(jpeg|png)$/,

// Converts a canvas element to a Blob or File object:
canvasToBlob = function (canvas, callback, options) {
options = options || {};
if (canvas.toBlob) {
canvas.toBlob(callback, options.type);
return true;
} else if (canvas.mozGetAsFile) {
var name = options.name;
callback(canvas.mozGetAsFile(
(blobTypes.test(options.type) && name) ||
((name && name.replace(/\..+$/, '')) || 'blob') + '.png',
options.type
));
return true;
} else if (canvas.toDataURL && BlobBuilder && window.atob &&
window.ArrayBuffer && window.Uint8Array) {
callback(canvasToBlob.dataURItoBlob(
canvas.toDataURL(options.type)
));
return true;
}
return false;
};

// Converts a dataURI to a Blob:
canvasToBlob.dataURItoBlob = function (dataURI) {
var byteString,
arrayBuffer,
intArray,
i,
bb,
mimeString;
if (dataURI.split(',')[0].indexOf('base64') >= 0) {
// Convert base64 to raw binary data held in a string:
byteString = atob(dataURI.split(',')[1]);
} else {
// Convert base64/URLEncoded data component to raw binary data:
byteString = decodeURIComponent(dataURI.split(',')[1]);
var CanvasPrototype = window.HTMLCanvasElement &&
window.HTMLCanvasElement.prototype,
BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder ||
window.MozBlobBuilder || window.MSBlobBuilder,
dataURLtoBlob = BlobBuilder && window.atob && window.ArrayBuffer &&
window.Uint8Array && function (dataURI) {
var byteString,
arrayBuffer,
intArray,
i,
bb,
mimeString;
if (dataURI.split(',')[0].indexOf('base64') >= 0) {
// Convert base64 to raw binary data held in a string:
byteString = atob(dataURI.split(',')[1]);
} else {
// Convert base64/URLEncoded data component to raw binary data:
byteString = decodeURIComponent(dataURI.split(',')[1]);
}
// Write the bytes of the string to an ArrayBuffer:
arrayBuffer = new ArrayBuffer(byteString.length);
intArray = new Uint8Array(arrayBuffer);
for (i = 0; i < byteString.length; i += 1) {
intArray[i] = byteString.charCodeAt(i);
}
// Write the ArrayBuffer to a blob:
bb = new BlobBuilder();
bb.append(arrayBuffer);
// Separate out the mime component:
mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
return bb.getBlob(mimeString);
};
if (window.HTMLCanvasElement && !CanvasPrototype.toBlob) {
if (CanvasPrototype.mozGetAsFile) {
CanvasPrototype.toBlob = function (callback, type) {
callback(this.mozGetAsFile('blob', type));
};
} else if (CanvasPrototype.toDataURL && dataURLtoBlob) {
CanvasPrototype.toBlob = function (callback, type) {
callback(dataURLtoBlob(this.toDataURL(type)));
};
}
// Write the bytes of the string to an ArrayBuffer:
arrayBuffer = new ArrayBuffer(byteString.length);
intArray = new Uint8Array(arrayBuffer);
for (i = 0; i < byteString.length; i += 1) {
intArray[i] = byteString.charCodeAt(i);
}
// Write the ArrayBuffer to a blob:
bb = new BlobBuilder();
bb.append(arrayBuffer);
// Separate out the mime component:
mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
return bb.getBlob(mimeString);
};

}
if (typeof define !== 'undefined' && define.amd) {
define(function () {
return canvasToBlob;
return dataURLtoBlob;
});
} else {
$.canvasToBlob = canvasToBlob;
window.dataURLtoBlob = dataURLtoBlob;
}
}(this));
@@ -1,8 +1,8 @@
/*
* jQuery UI Widget 1.8.18+amd
* jQuery UI Widget 1.8.22+amd
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
Expand Down

0 comments on commit 7fdc655

Please sign in to comment.