mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:07 +01:00
Drag files from desktop anywhere onto filemanager uploads
This commit is contained in:
parent
b74eec3d3f
commit
6fdeb9f5f8
@ -113,7 +113,7 @@ var et2_file = et2_inputWidget.extend(
|
|||||||
return self.onStart(event, file_count);
|
return self.onStart(event, file_count);
|
||||||
},
|
},
|
||||||
onFinish: function(event, file_count) {
|
onFinish: function(event, file_count) {
|
||||||
self.onFinish(event, file_count);
|
self.onFinish.apply(self, [event, file_count]);
|
||||||
|
|
||||||
// Fire legacy change action when done
|
// Fire legacy change action when done
|
||||||
self.change(self.input);
|
self.change(self.input);
|
||||||
@ -209,18 +209,38 @@ var et2_file = et2_inputWidget.extend(
|
|||||||
};
|
};
|
||||||
$j(drop_target)
|
$j(drop_target)
|
||||||
.on("drop", jQuery.proxy(function(event) {
|
.on("drop", jQuery.proxy(function(event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
this.input.removeClass("ui-state-active");
|
||||||
if(event.dataTransfer && event.dataTransfer.files.length > 0)
|
if(event.dataTransfer && event.dataTransfer.files.length > 0)
|
||||||
{
|
{
|
||||||
this.input[0].files = event.dataTransfer.files;
|
this.input[0].files = event.dataTransfer.files;
|
||||||
this.input.trigger("start.html5_upload");
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}, this))
|
}, this))
|
||||||
.on("dragenter",function(e) {
|
.on("dragenter",function(e) {
|
||||||
return !self.disabled;
|
// Accept the drop if at least one mimetype matches
|
||||||
//self.checkMime(this.files[index]))
|
// Individual files will be rejected later
|
||||||
|
var mime_ok = false;
|
||||||
|
for(var file in e.dataTransfer.files)
|
||||||
|
{
|
||||||
|
mime_ok = mime_ok || self.checkMime(file);
|
||||||
|
}
|
||||||
|
if(!self.disabled && mime_ok)
|
||||||
|
{
|
||||||
|
self.input.addClass("ui-state-active");
|
||||||
|
}
|
||||||
|
// Returning true cancels, return false to allow
|
||||||
|
return self.disabled || !mime_ok;
|
||||||
|
})
|
||||||
|
.on("dragleave", function(e) {
|
||||||
|
self.input.removeClass("ui-state-active");
|
||||||
|
// Returning true cancels, return false to allow
|
||||||
|
return self.disabled
|
||||||
})
|
})
|
||||||
.on("dragover", function(e) {
|
.on("dragover", function(e) {
|
||||||
return !self.disabled;
|
// Returning true cancels, return false to allow
|
||||||
|
return self.disabled;
|
||||||
})
|
})
|
||||||
.on("dragend", false);
|
.on("dragend", false);
|
||||||
}
|
}
|
||||||
@ -381,7 +401,7 @@ var et2_file = et2_inputWidget.extend(
|
|||||||
$j("div.remove",status).click(this, this.cancel);
|
$j("div.remove",status).click(this, this.cancel);
|
||||||
if(error != "")
|
if(error != "")
|
||||||
{
|
{
|
||||||
status.addClass("message validation_error");
|
status.addClass("message ui-state-error");
|
||||||
status.append("<div>"+error+"</diff>");
|
status.append("<div>"+error+"</diff>");
|
||||||
$j(".progressBar",status).css("display", "none");
|
$j(".progressBar",status).css("display", "none");
|
||||||
}
|
}
|
||||||
@ -431,7 +451,7 @@ console.warn(event,name,error);
|
|||||||
else if (this.progress)
|
else if (this.progress)
|
||||||
{
|
{
|
||||||
$j("[file='"+name+"']",this.progress)
|
$j("[file='"+name+"']",this.progress)
|
||||||
.addClass("error")
|
.addClass("ui-state-error")
|
||||||
.css("display", "block")
|
.css("display", "block")
|
||||||
.text(this.egw().lang("Server error"));
|
.text(this.egw().lang("Server error"));
|
||||||
}
|
}
|
||||||
@ -467,7 +487,7 @@ console.info(filename);
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// Look for file name in list
|
// Look for file name in list
|
||||||
var target = $j(e.target).parents("li.message");
|
var target = $j(e.target).parents("li.message");
|
||||||
e.data.remove_file.apply(e.data,target.attr("file"));
|
e.data.remove_file.apply(e.data,[target.attr("file")]);
|
||||||
// In case it didn't make it to the list (error)
|
// In case it didn't make it to the list (error)
|
||||||
target.remove();
|
target.remove();
|
||||||
$j(e.target).remove();
|
$j(e.target).remove();
|
||||||
|
@ -452,7 +452,6 @@ action buttons, left aligned for "extra" controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
.et2_file .progress li {
|
.et2_file .progress li {
|
||||||
color: blue;
|
|
||||||
margin: .5ex;
|
margin: .5ex;
|
||||||
}
|
}
|
||||||
/* Hide progress bar when completed */
|
/* Hide progress bar when completed */
|
||||||
|
@ -183,11 +183,10 @@ app.filemanager = AppJS.extend(
|
|||||||
*/
|
*/
|
||||||
upload: function(_event, _file_count)
|
upload: function(_event, _file_count)
|
||||||
{
|
{
|
||||||
if (_file_count)
|
if (_file_count && !jQuery.isEmptyObject(_event.data.getValue()))
|
||||||
{
|
{
|
||||||
var widget = _event.data;
|
var widget = _event.data;
|
||||||
var request = new egw_json_request('filemanager_ui::ajax_action', ['upload', widget.getValue(), this.get_path()], this);
|
var request = new egw_json_request('filemanager_ui::ajax_action', ['upload', widget.getValue(), this.get_path()], this);
|
||||||
widget.progress.remove();
|
|
||||||
widget.set_value('');
|
widget.set_value('');
|
||||||
request.sendRequest(false, this._upload_callback, this);
|
request.sendRequest(false, this._upload_callback, this);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
<buttononly id="button[linkpaste]" onclick="app.filemanager.paste('linkpaste');" options="linkpaste,linkpaste_disabled"/>
|
<buttononly id="button[linkpaste]" onclick="app.filemanager.paste('linkpaste');" options="linkpaste,linkpaste_disabled"/>
|
||||||
<buttononly id="button[mailpaste]" onclick="app.filemanager.paste('mailpaste');" options="mailpaste,mailpaste_disabled"/>
|
<buttononly id="button[mailpaste]" onclick="app.filemanager.paste('mailpaste');" options="mailpaste,mailpaste_disabled"/>
|
||||||
<button label="File a file" onclick="window.open(egw::link('/index.php','menuaction=stylite.stylite_filemanager.upload'),'_blank','dependent=yes,width=550,height=350,scrollbars=yes,status=yes'); return false;" image="upload"/>
|
<button label="File a file" onclick="window.open(egw::link('/index.php','menuaction=stylite.stylite_filemanager.upload'),'_blank','dependent=yes,width=550,height=350,scrollbars=yes,status=yes'); return false;" image="upload"/>
|
||||||
<file statustext="Select file to upload in current directory" id="upload"/>
|
<file statustext="Select file to upload in current directory" id="upload" drop_target ="divAppbox"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
</template>
|
</template>
|
||||||
<template id="filemanager.index" template="" lang="" group="0" version="1.9.003">
|
<template id="filemanager.index" template="" lang="" group="0" version="1.9.003">
|
||||||
|
Loading…
Reference in New Issue
Block a user