Commit ab24f5a2 authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

js: vérifie l'attribut 'data-size-precision' pour formatter les tailles.

Showing with 9 additions and 6 deletions
+9 -6
......@@ -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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment