Implemented files copying (with drag-n-drop and SHIFT key)
This commit is contained in:
parent
fa1cc97ed5
commit
b8f4b4332a
5 changed files with 81 additions and 7 deletions
|
@ -86,7 +86,7 @@ window.rcmail && rcmail.addEventListener('init', function() {
|
|||
// "one file only" commands
|
||||
rcmail.env.file_commands = ['files-get'];
|
||||
// "one or more file" commands
|
||||
rcmail.env.file_commands_all = ['files-delete'];
|
||||
rcmail.env.file_commands_all = ['files-delete', 'files-move', 'files-copy'];
|
||||
|
||||
kolab_files_init();
|
||||
file_api.folder_list();
|
||||
|
@ -448,17 +448,37 @@ kolab_files_list_select = function(list)
|
|||
// rcmail.select_all_mode = false;
|
||||
};
|
||||
|
||||
kolab_files_drag_end = function()
|
||||
kolab_files_drag_end = function(e)
|
||||
{
|
||||
var folder = $('#files-folder-list li.droptarget').removeClass('droptarget');
|
||||
|
||||
if (folder.length) {
|
||||
folder = folder.data('folder');
|
||||
|
||||
file_api.file_move(kolab_files_selected(), folder);
|
||||
var modkey = rcube_event.get_modifier(e),
|
||||
menu = rcmail.gui_objects.file_dragmenu;
|
||||
|
||||
if (menu && modkey == SHIFT_KEY && rcmail.commands['files-copy']) {
|
||||
var pos = rcube_event.get_mouse_pos(e);
|
||||
rcmail.env.drag_target = folder;
|
||||
$(menu).css({top: (pos.y-10)+'px', left: (pos.x-10)+'px'}).show();
|
||||
return;
|
||||
}
|
||||
|
||||
rcmail.command('files-move', folder);
|
||||
}
|
||||
};
|
||||
|
||||
kolab_files_drag_menu_action = function(command)
|
||||
{
|
||||
var menu = rcmail.gui_objects.file_dragmenu;
|
||||
|
||||
if (menu)
|
||||
$(menu).hide();
|
||||
|
||||
rcmail.command(command, rcmail.env.drag_target);
|
||||
};
|
||||
|
||||
kolab_files_selected = function()
|
||||
{
|
||||
var files = [];
|
||||
|
@ -529,6 +549,18 @@ rcube_webmail.prototype.files_delete = function()
|
|||
file_api.file_delete(files);
|
||||
};
|
||||
|
||||
rcube_webmail.prototype.files_move = function(folder)
|
||||
{
|
||||
var files = kolab_files_selected();
|
||||
file_api.file_move(files, folder);
|
||||
};
|
||||
|
||||
rcube_webmail.prototype.files_copy = function(folder)
|
||||
{
|
||||
var files = kolab_files_selected();
|
||||
file_api.file_copy(files, folder);
|
||||
};
|
||||
|
||||
rcube_webmail.prototype.files_upload = function(form)
|
||||
{
|
||||
if (form)
|
||||
|
@ -850,6 +882,30 @@ function kolab_files_ui()
|
|||
this.file_list();
|
||||
};
|
||||
|
||||
// file(s) copy request
|
||||
this.file_copy = function(files, folder)
|
||||
{
|
||||
if (!files || !files.length || !folder)
|
||||
return;
|
||||
|
||||
var list = {};
|
||||
$.each(files, function(i, v) {
|
||||
list[v] = folder + file_api.env.directory_separator + file_api.file_name(v);
|
||||
});
|
||||
|
||||
this.req = this.set_busy(true, 'kolab_files.filecopying');
|
||||
this.get('file_copy', {file: list}, 'file_copy_response');
|
||||
};
|
||||
|
||||
// file(s) copy response handler
|
||||
this.file_copy_response = function(response)
|
||||
{
|
||||
if (!this.response(response))
|
||||
return;
|
||||
|
||||
this.display_message('kolab_files.filecopynotice', 'confirmation');
|
||||
};
|
||||
|
||||
// file upload request
|
||||
this.file_upload = function(form)
|
||||
{
|
||||
|
|
|
@ -456,10 +456,13 @@ class kolab_files_engine
|
|||
|
||||
protected function action_index()
|
||||
{
|
||||
$this->rc->output->add_label('deletefolderconfirm', 'kolab_files.folderdeleting',
|
||||
'kolab_files.foldercreating', 'kolab_files.uploading', 'kolab_files.filedeleteconfirm',
|
||||
'kolab_files.folderdeleteconfirm', 'kolab_files.filedeleting', 'kolab_files.filedeletenotice',
|
||||
'kolab_files.filemoving', 'kolab_files.filemovenotice');
|
||||
$this->rc->output->add_label(
|
||||
'kolab_files.folderdeleting', 'kolab_files.folderdeleteconfirm',
|
||||
'kolab_files.foldercreating', 'kolab_files.uploading',
|
||||
'kolab_files.filedeleting', 'kolab_files.filedeletenotice', 'kolab_files.filedeleteconfirm',
|
||||
'kolab_files.filemoving', 'kolab_files.filemovenotice',
|
||||
'kolab_files.filecopying', 'kolab_files.filecopynotice'
|
||||
);
|
||||
|
||||
$this->rc->output->set_pagetitle($this->plugin->gettext('files'));
|
||||
$this->rc->output->send('kolab_files.files');
|
||||
|
|
|
@ -37,9 +37,11 @@ $labels['saveallnotice'] = 'Successfully saved $n file(s).';
|
|||
$labels['saveallerror'] = 'Saving $n file(s) failed.';
|
||||
$labels['attacherror'] = 'Failed to attach file(s) from the cloud';
|
||||
$labels['filemoving'] = 'Moving file(s)...';
|
||||
$labels['filecopying'] = 'Copying file(s)...';
|
||||
$labels['filedeleting'] = 'Deleting file(s)...';
|
||||
$labels['filedeleteconfirm'] = 'Are you sure you want to delete selected files?';
|
||||
$labels['filedeletenotice'] = 'File(s) deleted successfully.';
|
||||
$labels['filemovenotice'] = 'File(s) moved successfully.';
|
||||
$labels['filecopynotice'] = 'File(s) copied successfully.';
|
||||
|
||||
?>
|
||||
|
|
|
@ -99,6 +99,13 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="dragfilemenu" class="popupmenu">
|
||||
<ul class="toolbarmenu">
|
||||
<li><roundcube:button command="files-move" onclick="return kolab_files_drag_menu_action('files-move')" label="move" classAct="active" /></li>
|
||||
<li><roundcube:button command="files-copy" onclick="return kolab_files_drag_menu_action('files-copy')" label="copy" classAct="active" /></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<roundcube:include file="/includes/footer.html" />
|
||||
<script type="text/javascript">
|
||||
kolab_files_ui_init();
|
||||
|
|
|
@ -6,6 +6,12 @@ function kolab_files_ui_init()
|
|||
$(document).ready(function() {
|
||||
rcmail.addEventListener('menu-open', kolab_files_show_listoptions);
|
||||
rcmail.addEventListener('menu-save', kolab_files_save_listoptions);
|
||||
|
||||
var dragmenu = $('#dragfilemenu');
|
||||
if (dragmenu.length) {
|
||||
rcmail.gui_object('file_dragmenu', 'dragfilemenu');
|
||||
UI.add_popup('dragfilemenu', {sticky: 1});
|
||||
}
|
||||
});
|
||||
|
||||
kolab_files_upload_input('#filestoolbar a.upload');
|
||||
|
|
Loading…
Add table
Reference in a new issue