diff --git a/Resources/js/widget/file_upload.js b/Resources/js/widget/file_upload.js index c93c531c3180b80c24eb2e6d0a10ef81aff4119e..7f5fed04912b72dc015a700d7a999357c6a62410 100644 --- a/Resources/js/widget/file_upload.js +++ b/Resources/js/widget/file_upload.js @@ -4,15 +4,18 @@ */ (function($) { - var formatFileSize = function(size) { + var formatFileSize = function(size, precision) { + if(typeof(precision) === "undefined") { + precision = 2; + } if(size > 1000000000) { - return (size/1000000000).toFixed(2) + ' Gio'; + return (size/1000000000).toFixed(precision) + ' Gio'; } if(size > 1000000) { - return (size/1000000).toFixed(2) + ' Mio'; + return (size/1000000).toFixed(precision) + ' Mio'; } if(size > 1000) { - return (size/1000).toFixed(2)+ ' Kio'; + return (size/1000).toFixed(precision)+ ' Kio'; } return size + ' o'; }, @@ -56,8 +59,8 @@ $button.toggle(options.multiple || !hasEntry); }; - $this.find('.template-download .size').each(function() { - $(this).text(formatFileSize($(this).text())); + $this.find('.size').each(function() { + $(this).text(formatFileSize($(this).text(), $(this).data('size-precision'))); }); updateDisplay();