diff --git a/Resources/js/widget/file_upload.js b/Resources/js/widget/file_upload.js index e265b02264713fdc7ecc863db7fbe8c29125532d..cf0aa4d2e12b9caf88b742f05f4c4b663c14171f 100644 --- a/Resources/js/widget/file_upload.js +++ b/Resources/js/widget/file_upload.js @@ -4,6 +4,22 @@ */ (function($) { + var formatSize = function(size) { + if(size > 1000000000) { + return (size/1000000000).toFixed(2) + ' Gio'; + } + if(size > 1000000) { + return (size/1000000).toFixed(2) + ' Mio'; + } + if(size > 1000) { + return (size/1000).toFixed(2)+ ' Kio'; + } + return size + ' o'; + }, + formatBitrate = function(rate) { + return formatSize(rate) + '/s'; + }; + /** Plugin irsteaFileUpload. */ $.fn.irsteaFileUpload = function(options) { @@ -23,28 +39,13 @@ options.acceptFileTypes = new RegExp('^' + options.acceptFileTypes + '$'); } - var formatSize = function(size) { - if(size > 1000000000) { - return (size/1000000000).toFixed(2) + ' Gio'; - } - if(size > 1000000) { - return (size/1000000).toFixed(2) + ' Mio'; - } - if(size > 1000) { - return (size/1000).toFixed(2)+ ' Kio'; - } - return size + ' o'; - }, - formatBitrate = function(rate) { - return formatSize(rate) + '/s'; - }, - updateButtonVisibility = function() { - if($entries.children().length > 0 && !options.multiple) { - $button.hide(); - } else { - $button.show(); - } - }; + var updateButtonVisibility = function() { + if($entries.children().length > 0 && !options.multiple) { + $button.hide(); + } else { + $button.show(); + } + }; $this.find('.template-download .size').each(function() { $(this).html(formatSize($(this).text())); });