title : file.name,
mimetype : file.type,
preview : false,
+ is_deleted : 0
})
},
closeable : true,
header : !data.mimetype.match(/image/) && !data.preview ? "Document": false,
header_image : data.mimetype.match(/image/) ? data.src : data.preview,
- header_image_fit_square: true,
+ header_image_fit_square: true, // fixme - we probably need to use the 'Img' element to do stuff like this.
data : data,
html : false,
}
);
// dont' really need ot update items.
- //this.items.push(cn);
+ // this.items.push(cn);
this.fileCollection.add(cn);
+ this.updateInput();
},
removeCard : function(id)
{
var card = this.fileCollection.get(id);
+ card.data.is_deleted = 1;
+ card.data.src = ''; /// delete the source - so it reduces size of not uploaded images etc.
this.fileCollection.remove(card);
//this.items = this.items.filter(function(e) { return e != card });
// dont' really need ot update items.
card.el.dom.parentNode.removeChild(card.el.dom);
},
+ reset: function()
+ {
+ this.fileCollection.each(function(card) {
+ card.el.dom.parentNode.removeChild(card.el.dom);
+ });
+ this.fileCollection.clear();
+ this.updateInput();
+ },
+
updateInput : function()
{
- this.fileCo
+ var data = [];
+ this.fileCollection.each(function(e) {
+ data.push(e.data);
+ });
+
+ this.inputEl().dom.value = JSON.stringify(data);
}