Skip to content

Commit

Permalink
[task_edit/files] fix drag and drop behaviour
Browse files Browse the repository at this point in the history
Fixes #984
  • Loading branch information
anthonygego committed Nov 23, 2023
1 parent 1907e7b commit 3fa7be6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
16 changes: 7 additions & 9 deletions inginious/frontend/static/js/studio.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,28 +691,31 @@ function drag_drop_handler() {

// Drag enter
$(".upload-area").on('dragenter', function (e) {
$("#edit_task_tabs_content").append("<p id='dragtext'><b>Drag a file here</b></p>");
$("#dragtext").css("visibility", "visible");
$(this).addClass("dragin");
e.stopPropagation();
e.preventDefault();

});

// Drag over
$(".upload-area").on('dragover', function (e) {
$(this).addClass("dragin");
$("#dragtext").css("visibility", "visible");
e.stopPropagation();
e.preventDefault();

});

$(".upload-area").on('dragleave',function(e){
$(this).removeClass("dragin");
$("#dragtext").remove();
$("#dragtext").css("visibility", "hidden");
e.stopPropagation();
e.preventDefault();
});

// Drop
$(".upload-area").on('drop', function (e) {
$("#dragtext").remove();
$("#dragtext").css("visibility", "hidden");
e.stopPropagation();
e.preventDefault();

Expand All @@ -723,11 +726,6 @@ function drag_drop_handler() {
uploadData(fd);
});

// Open file selector on div click
$(".upload-area").click(function(){
$("#file").click();
});

// file selected
$("#file").change(function(){
var fd = new FormData();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{# This file is part of INGInious. See the LICENSE and the COPYRIGHTS files for #}
{# more information about the licensing of this file. #}

<div role="tabpanel" class="tab-pane show active upload-area" id="tab_file_list">
<div role="tabpanel" class="tab-pane show active " id="tab_file_list">

{% if error is not none %}
<div class="alert alert-danger" role="alert" style="text-align: center;">
{{ error }}
Expand All @@ -10,7 +11,7 @@

<input type="file" name="file" id="file" style="display: none;">
<div style="overflow-x:auto;">
<table class="table table-bordered table-sm">
<table class="table table-bordered table-sm upload-area">
<thead class="table-borderless">
<th class="col-sm-8">{{_("Path")}}</th>
<th class="col-sm-1">{{_("Download")}}</th>
Expand Down Expand Up @@ -66,4 +67,4 @@
drag_drop_handler();
</script>
</div>

<p id="dragtext" class="mb-0" style="visibility: hidden;"><b>{{ _("Drag and drop a file here.") }}</b></p>

0 comments on commit 3fa7be6

Please sign in to comment.