mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-28 16:59:36 +01:00
Implement set_value() on file widget - you can't really set file upload values programmatically to anything that makes sense, but it can be cleared
This commit is contained in:
parent
bd6c23298b
commit
fc727570dd
@ -186,6 +186,36 @@ var et2_file = et2_inputWidget.extend(
|
|||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* You can't actually set value, but clearing works
|
||||||
|
*/
|
||||||
|
set_value: function(value) {
|
||||||
|
if(!value || typeof value == "undefined")
|
||||||
|
{
|
||||||
|
value = {};
|
||||||
|
}
|
||||||
|
if(jQuery.isEmptyObject(value))
|
||||||
|
{
|
||||||
|
this.options.value = {};
|
||||||
|
this.progress.empty();
|
||||||
|
|
||||||
|
// Reset the HTML element
|
||||||
|
this.input.wrap('<form>').closest('form').get(0).reset();
|
||||||
|
this.input.unwrap();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// This would only look like it worked
|
||||||
|
var i = 0;
|
||||||
|
for(var key in value)
|
||||||
|
{
|
||||||
|
this.createStatus(null,value.name,i++);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
},
|
||||||
|
|
||||||
getInputNode: function() {
|
getInputNode: function() {
|
||||||
return this.input[0];
|
return this.input[0];
|
||||||
},
|
},
|
||||||
@ -356,21 +386,31 @@ console.warn(event,name,error);
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel a file
|
* Remove a file from the list of values
|
||||||
*/
|
*/
|
||||||
cancel: function(e) {
|
remove_file: function(filename)
|
||||||
e.preventDefault();
|
|
||||||
// Look for file name in list
|
|
||||||
var target = $j(e.target).parents("li.message");
|
|
||||||
console.info(target);
|
|
||||||
for(var key in e.data.options.value) {
|
|
||||||
if(e.data.options.value[key].name == target.attr("file"))
|
|
||||||
{
|
{
|
||||||
delete e.data.options.value[key];
|
console.info(filename);
|
||||||
target.remove();
|
for(var key in this.options.value)
|
||||||
|
{
|
||||||
|
if(this.options.value[key].name == filename)
|
||||||
|
{
|
||||||
|
delete this.options.value[key];
|
||||||
|
$j('[file="'+filename+'"]',this.node).remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel a file - event callback
|
||||||
|
*/
|
||||||
|
cancel: function(e)
|
||||||
|
{
|
||||||
|
e.preventDefault();
|
||||||
|
// Look for file name in list
|
||||||
|
var target = $j(e.target).parents("li.message");
|
||||||
|
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();
|
||||||
|
Loading…
Reference in New Issue
Block a user