aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-11-05 08:46:42 +0000
committerMario <mario@mariovavti.com>2020-11-05 08:46:42 +0000
commitbafbf0416462c6f18c3fb6c8c06a063c8d6fdae6 (patch)
tree8929845be585b09d0f420621281c5531e1efad3e /vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js
parent6f93d9848c43019d43ea76c27d42d657ba031cd7 (diff)
parentfdefa101d84dc2a9424eaedbdb003a4c30ec5d01 (diff)
downloadvolse-hubzilla-bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6.tar.gz
volse-hubzilla-bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6.tar.bz2
volse-hubzilla-bafbf0416462c6f18c3fb6c8c06a063c8d6fdae6.zip
Merge branch '5.0RC'5.0
Diffstat (limited to 'vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js')
-rw-r--r--vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js214
1 files changed, 106 insertions, 108 deletions
diff --git a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js
index 562708c6b..9cc3d3fd0 100644
--- a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js
+++ b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js
@@ -11,7 +11,7 @@
/* global define, require */
-(function(factory) {
+(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
@@ -37,7 +37,7 @@
// Browser globals:
factory(window.jQuery, window.tmpl);
}
-})(function($, tmpl) {
+})(function ($, tmpl) {
'use strict';
$.blueimp.fileupload.prototype._specialOptions.push(
@@ -54,6 +54,8 @@
// as the user clicks on the start buttons. To enable automatic
// uploads, set the following option to true:
autoUpload: false,
+ // The class to show/hide UI elements:
+ showElementClass: 'in',
// The ID of the upload template:
uploadTemplateId: 'template-upload',
// The ID of the download template:
@@ -75,12 +77,12 @@
// Function returning the current number of files,
// used by the maxNumberOfFiles validation:
- getNumberOfFiles: function() {
+ getNumberOfFiles: function () {
return this.filesContainer.children().not('.processing').length;
},
// Callback to retrieve the list of files from the server response:
- getFilesFromResponse: function(data) {
+ getFilesFromResponse: function (data) {
if (data.result && $.isArray(data.result.files)) {
return data.result.files;
}
@@ -90,7 +92,7 @@
// 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) {
+ add: function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
@@ -107,12 +109,12 @@
that._forceReflow(data.context);
that._transition(data.context);
data
- .process(function() {
+ .process(function () {
return $this.fileupload('process', data);
})
- .always(function() {
+ .always(function () {
data.context
- .each(function(index) {
+ .each(function (index) {
$(this)
.find('.size')
.text(that._formatFileSize(data.files[index].size));
@@ -120,7 +122,7 @@
.removeClass('processing');
that._renderPreviews(data);
})
- .done(function() {
+ .done(function () {
data.context.find('.edit,.start').prop('disabled', false);
if (
that._trigger('added', e, data) !== false &&
@@ -130,21 +132,19 @@
data.submit();
}
})
- .fail(function() {
+ .fail(function () {
if (data.files.error) {
- data.context.each(function(index) {
+ data.context.each(function (index) {
var error = data.files[index].error;
if (error) {
- $(this)
- .find('.error')
- .text(error);
+ $(this).find('.error').text(error);
}
});
}
});
},
// Callback for the start of each file upload request:
- send: function(e, data) {
+ send: function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
@@ -169,7 +169,7 @@
return that._trigger('sent', e, data);
},
// Callback for successful uploads:
- done: function(e, data) {
+ done: function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
@@ -181,14 +181,14 @@
template,
deferred;
if (data.context) {
- data.context.each(function(index) {
+ data.context.each(function (index) {
var file = files[index] || { error: 'Empty file upload result' };
deferred = that._addFinishedDeferreds();
- that._transition($(this)).done(function() {
+ that._transition($(this)).done(function () {
var node = $(this);
template = that._renderDownload([file]).replaceAll(node);
that._forceReflow(template);
- that._transition(template).done(function() {
+ that._transition(template).done(function () {
data.context = $(this);
that._trigger('completed', e, data);
that._trigger('finished', e, data);
@@ -204,7 +204,7 @@
);
that._forceReflow(template);
deferred = that._addFinishedDeferreds();
- that._transition(template).done(function() {
+ that._transition(template).done(function () {
data.context = $(this);
that._trigger('completed', e, data);
that._trigger('finished', e, data);
@@ -213,7 +213,7 @@
}
},
// Callback for failed (abort or error) uploads:
- fail: function(e, data) {
+ fail: function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
@@ -222,17 +222,17 @@
template,
deferred;
if (data.context) {
- data.context.each(function(index) {
+ data.context.each(function (index) {
if (data.errorThrown !== 'abort') {
var file = data.files[index];
file.error =
file.error || data.errorThrown || data.i18n('unknownError');
deferred = that._addFinishedDeferreds();
- that._transition($(this)).done(function() {
+ that._transition($(this)).done(function () {
var node = $(this);
template = that._renderDownload([file]).replaceAll(node);
that._forceReflow(template);
- that._transition(template).done(function() {
+ that._transition(template).done(function () {
data.context = $(this);
that._trigger('failed', e, data);
that._trigger('finished', e, data);
@@ -241,7 +241,7 @@
});
} else {
deferred = that._addFinishedDeferreds();
- that._transition($(this)).done(function() {
+ that._transition($(this)).done(function () {
$(this).remove();
that._trigger('failed', e, data);
that._trigger('finished', e, data);
@@ -258,7 +258,7 @@
.data('data', data);
that._forceReflow(data.context);
deferred = that._addFinishedDeferreds();
- that._transition(data.context).done(function() {
+ that._transition(data.context).done(function () {
data.context = $(this);
that._trigger('failed', e, data);
that._trigger('finished', e, data);
@@ -271,13 +271,13 @@
}
},
// Callback for upload progress events:
- progress: function(e, data) {
+ progress: function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
var progress = Math.floor((data.loaded / data.total) * 100);
if (data.context) {
- data.context.each(function() {
+ data.context.each(function () {
$(this)
.find('.progress')
.attr('aria-valuenow', progress)
@@ -288,7 +288,7 @@
}
},
// Callback for global upload progress events:
- progressall: function(e, data) {
+ progressall: function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
@@ -311,62 +311,64 @@
.css('width', progress + '%');
},
// Callback for uploads start, equivalent to the global ajaxStart event:
- start: function(e) {
+ start: function (e) {
if (e.isDefaultPrevented()) {
return false;
}
var that =
$(this).data('blueimp-fileupload') || $(this).data('fileupload');
that._resetFinishedDeferreds();
- that._transition($(this).find('.fileupload-progress')).done(function() {
- that._trigger('started', e);
- });
+ that
+ ._transition($(this).find('.fileupload-progress'))
+ .done(function () {
+ that._trigger('started', e);
+ });
},
// Callback for uploads stop, equivalent to the global ajaxStop event:
- stop: function(e) {
+ stop: function (e) {
if (e.isDefaultPrevented()) {
return false;
}
var that =
$(this).data('blueimp-fileupload') || $(this).data('fileupload'),
deferred = that._addFinishedDeferreds();
- $.when.apply($, that._getFinishedDeferreds()).done(function() {
+ $.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')
- .children()
- .first()
- .css('width', '0%');
- $(this)
- .find('.progress-extended')
- .html('&nbsp;');
- deferred.resolve();
- });
+ that
+ ._transition($(this).find('.fileupload-progress'))
+ .done(function () {
+ $(this)
+ .find('.progress')
+ .attr('aria-valuenow', '0')
+ .children()
+ .first()
+ .css('width', '0%');
+ $(this).find('.progress-extended').html('&nbsp;');
+ deferred.resolve();
+ });
},
- processstart: function(e) {
+ processstart: function (e) {
if (e.isDefaultPrevented()) {
return false;
}
$(this).addClass('fileupload-processing');
},
- processstop: function(e) {
+ processstop: function (e) {
if (e.isDefaultPrevented()) {
return false;
}
$(this).removeClass('fileupload-processing');
},
// Callback for file deletion:
- destroy: function(e, data) {
+ destroy: function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
var that =
$(this).data('blueimp-fileupload') || $(this).data('fileupload'),
- removeNode = function() {
- that._transition(data.context).done(function() {
+ removeNode = function () {
+ that._transition(data.context).done(function () {
$(this).remove();
that._trigger('destroyed', e, data);
});
@@ -375,7 +377,7 @@
data.dataType = data.dataType || that.options.dataType;
$.ajax(data)
.done(removeNode)
- .fail(function() {
+ .fail(function () {
that._trigger('destroyfailed', e, data);
});
} else {
@@ -384,29 +386,29 @@
}
},
- _resetFinishedDeferreds: function() {
+ _resetFinishedDeferreds: function () {
this._finishedUploads = [];
},
- _addFinishedDeferreds: function(deferred) {
+ _addFinishedDeferreds: function (deferred) {
// eslint-disable-next-line new-cap
var promise = deferred || $.Deferred();
this._finishedUploads.push(promise);
return promise;
},
- _getFinishedDeferreds: function() {
+ _getFinishedDeferreds: function () {
return this._finishedUploads;
},
// Link handler, that allows to download files
// by drag & drop of the links to the desktop:
- _enableDragToDesktop: function() {
+ _enableDragToDesktop: function () {
var link = $(this),
url = link.prop('href'),
name = link.prop('download'),
type = 'application/octet-stream';
- link.bind('dragstart', function(e) {
+ link.on('dragstart', function (e) {
try {
e.originalEvent.dataTransfer.setData(
'DownloadURL',
@@ -418,7 +420,7 @@
});
},
- _formatFileSize: function(bytes) {
+ _formatFileSize: function (bytes) {
if (typeof bytes !== 'number') {
return '';
}
@@ -431,7 +433,7 @@
return (bytes / 1000).toFixed(2) + ' KB';
},
- _formatBitrate: function(bits) {
+ _formatBitrate: function (bits) {
if (typeof bits !== 'number') {
return '';
}
@@ -447,7 +449,7 @@
return bits.toFixed(2) + ' bit/s';
},
- _formatTime: function(seconds) {
+ _formatTime: function (seconds) {
var date = new Date(seconds * 1000),
days = Math.floor(seconds / 86400);
days = days ? days + 'd ' : '';
@@ -461,11 +463,11 @@
);
},
- _formatPercentage: function(floatValue) {
+ _formatPercentage: function (floatValue) {
return (floatValue * 100).toFixed(2) + ' %';
},
- _renderExtendedProgress: function(data) {
+ _renderExtendedProgress: function (data) {
return (
this._formatBitrate(data.bitrate) +
' | ' +
@@ -479,7 +481,7 @@
);
},
- _renderTemplate: function(func, files) {
+ _renderTemplate: function (func, files) {
if (!func) {
return $();
}
@@ -491,31 +493,27 @@
if (result instanceof $) {
return result;
}
- return $(this.options.templatesContainer)
- .html(result)
- .children();
+ return $(this.options.templatesContainer).html(result).children();
},
- _renderPreviews: function(data) {
- data.context.find('.preview').each(function(index, elm) {
- $(elm)
- .empty()
- .append(data.files[index].preview);
+ _renderPreviews: function (data) {
+ data.context.find('.preview').each(function (index, elm) {
+ $(elm).empty().append(data.files[index].preview);
});
},
- _renderUpload: function(files) {
+ _renderUpload: function (files) {
return this._renderTemplate(this.options.uploadTemplate, files);
},
- _renderDownload: function(files) {
+ _renderDownload: function (files) {
return this._renderTemplate(this.options.downloadTemplate, files)
.find('a[download]')
.each(this._enableDragToDesktop)
.end();
},
- _editHandler: function(e) {
+ _editHandler: function (e) {
e.preventDefault();
if (!this.options.edit) return;
var that = this,
@@ -523,24 +521,24 @@
template = button.closest('.template-upload'),
data = template.data('data'),
index = button.data().index;
- this.options.edit(data.files[index]).then(function(file) {
+ this.options.edit(data.files[index]).then(function (file) {
if (!file) return;
data.files[index] = file;
data.context.addClass('processing');
template.find('.edit,.start').prop('disabled', true);
$(that.element)
.fileupload('process', data)
- .always(function() {
+ .always(function () {
template
.find('.size')
.text(that._formatFileSize(data.files[index].size));
data.context.removeClass('processing');
that._renderPreviews(data);
})
- .done(function() {
+ .done(function () {
template.find('.edit,.start').prop('disabled', false);
})
- .fail(function() {
+ .fail(function () {
template.find('.edit').prop('disabled', false);
var error = data.files[index].error;
if (error) {
@@ -550,7 +548,7 @@
});
},
- _startHandler: function(e) {
+ _startHandler: function (e) {
e.preventDefault();
var button = $(e.currentTarget),
template = button.closest('.template-upload'),
@@ -561,7 +559,7 @@
}
},
- _cancelHandler: function(e) {
+ _cancelHandler: function (e) {
e.preventDefault();
var template = $(e.currentTarget).closest(
'.template-upload,.template-download'
@@ -576,7 +574,7 @@
}
},
- _deleteHandler: function(e) {
+ _deleteHandler: function (e) {
e.preventDefault();
var button = $(e.currentTarget);
this._trigger(
@@ -592,11 +590,11 @@
);
},
- _forceReflow: function(node) {
+ _forceReflow: function (node) {
return $.support.transition && node.length && node[0].offsetWidth;
},
- _transition: function(node) {
+ _transition: function (node) {
// eslint-disable-next-line new-cap
var dfd = $.Deferred();
if (
@@ -604,52 +602,52 @@
node.hasClass('fade') &&
node.is(':visible')
) {
- var transitionEndHandler = function(e) {
+ var transitionEndHandler = function (e) {
// Make sure we don't respond to other transition events
// in the container element, e.g. from button elements:
if (e.target === node[0]) {
- node.unbind($.support.transition.end, transitionEndHandler);
+ node.off($.support.transition.end, transitionEndHandler);
dfd.resolveWith(node);
}
};
node
- .bind($.support.transition.end, transitionEndHandler)
- .toggleClass('in');
+ .on($.support.transition.end, transitionEndHandler)
+ .toggleClass(this.options.showElementClass);
} else {
- node.toggleClass('in');
+ node.toggleClass(this.options.showElementClass);
dfd.resolveWith(node);
}
return dfd;
},
- _initButtonBarEventHandlers: function() {
+ _initButtonBarEventHandlers: function () {
var fileUploadButtonBar = this.element.find('.fileupload-buttonbar'),
filesList = this.options.filesContainer;
this._on(fileUploadButtonBar.find('.start'), {
- click: function(e) {
+ click: function (e) {
e.preventDefault();
- filesList.find('.start').click();
+ filesList.find('.start').trigger('click');
}
});
this._on(fileUploadButtonBar.find('.cancel'), {
- click: function(e) {
+ click: function (e) {
e.preventDefault();
- filesList.find('.cancel').click();
+ filesList.find('.cancel').trigger('click');
}
});
this._on(fileUploadButtonBar.find('.delete'), {
- click: function(e) {
+ click: function (e) {
e.preventDefault();
filesList
.find('.toggle:checked')
.closest('.template-download')
.find('.delete')
- .click();
+ .trigger('click');
fileUploadButtonBar.find('.toggle').prop('checked', false);
}
});
this._on(fileUploadButtonBar.find('.toggle'), {
- change: function(e) {
+ change: function (e) {
filesList
.find('.toggle')
.prop('checked', $(e.currentTarget).is(':checked'));
@@ -657,7 +655,7 @@
});
},
- _destroyButtonBarEventHandlers: function() {
+ _destroyButtonBarEventHandlers: function () {
this._off(
this.element
.find('.fileupload-buttonbar')
@@ -667,7 +665,7 @@
this._off(this.element.find('.fileupload-buttonbar .toggle'), 'change.');
},
- _initEventHandlers: function() {
+ _initEventHandlers: function () {
this._super();
this._on(this.options.filesContainer, {
'click .edit': this._editHandler,
@@ -678,13 +676,13 @@
this._initButtonBarEventHandlers();
},
- _destroyEventHandlers: function() {
+ _destroyEventHandlers: function () {
this._destroyButtonBarEventHandlers();
this._off(this.options.filesContainer, 'click');
this._super();
},
- _enableFileInputButton: function() {
+ _enableFileInputButton: function () {
this.element
.find('.fileinput-button input')
.prop('disabled', false)
@@ -692,7 +690,7 @@
.removeClass('disabled');
},
- _disableFileInputButton: function() {
+ _disableFileInputButton: function () {
this.element
.find('.fileinput-button input')
.prop('disabled', true)
@@ -700,7 +698,7 @@
.addClass('disabled');
},
- _initTemplates: function() {
+ _initTemplates: function () {
var options = this.options;
options.templatesContainer = this.document[0].createElement(
options.filesContainer.prop('nodeName')
@@ -715,7 +713,7 @@
}
},
- _initFilesContainer: function() {
+ _initFilesContainer: function () {
var options = this.options;
if (options.filesContainer === undefined) {
options.filesContainer = this.element.find('.files');
@@ -724,13 +722,13 @@
}
},
- _initSpecialOptions: function() {
+ _initSpecialOptions: function () {
this._super();
this._initFilesContainer();
this._initTemplates();
},
- _create: function() {
+ _create: function () {
this._super();
this._resetFinishedDeferreds();
if (!$.support.fileInput) {
@@ -738,7 +736,7 @@
}
},
- enable: function() {
+ enable: function () {
var wasDisabled = false;
if (this.options.disabled) {
wasDisabled = true;
@@ -750,7 +748,7 @@
}
},
- disable: function() {
+ disable: function () {
if (!this.options.disabled) {
this.element.find('input, button').prop('disabled', true);
this._disableFileInputButton();