diff --git a/bl-kernel/admin/themes/booty/html/media.php b/bl-kernel/admin/themes/booty/html/media.php index d4ce4436..e442972f 100644 --- a/bl-kernel/admin/themes/booty/html/media.php +++ b/bl-kernel/admin/themes/booty/html/media.php @@ -66,6 +66,14 @@ $amountOfPages = count($listOfFilesByPage); echo 'var preLoadFiles = '.json_encode($preLoadFiles).';'; ?> +function openMediaManager() { + $('#jsbluditMediaModal').modal('show') +} + +function closeMediaManager() { + $('#jsbluditMediaModal').modal('hide') +} + // Remove all files from the table function cleanFiles() { $('#jsbluditMediaTable').empty(); @@ -77,13 +85,13 @@ function displayFiles(files) { cleanFiles(); // Regenerate the table $.each(files, function(key, filename) { - tableRow = ''+ + tableRow = ''+ '200x200'+ - ''+ + ''+ '
'+filename+'
'+ '
'+ - ''+ - ''+ + ''+ + ''+ '
'+ ''+ ''; @@ -93,13 +101,27 @@ function displayFiles(files) { // Get the list of files via AJAX, filter by the page number function getFiles(pageNumber) { - $.getJSON("ajax/list-files", - { pageNumber: pageNumber, path: ""}, + $.post("ajax/list-files", + { tokenCSRF: tokenCSRF, + pageNumber: pageNumber, + path: "" + }, function(data) { displayFiles(data.files); }); } +// Delete the file and the thumbnail if exist +function deleteMedia(filename) { + $.post("ajax/delete-file", + { tokenCSRF: tokenCSRF, + filename: filename + }, + function(data) { + getFiles(1); + }); +} + $(document).ready(function() { // Display the files preloaded for the first time displayFiles(preLoadFiles); @@ -122,13 +144,16 @@ $(document).ready(function() { if (xhr.upload) { xhr.upload.addEventListener("progress", function(e) { if (e.lengthComputable) { - var percentComplete = e.loaded / e.total; + var percentComplete = (e.loaded / e.total)*100; $("#jsbluditProgressBar").width(percentComplete+"%"); } }, false); } return xhr; } + }).done(function() { + // Get the files of the first page, this include the uploaded files + getFiles(1); }); }); }); diff --git a/bl-kernel/admin/themes/booty/index.php b/bl-kernel/admin/themes/booty/index.php index c7d47b10..18164cf1 100644 --- a/bl-kernel/admin/themes/booty/index.php +++ b/bl-kernel/admin/themes/booty/index.php @@ -18,6 +18,9 @@ + + + @@ -36,10 +39,10 @@