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

file_upload.js: partage des fonctions qui n'ont pas besoin d'être des closures.

Showing with 23 additions and 22 deletions
+23 -22
......@@ -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())); });
......
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