From bc01cbedf314f4c1618ad293de32ad49bc8033cc Mon Sep 17 00:00:00 2001
From: Brian Moseley
Date: Thu, 6 Jun 2013 09:22:27 -0700
Subject: [PATCH] update assets to 8.2.1 release
however, I didn't incorporate any changes from jquery.fileupload-ui.css
as I wasn't sure if the differences between that file and the scss file
in this repo were meaningful or not.
---
.../javascripts/jquery-fileupload/app.js | 89 +++++
.../jquery.fileupload-angular.js | 348 ++++++++++++++++++
.../jquery.fileupload-process.js | 158 ++++++++
.../jquery.fileupload-resize.js | 212 +++++++++++
.../jquery-fileupload/jquery.fileupload-ui.js | 280 +++-----------
.../jquery.fileupload-validate.js | 116 ++++++
.../jquery-fileupload/jquery.fileupload.js | 166 ++++++---
.../jquery.iframe-transport.js | 12 +-
.../javascripts/jquery-fileupload/main.js | 73 ++++
.../jquery.fileupload-ui-noscript.css | 27 ++
vendor/assets/stylesheets/style.css | 19 +
11 files changed, 1221 insertions(+), 279 deletions(-)
create mode 100644 vendor/assets/javascripts/jquery-fileupload/app.js
create mode 100644 vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-angular.js
create mode 100644 vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-process.js
create mode 100644 vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-resize.js
create mode 100644 vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-validate.js
create mode 100644 vendor/assets/javascripts/jquery-fileupload/main.js
create mode 100644 vendor/assets/stylesheets/jquery.fileupload-ui-noscript.css
create mode 100644 vendor/assets/stylesheets/style.css
diff --git a/vendor/assets/javascripts/jquery-fileupload/app.js b/vendor/assets/javascripts/jquery-fileupload/app.js
new file mode 100644
index 0000000..5e66c2f
--- /dev/null
+++ b/vendor/assets/javascripts/jquery-fileupload/app.js
@@ -0,0 +1,89 @@
+/*
+ * jQuery File Upload Plugin Angular JS Example 1.0
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2013, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+/*global window, angular */
+
+(function () {
+ 'use strict';
+
+ var isOnGitHub = window.location.hostname === 'blueimp.github.com' ||
+ window.location.hostname === 'blueimp.github.io',
+ url = isOnGitHub ? '//jquery-file-upload.appspot.com/' : 'server/php/';
+
+ angular.module('demo', [
+ 'blueimp.fileupload'
+ ])
+ .config([
+ '$httpProvider', 'fileUploadProvider',
+ function ($httpProvider, fileUploadProvider) {
+ if (isOnGitHub) {
+ // Demo settings:
+ delete $httpProvider.defaults.headers.common['X-Requested-With'];
+ angular.extend(fileUploadProvider.defaults, {
+ disableImageResize: false,
+ maxFileSize: 5000000,
+ acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
+ });
+ }
+ }
+ ])
+
+ .controller('DemoFileUploadController', [
+ '$scope', '$http',
+ function ($scope, $http) {
+ if (!isOnGitHub) {
+ $scope.loadingFiles = true;
+ $scope.options = {
+ url: url
+ };
+ $http.get(url)
+ .then(
+ function (response) {
+ $scope.loadingFiles = false;
+ $scope.queue = response.data.files;
+ },
+ function () {
+ $scope.loadingFiles = false;
+ }
+ );
+ }
+ }
+ ])
+
+ .controller('FileDestroyController', [
+ '$scope', '$http',
+ function ($scope, $http) {
+ var file = $scope.file,
+ state;
+ if (file.url) {
+ file.$state = function () {
+ return state;
+ };
+ file.$destroy = function () {
+ state = 'pending';
+ return $http({
+ url: file.delete_url,
+ method: file.delete_type
+ }).then(
+ function () {
+ state = 'resolved';
+ $scope.clear(file);
+ },
+ function () {
+ state = 'rejected';
+ }
+ );
+ };
+ }
+ }
+ ]);
+
+}());
diff --git a/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-angular.js b/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-angular.js
new file mode 100644
index 0000000..e7ba784
--- /dev/null
+++ b/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-angular.js
@@ -0,0 +1,348 @@
+/*
+ * jQuery File Upload AngularJS Plugin 1.0.1
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2013, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+/*jslint nomen: true, unparam: true */
+/*global angular */
+
+(function () {
+ 'use strict';
+
+ angular.module('blueimp.fileupload', [])
+
+ .provider('fileUpload', function () {
+ var scopeApply = function () {
+ var scope = angular.element(this)
+ .fileupload('option', 'scope')();
+ if (!scope.$$phase) {
+ scope.$apply();
+ }
+ },
+ $config;
+ $config = this.defaults = {
+ handleResponse: function (e, data) {
+ var files = data.result && data.result.files;
+ if (files) {
+ data.scope().replace(data.files, files);
+ } else if (data.errorThrown ||
+ data.textStatus === 'error') {
+ data.files[0].error = data.errorThrown ||
+ data.textStatus;
+ }
+ },
+ add: function (e, data) {
+ var scope = data.scope();
+ data.process(function () {
+ return scope.process(data);
+ }).always(
+ function () {
+ var file = data.files[0],
+ submit = function () {
+ return data.submit();
+ };
+ file.$cancel = function () {
+ scope.clear(data.files);
+ return data.abort();
+ };
+ file.$state = function () {
+ return data.state();
+ };
+ file.$progress = function () {
+ return data.progress();
+ };
+ file.$response = function () {
+ return data.response();
+ };
+ if (file.$state() === 'rejected') {
+ file._$submit = submit;
+ } else {
+ file.$submit = submit;
+ }
+ scope.$apply(function () {
+ var method = scope.option('prependFiles') ?
+ 'unshift' : 'push';
+ Array.prototype[method].apply(
+ scope.queue,
+ data.files
+ );
+ if (file.$submit &&
+ (scope.option('autoUpload') ||
+ data.autoUpload) &&
+ data.autoUpload !== false) {
+ file.$submit();
+ }
+ });
+ }
+ );
+ },
+ progress: function (e, data) {
+ data.scope().$apply();
+ },
+ done: function (e, data) {
+ var that = this;
+ data.scope().$apply(function () {
+ data.handleResponse.call(that, e, data);
+ });
+ },
+ fail: function (e, data) {
+ var that = this;
+ if (data.errorThrown === 'abort') {
+ return;
+ }
+ if (data.dataType.indexOf('json') === data.dataType.length - 4) {
+ try {
+ data.result = angular.fromJson(data.jqXHR.responseText);
+ } catch (err) {}
+ }
+ data.scope().$apply(function () {
+ data.handleResponse.call(that, e, data);
+ });
+ },
+ stop: scopeApply,
+ processstart: scopeApply,
+ processstop: scopeApply,
+ getNumberOfFiles: function () {
+ return this.scope().queue.length;
+ },
+ dataType: 'json',
+ prependFiles: true,
+ autoUpload: false
+ };
+ this.$get = [
+ function () {
+ return {
+ defaults: $config
+ };
+ }
+ ];
+ })
+
+ .provider('formatFileSizeFilter', function () {
+ var $config = this.defaults = {
+ // Byte units following the IEC format
+ // http://en.wikipedia.org/wiki/Kilobyte
+ units: [
+ {size: 1000000000, suffix: ' GB'},
+ {size: 1000000, suffix: ' MB'},
+ {size: 1000, suffix: ' KB'}
+ ]
+ };
+ this.$get = function () {
+ return function (bytes) {
+ if (!angular.isNumber(bytes)) {
+ return '';
+ }
+ var unit = true,
+ i = -1;
+ while (unit) {
+ unit = $config.units[i += 1];
+ if (i === $config.units.length - 1 || bytes >= unit.size) {
+ return (bytes / unit.size).toFixed(2) + unit.suffix;
+ }
+ }
+ };
+ };
+ })
+
+ .controller('FileUploadController', [
+ '$scope', '$element', '$attrs', 'fileUpload',
+ function ($scope, $element, $attrs, fileUpload) {
+ $scope.disabled = angular.element('')
+ .prop('disabled');
+ $scope.queue = $scope.queue || [];
+ $scope.clear = function (files) {
+ var queue = this.queue,
+ i = queue.length,
+ file = files,
+ length = 1;
+ if (angular.isArray(files)) {
+ file = files[0];
+ length = files.length;
+ }
+ while (i) {
+ if (queue[i -= 1] === file) {
+ return queue.splice(i, length);
+ }
+ }
+ };
+ $scope.replace = function (oldFiles, newFiles) {
+ var queue = this.queue,
+ file = oldFiles[0],
+ i,
+ j;
+ for (i = 0; i < queue.length; i += 1) {
+ if (queue[i] === file) {
+ for (j = 0; j < newFiles.length; j += 1) {
+ queue[i + j] = newFiles[j];
+ }
+ return;
+ }
+ }
+ };
+ $scope.progress = function () {
+ return $element.fileupload('progress');
+ };
+ $scope.active = function () {
+ return $element.fileupload('active');
+ };
+ $scope.option = function (option, data) {
+ return $element.fileupload('option', option, data);
+ };
+ $scope.add = function (data) {
+ return $element.fileupload('add', data);
+ };
+ $scope.send = function (data) {
+ return $element.fileupload('send', data);
+ };
+ $scope.process = function (data) {
+ return $element.fileupload('process', data);
+ };
+ $scope.processing = function (data) {
+ return $element.fileupload('processing', data);
+ };
+ $scope.applyOnQueue = function (method) {
+ var list = this.queue.slice(0),
+ i,
+ file;
+ for (i = 0; i < list.length; i += 1) {
+ file = list[i];
+ if (file[method]) {
+ file[method]();
+ }
+ }
+ };
+ $scope.submit = function () {
+ this.applyOnQueue('$submit');
+ };
+ $scope.cancel = function () {
+ this.applyOnQueue('$cancel');
+ };
+ // The fileupload widget will initialize with
+ // the options provided via "data-"-parameters,
+ // as well as those given via options object:
+ $element.fileupload(angular.extend(
+ {scope: function () {
+ return $scope;
+ }},
+ fileUpload.defaults
+ )).on('fileuploadadd', function (e, data) {
+ data.scope = $scope.option('scope');
+ }).on([
+ 'fileuploadadd',
+ 'fileuploadsubmit',
+ 'fileuploadsend',
+ 'fileuploaddone',
+ 'fileuploadfail',
+ 'fileuploadalways',
+ 'fileuploadprogress',
+ 'fileuploadprogressall',
+ 'fileuploadstart',
+ 'fileuploadstop',
+ 'fileuploadchange',
+ 'fileuploadpaste',
+ 'fileuploaddrop',
+ 'fileuploaddragover',
+ 'fileuploadchunksend',
+ 'fileuploadchunkdone',
+ 'fileuploadchunkfail',
+ 'fileuploadchunkalways',
+ 'fileuploadprocessstart',
+ 'fileuploadprocess',
+ 'fileuploadprocessdone',
+ 'fileuploadprocessfail',
+ 'fileuploadprocessalways',
+ 'fileuploadprocessstop'
+ ].join(' '), function (e, data) {
+ $scope.$emit(e.type, data);
+ });
+ // Observe option changes:
+ $scope.$watch(
+ $attrs.fileupload,
+ function (newOptions, oldOptions) {
+ if (newOptions) {
+ $element.fileupload('option', newOptions);
+ }
+ }
+ );
+ }
+ ])
+
+ .controller('FileUploadProgressController', [
+ '$scope', '$attrs', '$parse',
+ function ($scope, $attrs, $parse) {
+ var fn = $parse($attrs.progress),
+ update = function () {
+ var progress = fn($scope);
+ if (!progress || !progress.total) {
+ return;
+ }
+ $scope.num = Math.floor(
+ progress.loaded / progress.total * 100
+ );
+ };
+ update();
+ $scope.$watch(
+ $attrs.progress + '.loaded',
+ function (newValue, oldValue) {
+ if (newValue !== oldValue) {
+ update();
+ }
+ }
+ );
+ }
+ ])
+
+ .controller('FileUploadPreviewController', [
+ '$scope', '$element', '$attrs', '$parse',
+ function ($scope, $element, $attrs, $parse) {
+ var fn = $parse($attrs.preview),
+ file = fn($scope);
+ if (file.preview) {
+ $element.append(file.preview);
+ }
+ }
+ ])
+
+ .directive('fileupload', function () {
+ return {
+ controller: 'FileUploadController'
+ };
+ })
+
+ .directive('progress', function () {
+ return {
+ controller: 'FileUploadProgressController'
+ };
+ })
+
+ .directive('preview', function () {
+ return {
+ controller: 'FileUploadPreviewController'
+ };
+ })
+
+ .directive('download', function () {
+ return function (scope, elm, attrs) {
+ elm.on('dragstart', function (e) {
+ try {
+ e.originalEvent.dataTransfer.setData(
+ 'DownloadURL',
+ [
+ 'application/octet-stream',
+ elm.prop('download'),
+ elm.prop('href')
+ ].join(':')
+ );
+ } catch (err) {}
+ });
+ };
+ });
+
+}());
diff --git a/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-process.js b/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-process.js
new file mode 100644
index 0000000..2f9eeed
--- /dev/null
+++ b/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-process.js
@@ -0,0 +1,158 @@
+/*
+ * jQuery File Upload Processing Plugin 1.1
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2012, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+/*jslint nomen: true, unparam: true */
+/*global define, window */
+
+(function (factory) {
+ 'use strict';
+ if (typeof define === 'function' && define.amd) {
+ // Register as an anonymous AMD module:
+ define([
+ 'jquery',
+ './jquery.fileupload'
+ ], factory);
+ } else {
+ // Browser globals:
+ factory(
+ window.jQuery
+ );
+ }
+}(function ($) {
+ 'use strict';
+
+ var originalAdd = $.blueimp.fileupload.prototype.options.add;
+
+ // The File Upload Processing plugin extends the fileupload widget
+ // with file processing functionality:
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
+
+ options: {
+ // The list of processing actions:
+ processQueue: [
+ /*
+ {
+ action: 'log',
+ type: 'debug'
+ }
+ */
+ ],
+ add: function (e, data) {
+ var $this = $(this);
+ data.process(function () {
+ return $this.fileupload('process', data);
+ });
+ originalAdd.call(this, e, data);
+ }
+ },
+
+ processActions: {
+ /*
+ log: function (data, options) {
+ console[options.type](
+ 'Processing "' + data.files[data.index].name + '"'
+ );
+ }
+ */
+ },
+
+ _processFile: function (data) {
+ var that = this,
+ dfd = $.Deferred().resolveWith(that, [data]),
+ chain = dfd.promise();
+ this._trigger('process', null, data);
+ $.each(data.processQueue, function (i, settings) {
+ var func = function (data) {
+ return that.processActions[settings.action].call(
+ that,
+ data,
+ settings
+ );
+ };
+ chain = chain.pipe(func, settings.always && func);
+ });
+ chain
+ .done(function () {
+ that._trigger('processdone', null, data);
+ that._trigger('processalways', null, data);
+ })
+ .fail(function () {
+ that._trigger('processfail', null, data);
+ that._trigger('processalways', null, data);
+ });
+ return chain;
+ },
+
+ // Replaces the settings of each processQueue item that
+ // are strings starting with an "@", using the remaining
+ // substring as key for the option map,
+ // e.g. "@autoUpload" is replaced with options.autoUpload:
+ _transformProcessQueue: function (options) {
+ var processQueue = [];
+ $.each(options.processQueue, function () {
+ var settings = {};
+ $.each(this, function (key, value) {
+ if ($.type(value) === 'string' &&
+ value.charAt(0) === '@') {
+ settings[key] = options[value.slice(1)];
+ } else {
+ settings[key] = value;
+ }
+ });
+ processQueue.push(settings);
+ });
+ options.processQueue = processQueue;
+ },
+
+ // Returns the number of files currently in the processsing queue:
+ processing: function () {
+ return this._processing;
+ },
+
+ // Processes the files given as files property of the data parameter,
+ // returns a Promise object that allows to bind callbacks:
+ process: function (data) {
+ var that = this,
+ options = $.extend({}, this.options, data);
+ if (options.processQueue && options.processQueue.length) {
+ this._transformProcessQueue(options);
+ if (this._processing === 0) {
+ this._trigger('processstart');
+ }
+ $.each(data.files, function (index, file) {
+ var opts = index ? $.extend({}, options) : options,
+ func = function () {
+ return that._processFile(opts);
+ };
+ opts.index = index;
+ that._processing += 1;
+ that._processingQueue = that._processingQueue.pipe(func, func)
+ .always(function () {
+ that._processing -= 1;
+ if (that._processing === 0) {
+ that._trigger('processstop');
+ }
+ });
+ });
+ }
+ return this._processingQueue;
+ },
+
+ _create: function () {
+ this._super();
+ this._processing = 0;
+ this._processingQueue = $.Deferred().resolveWith(this)
+ .promise();
+ }
+
+ });
+
+}));
diff --git a/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-resize.js b/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-resize.js
new file mode 100644
index 0000000..ae5c5be
--- /dev/null
+++ b/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-resize.js
@@ -0,0 +1,212 @@
+/*
+ * jQuery File Upload Image Resize Plugin 1.1.2
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2013, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+/*jslint nomen: true, unparam: true, regexp: true */
+/*global define, window */
+
+(function (factory) {
+ 'use strict';
+ if (typeof define === 'function' && define.amd) {
+ // Register as an anonymous AMD module:
+ define([
+ 'jquery',
+ 'load-image',
+ 'canvas-to-blob',
+ './jquery.fileupload-process'
+ ], factory);
+ } else {
+ // Browser globals:
+ factory(
+ window.jQuery,
+ window.loadImage
+ );
+ }
+}(function ($, loadImage) {
+ 'use strict';
+
+ // Prepend to the default processQueue:
+ $.blueimp.fileupload.prototype.options.processQueue.unshift(
+ {
+ action: 'loadImage',
+ fileTypes: '@loadImageFileTypes',
+ maxFileSize: '@loadImageMaxFileSize',
+ noRevoke: '@loadImageNoRevoke',
+ disabled: '@disableImageLoad'
+ },
+ {
+ action: 'resizeImage',
+ maxWidth: '@imageMaxWidth',
+ maxHeight: '@imageMaxHeight',
+ minWidth: '@imageMinWidth',
+ minHeight: '@imageMinHeight',
+ crop: '@imageCrop',
+ disabled: '@disableImageResize'
+ },
+ {
+ action: 'saveImage',
+ disabled: '@disableImageResize'
+ },
+ {
+ action: 'resizeImage',
+ maxWidth: '@previewMaxWidth',
+ maxHeight: '@previewMaxHeight',
+ minWidth: '@previewMinWidth',
+ minHeight: '@previewMinHeight',
+ crop: '@previewCrop',
+ canvas: '@previewAsCanvas',
+ disabled: '@disableImagePreview'
+ },
+ {
+ action: 'setImage',
+ // The name of the property the resized image
+ // is saved as on the associated file object:
+ name: 'preview',
+ disabled: '@disableImagePreview'
+ }
+ );
+
+ // The File Upload Resize plugin extends the fileupload widget
+ // with image resize functionality:
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
+
+ options: {
+ // The regular expression for the types of images to load:
+ // matched against the file type:
+ loadImageFileTypes: /^image\/(gif|jpeg|png)$/,
+ // The maximum file size of images to load:
+ loadImageMaxFileSize: 5000000, // 5MB
+ // The maximum width of resized images:
+ imageMaxWidth: 1920,
+ // The maximum height of resized images:
+ imageMaxHeight: 1080,
+ // Define if resized images should be cropped or only scaled:
+ imageCrop: false,
+ // Disable the resize image functionality by default:
+ disableImageResize: true,
+ // The maximum width of the preview images:
+ previewMaxWidth: 80,
+ // The maximum height of the preview images:
+ previewMaxHeight: 80,
+ // Define if preview images should be cropped or only scaled:
+ previewCrop: false,
+ // Define if preview images should be resized as canvas elements:
+ previewAsCanvas: true
+ },
+
+ processActions: {
+
+ // Loads the image given via data.files and data.index
+ // as img element if the browser supports canvas.
+ // Accepts the options fileTypes (regular expression)
+ // and maxFileSize (integer) to limit the files to load:
+ loadImage: function (data, options) {
+ if (options.disabled) {
+ return data;
+ }
+ var that = this,
+ file = data.files[data.index],
+ dfd = $.Deferred();
+ if (($.type(options.maxFileSize) === 'number' &&
+ file.size > options.maxFileSize) ||
+ (options.fileTypes &&
+ !options.fileTypes.test(file.type)) ||
+ !loadImage(
+ file,
+ function (img) {
+ if (!img.src) {
+ return dfd.rejectWith(that, [data]);
+ }
+ data.img = img;
+ dfd.resolveWith(that, [data]);
+ },
+ options
+ )) {
+ dfd.rejectWith(that, [data]);
+ }
+ return dfd.promise();
+ },
+
+ // Resizes the image given as data.canvas or data.img
+ // and updates data.canvas or data.img with the resized image.
+ // Accepts the options maxWidth, maxHeight, minWidth,
+ // minHeight, canvas and crop:
+ resizeImage: function (data, options) {
+ options = $.extend({canvas: true}, options);
+ var img = (options.canvas && data.canvas) || data.img,
+ canvas;
+ if (img && !options.disabled) {
+ canvas = loadImage.scale(img, options);
+ if (canvas && (canvas.width !== img.width ||
+ canvas.height !== img.height)) {
+ data[canvas.getContext ? 'canvas' : 'img'] = canvas;
+ }
+ }
+ return data;
+ },
+
+ // Saves the processed image given as data.canvas
+ // inplace at data.index of data.files:
+ saveImage: function (data, options) {
+ if (!data.canvas || options.disabled) {
+ return data;
+ }
+ var that = this,
+ file = data.files[data.index],
+ name = file.name,
+ dfd = $.Deferred(),
+ callback = function (blob) {
+ if (!blob.name) {
+ if (file.type === blob.type) {
+ blob.name = file.name;
+ } else if (file.name) {
+ blob.name = file.name.replace(
+ /\..+$/,
+ '.' + blob.type.substr(6)
+ );
+ }
+ }
+ // Store the created blob at the position
+ // of the original file in the files list:
+ data.files[data.index] = blob;
+ dfd.resolveWith(that, [data]);
+ };
+ // Use canvas.mozGetAsFile directly, to retain the filename, as
+ // Gecko doesn't support the filename option for FormData.append:
+ if (data.canvas.mozGetAsFile) {
+ callback(data.canvas.mozGetAsFile(
+ (/^image\/(jpeg|png)$/.test(file.type) && name) ||
+ ((name && name.replace(/\..+$/, '')) ||
+ 'blob') + '.png',
+ file.type
+ ));
+ } else if (data.canvas.toBlob) {
+ data.canvas.toBlob(callback, file.type);
+ } else {
+ return data;
+ }
+ return dfd.promise();
+ },
+
+ // Sets the resized version of the image as a property of the
+ // file object, must be called after "saveImage":
+ setImage: function (data, options) {
+ var img = data.canvas || data.img;
+ if (img && !options.disabled) {
+ data.files[data.index][options.name] = img;
+ }
+ return data;
+ }
+
+ }
+
+ });
+
+}));
diff --git a/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js b/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js
index 0386fb2..5d22346 100644
--- a/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js
+++ b/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js
@@ -1,5 +1,5 @@
/*
- * jQuery File Upload User Interface Plugin 7.4.1
+ * jQuery File Upload User Interface Plugin 8.2.1
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
@@ -19,20 +19,25 @@
define([
'jquery',
'tmpl',
- 'load-image',
- './jquery.fileupload-fp'
+ './jquery.fileupload-resize',
+ './jquery.fileupload-validate'
], factory);
} else {
// Browser globals:
factory(
window.jQuery,
- window.tmpl,
- window.loadImage
+ window.tmpl
);
}
}(function ($, tmpl, loadImage) {
'use strict';
+ $.blueimp.fileupload.prototype._specialOptions.push(
+ 'filesContainer',
+ 'uploadTemplateId',
+ 'downloadTemplateId'
+ );
+
// The UI version extends the file upload widget
// and adds complete user interface interaction:
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
@@ -42,29 +47,6 @@
// as the user clicks on the start buttons. To enable automatic
// uploads, set the following option to true:
autoUpload: false,
- // The following option limits the number of files that are
- // allowed to be uploaded using this widget:
- maxNumberOfFiles: undefined,
- // The maximum allowed file size:
- maxFileSize: undefined,
- // The minimum allowed file size:
- minFileSize: undefined,
- // The regular expression for allowed file types, matches
- // against either file type or file name:
- acceptFileTypes: /.+$/i,
- // The regular expression to define for which files a preview
- // image is shown, matched against the file type:
- previewSourceFileTypes: /^image\/(gif|jpeg|png)$/,
- // The maximum file size of images that are to be displayed as preview:
- previewSourceMaxFileSize: 5000000, // 5MB
- // The maximum width of the preview images:
- previewMaxWidth: 80,
- // The maximum height of the preview images:
- previewMaxHeight: 80,
- // By default, preview images are displayed as canvas elements
- // if supported by the browser. Set the following option to false
- // to always display preview images as img elements:
- previewAsCanvas: true,
// The ID of the upload template:
uploadTemplateId: 'template-upload',
// The ID of the download template:
@@ -79,29 +61,43 @@
// option of the $.ajax upload requests:
dataType: 'json',
+ // Function returning the current number of files,
+ // used by the maxNumberOfFiles validation:
+ getNumberOfFiles: function () {
+ return this.filesContainer.children().length;
+ },
+
+ // Callback to retrieve the list of files from the server response:
+ getFilesFromResponse: function (data) {
+ if (data.result && $.isArray(data.result.files)) {
+ return data.result.files;
+ }
+ return [];
+ },
+
// The add callback is invoked as soon as files are added to the fileupload
// 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('blueimp-fileupload') ||
- $(this).data('fileupload'),
+ var $this = $(this),
+ that = $this.data('blueimp-fileupload') ||
+ $this.data('fileupload'),
options = that.options,
files = data.files;
- $(this).fileupload('process', data).done(function () {
- that._adjustMaxNumberOfFiles(-files.length);
- data.maxNumberOfFilesAdjusted = true;
- data.files.valid = data.isValidated = that._validate(files);
+ data.process(function () {
+ return $this.fileupload('process', data);
+ }).always(function () {
data.context = that._renderUpload(files).data('data', data);
+ that._renderPreviews(data);
options.filesContainer[
options.prependFiles ? 'prepend' : 'append'
](data.context);
- that._renderPreviews(data);
that._forceReflow(data.context);
that._transition(data.context).done(
function () {
if ((that._trigger('added', e, data) !== false) &&
(options.autoUpload || data.autoUpload) &&
- data.autoUpload !== false && data.isValidated) {
+ data.autoUpload !== false && !data.files.error) {
data.submit();
}
}
@@ -112,15 +108,6 @@
send: function (e, data) {
var that = $(this).data('blueimp-fileupload') ||
$(this).data('fileupload');
- if (!data.isValidated) {
- if (!data.maxNumberOfFilesAdjusted) {
- that._adjustMaxNumberOfFiles(-data.files.length);
- data.maxNumberOfFilesAdjusted = true;
- }
- if (!that._validate(data.files)) {
- return false;
- }
- }
if (data.context && data.dataType &&
data.dataType.substr(0, 6) === 'iframe') {
// Iframe Transport does not support progress events.
@@ -142,7 +129,9 @@
done: function (e, data) {
var that = $(this).data('blueimp-fileupload') ||
$(this).data('fileupload'),
- files = that._getFilesFromResponse(data),
+ getFilesFromResponse = data.getFilesFromResponse ||
+ that.options.getFilesFromResponse,
+ files = getFilesFromResponse(data),
template,
deferred;
if (data.context) {
@@ -150,9 +139,6 @@
var file = files[index] ||
{error: 'Empty file upload result'},
deferred = that._addFinishedDeferreds();
- if (file.error) {
- that._adjustMaxNumberOfFiles(1);
- }
that._transition($(this)).done(
function () {
var node = $(this);
@@ -171,17 +157,6 @@
);
});
} else {
- if (files.length) {
- $.each(files, function (index, file) {
- if (data.maxNumberOfFilesAdjusted && file.error) {
- that._adjustMaxNumberOfFiles(1);
- } else if (!data.maxNumberOfFilesAdjusted &&
- !file.error) {
- that._adjustMaxNumberOfFiles(-1);
- }
- });
- data.maxNumberOfFilesAdjusted = true;
- }
template = that._renderDownload(files)
.appendTo(that.options.filesContainer);
that._forceReflow(template);
@@ -202,9 +177,6 @@
$(this).data('fileupload'),
template,
deferred;
- if (data.maxNumberOfFilesAdjusted) {
- that._adjustMaxNumberOfFiles(data.files.length);
- }
if (data.context) {
data.context.each(function (index) {
if (data.errorThrown !== 'abort') {
@@ -323,20 +295,26 @@
}
);
},
+ processstart: function () {
+ $(this).addClass('fileupload-processing');
+ },
+ processstop: function () {
+ $(this).removeClass('fileupload-processing');
+ },
// Callback for file deletion:
destroy: function (e, data) {
var that = $(this).data('blueimp-fileupload') ||
$(this).data('fileupload');
if (data.url) {
- $.ajax(data);
- that._adjustMaxNumberOfFiles(1);
+ $.ajax(data).done(function () {
+ that._transition(data.context).done(
+ function () {
+ $(this).remove();
+ that._trigger('destroyed', e, data);
+ }
+ );
+ });
}
- that._transition(data.context).done(
- function () {
- $(this).remove();
- that._trigger('destroyed', e, data);
- }
- );
}
},
@@ -356,13 +334,6 @@
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 () {
@@ -376,21 +347,10 @@
'DownloadURL',
[type, name, url].join(':')
);
- } catch (err) {}
+ } catch (ignore) {}
});
},
- _adjustMaxNumberOfFiles: function (operand) {
- if (typeof this.options.maxNumberOfFiles === 'number') {
- this.options.maxNumberOfFiles += operand;
- if (this.options.maxNumberOfFiles < 1) {
- this._disableFileInputButton();
- } else {
- this._enableFileInputButton();
- }
- }
- },
-
_formatFileSize: function (bytes) {
if (typeof bytes !== 'number') {
return '';
@@ -446,46 +406,6 @@
this._formatFileSize(data.total);
},
- _hasError: function (file) {
- if (file.error) {
- return file.error;
- }
- // The number of added files is subtracted from
- // maxNumberOfFiles before validation, so we check if
- // maxNumberOfFiles is below 0 (instead of below 1):
- if (this.options.maxNumberOfFiles < 0) {
- return 'Maximum number of files exceeded';
- }
- // Files are accepted if either the file type or the file name
- // matches against the acceptFileTypes regular expression, as
- // only browsers with support for the File API report the type:
- if (!(this.options.acceptFileTypes.test(file.type) ||
- this.options.acceptFileTypes.test(file.name))) {
- return 'Filetype not allowed';
- }
- if (this.options.maxFileSize &&
- file.size > this.options.maxFileSize) {
- return 'File is too big';
- }
- if (typeof file.size === 'number' &&
- file.size < this.options.minFileSize) {
- return 'File is too small';
- }
- return null;
- },
-
- _validate: function (files) {
- var that = this,
- valid = !!files.length;
- $.each(files, function (index, file) {
- file.error = that._hasError(file);
- if (file.error) {
- valid = false;
- }
- });
- return valid;
- },
-
_renderTemplate: function (func, files) {
if (!func) {
return $();
@@ -501,63 +421,10 @@
return $(this.options.templatesContainer).html(result).children();
},
- _renderPreview: function (file, node) {
- var that = this,
- options = this.options,
- dfd = $.Deferred();
- return ((loadImage && loadImage(
- file,
- function (img) {
- node.append(img);
- that._forceReflow(node);
- that._transition(node).done(function () {
- dfd.resolveWith(node);
- });
- if (!$.contains(that.document[0].body, node[0])) {
- // If the element is not part of the DOM,
- // transition events are not triggered,
- // so we have to resolve manually:
- dfd.resolveWith(node);
- }
- node.on('remove', function () {
- // If the element is removed before the
- // transition finishes, transition events are
- // not triggered, resolve manually:
- dfd.resolveWith(node);
- });
- },
- {
- maxWidth: options.previewMaxWidth,
- maxHeight: options.previewMaxHeight,
- canvas: options.previewAsCanvas
- }
- )) || dfd.resolveWith(node)) && dfd;
- },
-
_renderPreviews: function (data) {
- var that = this,
- options = this.options;
- 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(),
- ev = $.Event('previewdone', {
- target: element
- });
- that._renderPreview(file, $(element)).done(
- function () {
- that._trigger(ev.type, ev, data);
- dfd.resolveWith(that);
- }
- );
- return dfd.promise();
- });
- }
+ data.context.find('.preview').each(function (index, elm) {
+ $(elm).append(data.files[index].preview);
});
- return this._processingQueue;
},
_renderUpload: function (files) {
@@ -601,8 +468,7 @@
var button = $(e.currentTarget);
this._trigger('destroy', e, $.extend({
context: button.closest('.template-download'),
- type: 'DELETE',
- dataType: this.options.dataType
+ type: 'DELETE'
}, button.data()));
},
@@ -731,54 +597,14 @@
}
},
- _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 () {
this._super();
this._initFilesContainer();
this._initTemplates();
- this._initRegExpOptions();
- },
-
- _setOption: function (key, value) {
- this._super(key, value);
- if (key === 'maxNumberOfFiles') {
- this._adjustMaxNumberOfFiles(0);
- }
},
_create: function () {
this._super();
- this._refreshOptionsList.push(
- 'filesContainer',
- 'uploadTemplateId',
- 'downloadTemplateId'
- );
- if (!this._processingQueue) {
- this._processingQueue = $.Deferred().resolveWith(this).promise();
- this.process = function () {
- return this._processingQueue;
- };
- }
this._resetFinishedDeferreds();
},
diff --git a/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-validate.js b/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-validate.js
new file mode 100644
index 0000000..2599da8
--- /dev/null
+++ b/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-validate.js
@@ -0,0 +1,116 @@
+/*
+ * jQuery File Upload Validation Plugin 1.0.2
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2013, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+/*jslint nomen: true, unparam: true, regexp: true */
+/*global define, window */
+
+(function (factory) {
+ 'use strict';
+ if (typeof define === 'function' && define.amd) {
+ // Register as an anonymous AMD module:
+ define([
+ 'jquery',
+ './jquery.fileupload-process'
+ ], factory);
+ } else {
+ // Browser globals:
+ factory(
+ window.jQuery
+ );
+ }
+}(function ($) {
+ 'use strict';
+
+ // Append to the default processQueue:
+ $.blueimp.fileupload.prototype.options.processQueue.push(
+ {
+ action: 'validate',
+ // Always trigger this action,
+ // even if the previous action was rejected:
+ always: true,
+ // Options taken from the global options map:
+ acceptFileTypes: '@acceptFileTypes',
+ maxFileSize: '@maxFileSize',
+ minFileSize: '@minFileSize',
+ maxNumberOfFiles: '@maxNumberOfFiles',
+ disabled: '@disableValidation'
+ }
+ );
+
+ // The File Upload Validation plugin extends the fileupload widget
+ // with file validation functionality:
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
+
+ options: {
+ /*
+ // The regular expression for allowed file types, matches
+ // against either file type or file name:
+ acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
+ // The maximum allowed file size in bytes:
+ maxFileSize: 10000000, // 10 MB
+ // The minimum allowed file size in bytes:
+ minFileSize: undefined, // No minimal file size
+ // The limit of files to be uploaded:
+ maxNumberOfFiles: 10,
+ */
+
+ // Function returning the current number of files,
+ // has to be overriden for maxNumberOfFiles validation:
+ getNumberOfFiles: $.noop,
+
+ // Error and info messages:
+ messages: {
+ maxNumberOfFiles: 'Maximum number of files exceeded',
+ acceptFileTypes: 'File type not allowed',
+ maxFileSize: 'File is too large',
+ minFileSize: 'File is too small'
+ }
+ },
+
+ processActions: {
+
+ validate: function (data, options) {
+ if (options.disabled) {
+ return data;
+ }
+ var dfd = $.Deferred(),
+ settings = this.options,
+ file = data.files[data.index],
+ numberOfFiles = settings.getNumberOfFiles();
+ if (numberOfFiles && $.type(options.maxNumberOfFiles) === 'number' &&
+ numberOfFiles + data.files.length > options.maxNumberOfFiles) {
+ file.error = settings.i18n('maxNumberOfFiles');
+ } else if (options.acceptFileTypes &&
+ !(options.acceptFileTypes.test(file.type) ||
+ options.acceptFileTypes.test(file.name))) {
+ file.error = settings.i18n('acceptFileTypes');
+ } else if (options.maxFileSize && file.size > options.maxFileSize) {
+ file.error = settings.i18n('maxFileSize');
+ } else if ($.type(file.size) === 'number' &&
+ file.size < options.minFileSize) {
+ file.error = settings.i18n('minFileSize');
+ } else {
+ delete file.error;
+ }
+ if (file.error || data.files.error) {
+ data.files.error = true;
+ dfd.rejectWith(this, [data]);
+ } else {
+ dfd.resolveWith(this, [data]);
+ }
+ return dfd.promise();
+ }
+
+ }
+
+ });
+
+}));
diff --git a/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload.js b/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload.js
index dbee297..03678f3 100644
--- a/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload.js
+++ b/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload.js
@@ -1,5 +1,5 @@
/*
- * jQuery File Upload Plugin 5.28.4
+ * jQuery File Upload Plugin 5.31.1
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
@@ -115,6 +115,23 @@
// By default, uploads are started automatically when adding files:
autoUpload: true,
+ // Error and info messages:
+ messages: {
+ uploadedBytes: 'Uploaded bytes exceed file size'
+ },
+
+ // Translation function, gets the message key to be translated
+ // and an object with context specific data as arguments:
+ i18n: function (message, context) {
+ message = this.messages[message] || message.toString();
+ if (context) {
+ $.each(context, function (key, value) {
+ message = message.replace('{' + key + '}', value);
+ });
+ }
+ return message;
+ },
+
// Additional form data to be sent along with the file uploads can be set
// using this option, which accepts an array of objects with name and
// value properties, a function returning such an array, a FormData
@@ -139,9 +156,10 @@
// data.submit().done(func).fail(func).always(func);
add: function (e, data) {
if (data.autoUpload || (data.autoUpload !== false &&
- ($(this).data('blueimp-fileupload') ||
- $(this).data('fileupload')).options.autoUpload)) {
- data.submit();
+ $(this).fileupload('option', 'autoUpload'))) {
+ data.process().done(function () {
+ data.submit();
+ });
}
},
@@ -205,8 +223,9 @@
cache: false
},
- // A list of options that require a refresh after assigning a new value:
- _refreshOptionsList: [
+ // A list of options that require reinitializing event listeners and/or
+ // special initialization code:
+ _specialOptions: [
'fileInput',
'dropZone',
'pasteZone',
@@ -215,7 +234,7 @@
],
_BitrateTimer: function () {
- this.timestamp = (new Date()).getTime();
+ this.timestamp = ((Date.now) ? Date.now() : (new Date()).getTime());
this.loaded = 0;
this.bitrate = 0;
this.getBitrate = function (now, loaded, interval) {
@@ -289,7 +308,7 @@
_onProgress: function (e, data) {
if (e.lengthComputable) {
- var now = (new Date()).getTime(),
+ var now = ((Date.now) ? Date.now() : (new Date()).getTime()),
loaded;
if (data._time && data.progressInterval &&
(now - data._time < data.progressInterval) &&
@@ -344,8 +363,14 @@
}
},
+ _isInstanceOf: function (type, obj) {
+ // Cross-frame instanceof check
+ return Object.prototype.toString.call(obj) === '[object ' + type + ']';
+ },
+
_initXHRData: function (options) {
- var formData,
+ var that = this,
+ formData,
file = options.files[0],
// Ignore non-multipart setting if not supported:
multipart = options.multipart || !$.support.xhrFileUpload,
@@ -380,7 +405,7 @@
});
}
} else {
- if (options.formData instanceof FormData) {
+ if (that._isInstanceOf('FormData', options.formData)) {
formData = options.formData;
} else {
formData = new FormData();
@@ -394,12 +419,10 @@
formData.append(paramName, options.blob, file.name);
} else {
$.each(options.files, function (index, file) {
- // 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 ((window.Blob && file instanceof Blob) ||
- (window.File && file instanceof File)) {
+ if (that._isInstanceOf('File', file) ||
+ that._isInstanceOf('Blob', file)) {
formData.append(
options.paramName[index] || paramName,
file,
@@ -444,7 +467,7 @@
options.dataType = 'postmessage ' + (options.dataType || '');
}
} else {
- this._initIframeSettings(options, 'iframe');
+ this._initIframeSettings(options);
}
},
@@ -544,9 +567,20 @@
return this._enhancePromise(promise);
},
- // Adds convenience methods to the callback arguments:
+ // Adds convenience methods to the data callback argument:
_addConvenienceMethods: function (e, data) {
- var that = this;
+ var that = this,
+ getPromise = function (data) {
+ return $.Deferred().resolveWith(that, [data]).promise();
+ };
+ data.process = function (resolveFunc, rejectFunc) {
+ if (resolveFunc || rejectFunc) {
+ data._processQueue = this._processQueue =
+ (this._processQueue || getPromise(this))
+ .pipe(resolveFunc, rejectFunc);
+ }
+ return this._processQueue || getPromise(this);
+ };
data.submit = function () {
if (this.state() !== 'pending') {
data.jqXHR = this.jqXHR =
@@ -565,6 +599,9 @@
if (this.jqXHR) {
return that._getDeferredState(this.jqXHR);
}
+ if (this._processQueue) {
+ return that._getDeferredState(this._processQueue);
+ }
};
data.progress = function () {
return this._progress;
@@ -608,7 +645,7 @@
return true;
}
if (ub >= fs) {
- file.error = 'Uploaded bytes exceed file size';
+ file.error = options.i18n('uploadedBytes');
return this._getXHRPromise(
false,
options.context,
@@ -644,7 +681,7 @@
// Create a progress event if no final progress event
// with loaded equaling total has been triggered
// for this chunk:
- if (o._progress.loaded === currentLoaded) {
+ if (currentLoaded + o.chunkSize - o._progress.loaded) {
that._onProgress($.Event('progress', {
lengthComputable: true,
loaded: ub - o.uploadedBytes,
@@ -1045,44 +1082,50 @@
},
_onPaste: function (e) {
- var cbd = e.originalEvent.clipboardData,
- items = (cbd && cbd.items) || [],
+ var items = e.originalEvent && e.originalEvent.clipboardData &&
+ e.originalEvent.clipboardData.items,
data = {files: []};
- $.each(items, function (index, item) {
- var file = item.getAsFile && item.getAsFile();
- if (file) {
- data.files.push(file);
+ if (items && items.length) {
+ $.each(items, function (index, item) {
+ var file = item.getAsFile && item.getAsFile();
+ if (file) {
+ data.files.push(file);
+ }
+ });
+ if (this._trigger('paste', e, data) === false ||
+ this._onAdd(e, data) === false) {
+ return false;
}
- });
- if (this._trigger('paste', e, data) === false ||
- this._onAdd(e, data) === false) {
- return false;
}
},
_onDrop: function (e) {
var that = this,
- dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer,
+ dataTransfer = e.dataTransfer = e.originalEvent &&
+ e.originalEvent.dataTransfer,
data = {};
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);
+ }
+ });
}
- this._getDroppedFiles(dataTransfer).always(function (files) {
- data.files = files;
- if (that._trigger('drop', e, data) !== false) {
- that._onAdd(e, data);
- }
- });
},
_onDragOver: function (e) {
- var dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer;
- if (this._trigger('dragover', e) === false) {
- return false;
- }
- if (dataTransfer && $.inArray('Files', dataTransfer.types) !== -1) {
- dataTransfer.dropEffect = 'copy';
- e.preventDefault();
+ var dataTransfer = e.dataTransfer = e.originalEvent &&
+ e.originalEvent.dataTransfer;
+ if (dataTransfer) {
+ if (this._trigger('dragover', e) === false) {
+ return false;
+ }
+ if ($.inArray('Files', dataTransfer.types) !== -1) {
+ dataTransfer.dropEffect = 'copy';
+ e.preventDefault();
+ }
}
},
@@ -1108,12 +1151,12 @@
},
_setOption: function (key, value) {
- var refresh = $.inArray(key, this._refreshOptionsList) !== -1;
- if (refresh) {
+ var reinit = $.inArray(key, this._specialOptions) !== -1;
+ if (reinit) {
this._destroyEventHandlers();
}
this._super(key, value);
- if (refresh) {
+ if (reinit) {
this._initSpecialOptions();
this._initEventHandlers();
}
@@ -1135,10 +1178,35 @@
}
},
- _create: function () {
- var options = this.options;
+ _getRegExp: function (str) {
+ var parts = str.split('/'),
+ modifiers = parts.pop();
+ parts.shift();
+ return new RegExp(parts.join('/'), modifiers);
+ },
+
+ _isRegExpOption: function (key, value) {
+ return key !== 'url' && $.type(value) === 'string' &&
+ /^\/.*\/[igm]{0,3}$/.test(value);
+ },
+
+ _initDataAttributes: function () {
+ var that = this,
+ options = this.options;
// Initialize options set via HTML5 data-attributes:
- $.extend(options, $(this.element[0].cloneNode(false)).data());
+ $.each(
+ $(this.element[0].cloneNode(false)).data(),
+ function (key, value) {
+ if (that._isRegExpOption(key, value)) {
+ value = that._getRegExp(value);
+ }
+ options[key] = value;
+ }
+ );
+ },
+
+ _create: function () {
+ this._initDataAttributes();
this._initSpecialOptions();
this._slots = [];
this._sequence = this._getXHRPromise(true);
diff --git a/vendor/assets/javascripts/jquery-fileupload/jquery.iframe-transport.js b/vendor/assets/javascripts/jquery-fileupload/jquery.iframe-transport.js
index ed25895..e04e7a0 100644
--- a/vendor/assets/javascripts/jquery-fileupload/jquery.iframe-transport.js
+++ b/vendor/assets/javascripts/jquery-fileupload/jquery.iframe-transport.js
@@ -1,5 +1,5 @@
/*
- * jQuery Iframe Transport Plugin 1.6.1
+ * jQuery Iframe Transport Plugin 1.6.2
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2011, Sebastian Tschan
@@ -61,9 +61,10 @@
// IE versions below IE8 cannot set the name property of
// elements that have already been added to the DOM,
// so we set the name along with the iframe HTML markup:
+ counter += 1;
iframe = $(
''
+ counter + '">'
).bind('load', function () {
var fileInputClones,
paramNames = $.isArray(options.paramName) ?
@@ -96,7 +97,12 @@
// (happens on form submits to iframe targets):
$('')
.appendTo(form);
- form.remove();
+ window.setTimeout(function () {
+ // Removing the form in a setTimeout call
+ // allows Chrome's developer tools to display
+ // the response result
+ form.remove();
+ }, 0);
});
form
.prop('target', iframe.prop('name'))
diff --git a/vendor/assets/javascripts/jquery-fileupload/main.js b/vendor/assets/javascripts/jquery-fileupload/main.js
new file mode 100644
index 0000000..a291435
--- /dev/null
+++ b/vendor/assets/javascripts/jquery-fileupload/main.js
@@ -0,0 +1,73 @@
+/*
+ * jQuery File Upload Plugin JS Example 8.0
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2010, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+/*jslint nomen: true, unparam: true, regexp: true */
+/*global $, window, document */
+
+$(function () {
+ 'use strict';
+
+ // Initialize the jQuery File Upload widget:
+ $('#fileupload').fileupload({
+ // Uncomment the following to send cross-domain cookies:
+ //xhrFields: {withCredentials: true},
+ url: 'server/php/'
+ });
+
+ // Enable iframe cross-domain access via redirect option:
+ $('#fileupload').fileupload(
+ 'option',
+ 'redirect',
+ window.location.href.replace(
+ /\/[^\/]*$/,
+ '/cors/result.html?%s'
+ )
+ );
+
+ if (window.location.hostname === 'blueimp.github.com' ||
+ window.location.hostname === 'blueimp.github.io') {
+ // Demo settings:
+ $('#fileupload').fileupload('option', {
+ url: '//jquery-file-upload.appspot.com/',
+ disableImageResize: false,
+ maxFileSize: 5000000,
+ acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
+ });
+ // Upload server status check for browsers with CORS support:
+ if ($.support.cors) {
+ $.ajax({
+ url: '//jquery-file-upload.appspot.com/',
+ type: 'HEAD'
+ }).fail(function () {
+ $('')
+ .text('Upload server currently unavailable - ' +
+ new Date())
+ .appendTo('#fileupload');
+ });
+ }
+ } else {
+ // Load existing files:
+ $('#fileupload').addClass('fileupload-processing');
+ $.ajax({
+ // Uncomment the following to send cross-domain cookies:
+ //xhrFields: {withCredentials: true},
+ url: $('#fileupload').fileupload('option', 'url'),
+ dataType: 'json',
+ context: $('#fileupload')[0]
+ }).always(function (result) {
+ $(this).removeClass('fileupload-processing');
+ }).done(function (result) {
+ $(this).fileupload('option', 'done')
+ .call(this, null, {result: result});
+ });
+ }
+
+});
diff --git a/vendor/assets/stylesheets/jquery.fileupload-ui-noscript.css b/vendor/assets/stylesheets/jquery.fileupload-ui-noscript.css
new file mode 100644
index 0000000..c450485
--- /dev/null
+++ b/vendor/assets/stylesheets/jquery.fileupload-ui-noscript.css
@@ -0,0 +1,27 @@
+@charset "UTF-8";
+/*
+ * jQuery File Upload UI Plugin NoScript CSS 1.0
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2012, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+.fileinput-button input {
+ position: static;
+ opacity: 1;
+ filter: none;
+ transform: none;
+ font-size: inherit;
+ direction: inherit;
+}
+
+.fileinput-button span,
+.fileinput-button i,
+.fileupload-buttonbar .delete,
+.fileupload-buttonbar .toggle {
+ display: none;
+}
diff --git a/vendor/assets/stylesheets/style.css b/vendor/assets/stylesheets/style.css
new file mode 100644
index 0000000..01c0fc2
--- /dev/null
+++ b/vendor/assets/stylesheets/style.css
@@ -0,0 +1,19 @@
+@charset "UTF-8";
+/*
+ * jQuery File Upload Plugin CSS Example 8.0
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2013, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+body {
+ padding-top: 60px;
+}
+
+.ng-cloak {
+ display: none;
+}