diff --git a/codepot/src/codepot/views/file_home.php b/codepot/src/codepot/views/file_home.php index 07410337..b054f999 100644 --- a/codepot/src/codepot/views/file_home.php +++ b/codepot/src/codepot/views/file_home.php @@ -58,7 +58,7 @@ var import_in_progress = false; var populated_file_obj = []; var populated_file_max = 0; -function populate_selected_files () +function populate_selected_files_with (files) { var file_desc = {}; for (var n = 0; n < populated_file_max; n++) @@ -71,26 +71,26 @@ function populate_selected_files () } } - $('#file_home_new_file_table').empty(); + var new_file_table = $('#file_home_new_file_table'); + new_file_table.empty(); populated_file_obj = []; - var f = $('#file_home_new_files').get(0); var f_no = 0; - for (var n = 0; n < f.files.length; n++) + for (var n = 0; n < files.length; n++) { - if (f.files[n] != null) + if (files[n] != null) { - var desc = file_desc[f.files[n].name]; + var desc = file_desc[files[n].name]; if (desc == null) desc = ''; - $('#file_home_new_file_table').append ( + new_file_table.append ( codepot_sprintf ( '%s', - f_no, f_no, f_no, codepot_htmlspecialchars(f.files[n].name), f_no, codepot_addslashes(desc) + f_no, f_no, f_no, codepot_htmlspecialchars(files[n].name), f_no, codepot_addslashes(desc) ) ); - populated_file_obj[f_no] = f.files[n]; + populated_file_obj[f_no] = files[n]; f_no++; } } @@ -98,6 +98,11 @@ function populate_selected_files () populated_file_max = f_no; } +function populate_selected_files () +{ + return populate_selected_files_with ($('#file_home_new_files').get(0).files); +} + function cancel_out_new_file (no) { $('#file_home_new_file_row_' + no).remove (); @@ -219,6 +224,32 @@ $(function () { return false; // prevent the default behavior } ); + + var file_drag_event_handler = function(e) { return false; }; + var file_drop_event_handler = function(e) + { + var aff = $('#file_home_new_form_div'); + aff.dialog('close'); + populate_selected_files_with(e.originalEvent.dataTransfer.files); + aff.dialog('open'); + return false; + }; + + var tmp = $('#file_home_content'); + tmp.bind('dragstart', file_drag_event_handler); + tmp.bind('dragenter', file_drag_event_handler); + tmp.bind('dragleave', file_drag_event_handler); + tmp.bind('dragover', file_drag_event_handler); + tmp.bind('dragend', file_drop_event_handler); + tmp.bind('drop', file_drop_event_handler); + + var tmp = $('#file_home_new_form_div').dialog(); + tmp.bind('dragstart', file_drag_event_handler); + tmp.bind('dragenter', file_drag_event_handler); + tmp.bind('dragleave', file_drag_event_handler); + tmp.bind('dragover', file_drag_event_handler); + tmp.bind('dragend', file_drop_event_handler); + tmp.bind('drop', file_drop_event_handler); }); diff --git a/codepot/src/codepot/views/file_show.php b/codepot/src/codepot/views/file_show.php index 55c6cfbb..da6e0dc2 100644 --- a/codepot/src/codepot/views/file_show.php +++ b/codepot/src/codepot/views/file_show.php @@ -570,11 +570,17 @@ $(function () { }; var tmp = $('#file_show_content'); + tmp.bind('dragstart', file_drag_event_handler); + tmp.bind('dragenter', file_drag_event_handler); + tmp.bind('dragleave', file_drag_event_handler); tmp.bind('dragover', file_drag_event_handler); tmp.bind('dragend', file_drop_event_handler); tmp.bind('drop', file_drop_event_handler); var tmp = $('#file_show_add_file_form').dialog(); + tmp.bind('dragstart', file_drag_event_handler); + tmp.bind('dragenter', file_drag_event_handler); + tmp.bind('dragleave', file_drag_event_handler); tmp.bind('dragover', file_drag_event_handler); tmp.bind('dragend', file_drop_event_handler); tmp.bind('drop', file_drop_event_handler);