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.
15 * @cfg {Boolean} multiple (default true) Should the upload allow multiple files to be uploaded.
18 * Create a new CardUploader
19 * @param {Object} config The config object
22 Roo.bootstrap.ButtonUploader = function(config){
26 Roo.bootstrap.ButtonUploader.superclass.constructor.call(this, config);
33 * When button is pressed, before show upload files dialog is shown
34 * @param {Roo.bootstrap.UploaderButton} this
37 'beforeselect' : true,
39 * @event fired when files have been selected,
40 * When a the download link is clicked
41 * @param {Roo.bootstrap.UploaderButton} this
42 * @param {Array} Array of files that have been uploaded
49 Roo.extend(Roo.bootstrap.ButtonUploader, Roo.bootstrap.Button, {
56 fileCollection : false,
59 getAutoCreate : function()
65 cls : 'd-none roo-card-upload-selector'
69 im.multiple = 'multiple';
75 Roo.bootstrap.Button.prototype.getAutoCreate.call(this),
85 initEvents : function()
88 Roo.bootstrap.Button.prototype.initEvents.call(this);
94 this.urlAPI = (window.createObjectURL && window) ||
95 (window.URL && URL.revokeObjectURL && URL) ||
96 (window.webkitURL && webkitURL);
101 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
103 this.selectorEl.on('change', this.onFileSelected, this);
110 onClick : function(e)
114 if ( this.fireEvent('beforeselect', this) === false) {
118 this.selectorEl.dom.click();
122 onFileSelected : function(e)
126 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
129 var files = Array.prototype.slice.call(this.selectorEl.dom.files);
130 this.selectorEl.dom.reset();
132 this.fireEvent('uploaded', this, files );
140 * addCard - add an Attachment to the uploader
141 * @param data - the data about the image to upload
145 title : "Title of file",
147 src : "http://.....",
148 srcfile : { the File upload object },
149 mimetype : file.type,