mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-27 21:32:46 +02:00
* Filemanager: Fix drag out files to desktop
This commit is contained in:
parent
7ebab3f83e
commit
b528c4c22a
@ -145,9 +145,7 @@ export function egwDragActionImplementation()
|
|||||||
if('draggable' in document.createElement('span') &&
|
if('draggable' in document.createElement('span') &&
|
||||||
navigator && navigator.userAgent.indexOf('Chrome') >= 0 && egw.app_name() == 'filemanager') // currently only filemanager supports drag out
|
navigator && navigator.userAgent.indexOf('Chrome') >= 0 && egw.app_name() == 'filemanager') // currently only filemanager supports drag out
|
||||||
{
|
{
|
||||||
var key = ["Mac68K","MacPPC","MacIntel"].indexOf(window.navigator.platform) < 0 ?
|
text.text(egw.lang('You may darg files out to your desktop', itemLabel));
|
||||||
egw.lang('Alt') : egw.lang('Command ⌘');
|
|
||||||
text.text(egw.lang('Hold [%1] and [%2] key to drag %3 to your desktop', key, egw.lang('Shift ⇧'), itemLabel));
|
|
||||||
}
|
}
|
||||||
// Final html DOM return as helper structor
|
// Final html DOM return as helper structor
|
||||||
return div;
|
return div;
|
||||||
@ -176,8 +174,7 @@ export function egwDragActionImplementation()
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Disable file drag and drop, it conflicts with normal drag and drop
|
for (var i = 0; i < groups.drag.length; i++)
|
||||||
for (var i = 0; false && i < groups.drag.length; i++)
|
|
||||||
{
|
{
|
||||||
// dragType 'file' says it can be dragged as a file
|
// dragType 'file' says it can be dragged as a file
|
||||||
if(groups.drag[i].link.actionObj.dragType == 'file' || groups.drag[i].link.actionObj.dragType.indexOf('file') > -1)
|
if(groups.drag[i].link.actionObj.dragType == 'file' || groups.drag[i].link.actionObj.dragType.indexOf('file') > -1)
|
||||||
@ -187,9 +184,7 @@ export function egwDragActionImplementation()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!action)
|
// Bind mouse handlers
|
||||||
{
|
|
||||||
// Use Ctrl key in order to select content
|
|
||||||
jQuery(node).off("mousedown")
|
jQuery(node).off("mousedown")
|
||||||
.on({
|
.on({
|
||||||
mousedown: function(event){
|
mousedown: function(event){
|
||||||
@ -215,19 +210,25 @@ export function egwDragActionImplementation()
|
|||||||
jQuery('body').css({cursor:'auto'});
|
jQuery('body').css({cursor:'auto'});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
node.setAttribute('draggable', true);
|
node.setAttribute('draggable', true);
|
||||||
const dragstart = function(event) {
|
const dragstart = function(event) {
|
||||||
if (action) {
|
|
||||||
|
// The helper function is called before the start function
|
||||||
|
// is evoked. Call the given callback function. The callback
|
||||||
|
// function will gather the selected elements and action links
|
||||||
|
// and call the doExecuteImplementation function. This
|
||||||
|
// will call the onExecute function of the first action
|
||||||
|
// in order to obtain the helper object (stored in ai.helper)
|
||||||
|
// and the multiple dragDropTypes (ai.ddTypes)
|
||||||
|
_callback.call(_context, false, ai);
|
||||||
|
|
||||||
|
if (action && egw.app_name() == 'filemanager') {
|
||||||
if (_context.isSelection(event)) return;
|
if (_context.isSelection(event)) return;
|
||||||
|
|
||||||
// Get all selected
|
// Get all selected
|
||||||
// Multiples aren't supported by event.dataTransfer, yet, so
|
var selected = ai.selected;
|
||||||
// select only the row they clicked on.
|
|
||||||
var selected = [_context];
|
|
||||||
_context.parent.setAllSelected(false);
|
|
||||||
_context.setSelected(true);
|
|
||||||
|
|
||||||
// Set file data
|
// Set file data
|
||||||
for (let i = 0; i < selected.length; i++) {
|
for (let i = 0; i < selected.length; i++) {
|
||||||
@ -239,14 +240,7 @@ export function egwDragActionImplementation()
|
|||||||
if (url[0] == '/') url = egw.link(url);
|
if (url[0] == '/') url = egw.link(url);
|
||||||
// egw.link adds the webserver, but that might not be an absolute URL - try again
|
// egw.link adds the webserver, but that might not be an absolute URL - try again
|
||||||
if (url[0] == '/') url = window.location.origin + url;
|
if (url[0] == '/') url = window.location.origin + url;
|
||||||
|
|
||||||
// Unfortunately, dragging files is currently only supported by Chrome
|
|
||||||
if (navigator && navigator.userAgent.indexOf('Chrome')) {
|
|
||||||
event.dataTransfer.setData("DownloadURL", d.mime + ':' + d.name + ':' + url);
|
event.dataTransfer.setData("DownloadURL", d.mime + ':' + d.name + ':' + url);
|
||||||
} else {
|
|
||||||
// Include URL as a fallback
|
|
||||||
event.dataTransfer.setData("text/uri-list", url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.dataTransfer.effectAllowed = 'copy';
|
event.dataTransfer.effectAllowed = 'copy';
|
||||||
@ -259,14 +253,7 @@ export function egwDragActionImplementation()
|
|||||||
} else {
|
} else {
|
||||||
event.dataTransfer.effectAllowed = 'linkMove';
|
event.dataTransfer.effectAllowed = 'linkMove';
|
||||||
}
|
}
|
||||||
// The helper function is called before the start function
|
|
||||||
// is evoked. Call the given callback function. The callback
|
|
||||||
// function will gather the selected elements and action links
|
|
||||||
// and call the doExecuteImplementation function. This
|
|
||||||
// will call the onExecute function of the first action
|
|
||||||
// in order to obtain the helper object (stored in ai.helper)
|
|
||||||
// and the multiple dragDropTypes (ai.ddTypes)
|
|
||||||
_callback.call(_context, false, ai);
|
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
ddTypes: ai.ddTypes,
|
ddTypes: ai.ddTypes,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user