diff options
author | Mario <mario@mariovavti.com> | 2020-05-07 21:48:26 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2020-05-07 21:48:26 +0000 |
commit | f132436af3c90cff8dcef852bd836546311036f3 (patch) | |
tree | 89531366ba5fc62095981a81a91a2fc52adcad9c /vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js | |
parent | fae70bf0a7f1b566d25e30064f60d58ab150951a (diff) | |
download | volse-hubzilla-f132436af3c90cff8dcef852bd836546311036f3.tar.gz volse-hubzilla-f132436af3c90cff8dcef852bd836546311036f3.tar.bz2 volse-hubzilla-f132436af3c90cff8dcef852bd836546311036f3.zip |
composer updates 2
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.js | 202 |
1 files changed, 99 insertions, 103 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 ff725cf14..c42b18cc2 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( @@ -77,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; } @@ -92,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; } @@ -109,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)); @@ -122,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 && @@ -132,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; } @@ -171,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; } @@ -183,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); @@ -206,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); @@ -215,7 +213,7 @@ } }, // Callback for failed (abort or error) uploads: - fail: function(e, data) { + fail: function (e, data) { if (e.isDefaultPrevented()) { return false; } @@ -224,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); @@ -243,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); @@ -260,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); @@ -273,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) @@ -290,7 +288,7 @@ } }, // Callback for global upload progress events: - progressall: function(e, data) { + progressall: function (e, data) { if (e.isDefaultPrevented()) { return false; } @@ -313,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(' '); - 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(' '); + 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); }); @@ -377,7 +377,7 @@ data.dataType = data.dataType || that.options.dataType; $.ajax(data) .done(removeNode) - .fail(function() { + .fail(function () { that._trigger('destroyfailed', e, data); }); } else { @@ -386,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', @@ -420,7 +420,7 @@ }); }, - _formatFileSize: function(bytes) { + _formatFileSize: function (bytes) { if (typeof bytes !== 'number') { return ''; } @@ -433,7 +433,7 @@ return (bytes / 1000).toFixed(2) + ' KB'; }, - _formatBitrate: function(bits) { + _formatBitrate: function (bits) { if (typeof bits !== 'number') { return ''; } @@ -449,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 ' : ''; @@ -463,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) + ' | ' + @@ -481,7 +481,7 @@ ); }, - _renderTemplate: function(func, files) { + _renderTemplate: function (func, files) { if (!func) { return $(); } @@ -493,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, @@ -525,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) { @@ -552,7 +548,7 @@ }); }, - _startHandler: function(e) { + _startHandler: function (e) { e.preventDefault(); var button = $(e.currentTarget), template = button.closest('.template-upload'), @@ -563,7 +559,7 @@ } }, - _cancelHandler: function(e) { + _cancelHandler: function (e) { e.preventDefault(); var template = $(e.currentTarget).closest( '.template-upload,.template-download' @@ -578,7 +574,7 @@ } }, - _deleteHandler: function(e) { + _deleteHandler: function (e) { e.preventDefault(); var button = $(e.currentTarget); this._trigger( @@ -594,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 ( @@ -606,16 +602,16 @@ 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) + .on($.support.transition.end, transitionEndHandler) .toggleClass(this.options.showElementClass); } else { node.toggleClass(this.options.showElementClass); @@ -624,23 +620,23 @@ 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(); } }); this._on(fileUploadButtonBar.find('.cancel'), { - click: function(e) { + click: function (e) { e.preventDefault(); filesList.find('.cancel').click(); } }); this._on(fileUploadButtonBar.find('.delete'), { - click: function(e) { + click: function (e) { e.preventDefault(); filesList .find('.toggle:checked') @@ -651,7 +647,7 @@ } }); this._on(fileUploadButtonBar.find('.toggle'), { - change: function(e) { + change: function (e) { filesList .find('.toggle') .prop('checked', $(e.currentTarget).is(':checked')); @@ -659,7 +655,7 @@ }); }, - _destroyButtonBarEventHandlers: function() { + _destroyButtonBarEventHandlers: function () { this._off( this.element .find('.fileupload-buttonbar') @@ -669,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, @@ -680,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) @@ -694,7 +690,7 @@ .removeClass('disabled'); }, - _disableFileInputButton: function() { + _disableFileInputButton: function () { this.element .find('.fileinput-button input') .prop('disabled', true) @@ -702,7 +698,7 @@ .addClass('disabled'); }, - _initTemplates: function() { + _initTemplates: function () { var options = this.options; options.templatesContainer = this.document[0].createElement( options.filesContainer.prop('nodeName') @@ -717,7 +713,7 @@ } }, - _initFilesContainer: function() { + _initFilesContainer: function () { var options = this.options; if (options.filesContainer === undefined) { options.filesContainer = this.element.find('.files'); @@ -726,13 +722,13 @@ } }, - _initSpecialOptions: function() { + _initSpecialOptions: function () { this._super(); this._initFilesContainer(); this._initTemplates(); }, - _create: function() { + _create: function () { this._super(); this._resetFinishedDeferreds(); if (!$.support.fileInput) { @@ -740,7 +736,7 @@ } }, - enable: function() { + enable: function () { var wasDisabled = false; if (this.options.disabled) { wasDisabled = true; @@ -752,7 +748,7 @@ } }, - disable: function() { + disable: function () { if (!this.options.disabled) { this.element.find('input, button').prop('disabled', true); this._disableFileInputButton(); |