Commit 69148c99 by Kálmán Viktor

dashboard: store js clean up

parent 61450d0d
...@@ -14,11 +14,16 @@ $(function() { ...@@ -14,11 +14,16 @@ $(function() {
return false; return false;
}); });
/* less js way, but at least works, tho redirection is bad */ /* how upload works
* - user clicks on a "fake" browse button, this triggers a click event on the file upload
* - if the file input changes it adds the name of the file to form (or number of files if multiple is enabled)
* - and finally when we click on the upload button (this event handler) it firsts ask the store api where to upload
* then changes the form's action attr before sending the form itself
*/
$("#store-list-container").on("click", '#store-upload-form button[type="submit"]', function() { $("#store-list-container").on("click", '#store-upload-form button[type="submit"]', function() {
var current_dir = $("#store-upload-form").find('[name="current_dir"]').val(); var current_dir = $("#store-upload-form").find('[name="current_dir"]').val();
$.get($("#store-upload-form").data("action") + "?current_dir=" + current_dir, function(result) { $.get($("#store-upload-form").data("action") + "?current_dir=" + current_dir, function(result) {
$('#store-upload-form button[type="submit"] i').addClass("icon-spinner icon-spin"); $('#store-upload-form button[type="submit"] i').addClass("fa-spinner fa-spin");
$("#store-upload-form").get(0).setAttribute("action", result['url']); $("#store-upload-form").get(0).setAttribute("action", result['url']);
$("#store-upload-form").submit(); $("#store-upload-form").submit();
}); });
...@@ -26,7 +31,7 @@ $(function() { ...@@ -26,7 +31,7 @@ $(function() {
return false; return false;
}); });
/* click on the "fake" browse button will */ /* "fake" browse button */
$("#store-list-container").on("click", "#store-upload-browse", function() { $("#store-list-container").on("click", "#store-upload-browse", function() {
$('#store-upload-form input[type="file"]').click(); $('#store-upload-form input[type="file"]').click();
}); });
...@@ -46,28 +51,9 @@ $(function() { ...@@ -46,28 +51,9 @@ $(function() {
} }
if(log) { if(log) {
$('#store-upload-form button[type="submit"]').prop("disabled", false); $('#store-upload-form button[type="submit"]').prop("disabled", false);
} else { } else {
$('#store-upload-form button[type="submit"]').prop("disabled", true); $('#store-upload-form button[type="submit"]').prop("disabled", true);
} }
});
/* this does not work
$('form input[type="submit"]').click(function() {
var current_dir = $("form").find('[name="current_dir"]').val();
$.get($("form").data("action") + "?current_dir=" + current_dir, function(result) {
$.ajax({
method: "POST",
url: result['url'],
data: $("form").serialize(),
success: function(re) {
console.log(re);
}
}); });
});
return false;
}); */
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment