From 657a2836ff64cda734313d554a78b94d3f9407af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Perr=C3=A9al?= <guillaume.perreal@irstea.fr> Date: Fri, 23 Jan 2015 15:17:33 +0100 Subject: [PATCH] =?UTF-8?q?file=5Fupload.js:=20partage=20des=20fonctions?= =?UTF-8?q?=20qui=20n'ont=20pas=20besoin=20d'=C3=AAtre=20des=20closures.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Resources/js/widget/file_upload.js | 45 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/Resources/js/widget/file_upload.js b/Resources/js/widget/file_upload.js index e265b022..cf0aa4d2 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())); }); -- GitLab