7 * @class Roo.bootstrap.ButtonUploader
8 * @extends Roo.bootstrap.Button
9 * Bootstrap Button Uploader class - it's a button which when you add files to it
12 * @cfg {Number} errorTimeout default 3000
13 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
14 * @cfg {Array} html The button text.
18 * Create a new CardUploader
19 * @param {Object} config The config object
22 Roo.bootstrap.ButtonUploader = function(config){
26 Roo.bootstrap.CardUploader.superclass.constructor.call(this, config);
29 this.fileCollection = new Roo.util.MixedCollection(false,function(r) {
37 * When button is pressed, before show upload files dialog is shown
38 * @param {Roo.bootstrap.UploaderButton} this
41 'beforeselect' : true,
43 * @event fired when files have been selected,
44 * When a the download link is clicked
45 * @param {Roo.bootstrap.Card} this
46 * @param {Object} The image information data contains
53 Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Button, {
60 fileCollection : false,
63 getAutoCreate : function()
70 Roo.bootstrap.Button.prototype.getAutoCreate(),
73 multiple : 'multiple',
75 cls : 'd-none roo-card-upload-selector'
87 initEvents : function()
90 Roo.bootstrap.Button.prototype.initEvents.call(this);
96 this.urlAPI = (window.createObjectURL && window) ||
97 (window.URL && URL.revokeObjectURL && URL) ||
98 (window.webkitURL && webkitURL);
103 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
105 this.selectorEl.on('change', this.onFileSelected, this);
112 onClick : function(e)
116 if ( this.fireEvent('beforeselect', this) === false) {
120 this.selectorEl.dom.click();
124 onFileSelected : function(e)
128 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
132 Roo.each(this.selectorEl.dom.files, function(file){
133 this.fireEvent('uploaded', this, [file]);
142 addFile : function(file)
145 if(typeof(file) === 'string'){
146 throw "Add file by name?"; // should not happen
150 if(!file || !this.urlAPI){
160 var url = _this.urlAPI.createObjectURL( file);
166 * addCard - add an Attachment to the uploader
167 * @param data - the data about the image to upload
171 title : "Title of file",
173 src : "http://.....",
174 srcfile : { the File upload object },
175 mimetype : file.type,