3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
7 Imgorg.UploadQueue = Ext.extend(Ext.Panel,{
12 initComponent: function() {
20 tpl: new Ext.XTemplate(
22 '<div class="upload-file" id="{id}">',
23 '<div class="upload-name">{name}</div>',
24 '<div id="{id}-pb" class="upload-pb"></div>',
25 '<div class="x-clear"></div>',
26 '<div class="upload-info">{size:fileSize}</div>',
30 store: new Ext.data.JsonStore({
34 {name: 'creationdate', type: 'date'},
35 {name: 'modificationdate', type: 'date'},
36 'filestatus','id','index','name','size','type','dbid'
39 itemSelector: 'div.upload-file',
40 selectedClass: 'upload-file-selected',
45 handler: this.startUpload,
47 iconCls: 'start-upload'
50 handler: this.cancelUpload,
55 handler: this.addAllAlbum,
66 checked: this.autoRemove,
68 check: function(cb, checked) {
69 this.autoRemove = checked;
73 },'Auto-Remove Uploaded']
75 Imgorg.UploadQueue.superclass.initComponent.call(this);
77 this.progressBars = {};
79 Ext.ux.SwfuMgr.on('filequeued', this.addFile, this);
80 Ext.ux.SwfuMgr.on('uploadprogress', this.updateProgress, this);
81 Ext.ux.SwfuMgr.on('uploadsuccess', this.uploadSuccess, this);
86 this.imgUplDv = this.getComponent('img-uploaddv');
91 startUpload: function() {
92 this.swfu.startUpload();
95 cancelUpload: function() {
96 this.swfu.cancelUpload();
97 for (var pb in this.progressBars) {
98 this.progressBars[pb].destroy();
100 this.getDv().store.removeAll();
101 this.uploaded = false;
104 addFile: function(swfu, file) {
105 this.getDv().store.loadData([file], true);
108 addAllAlbum: function(btn) {
109 if (!this.uploaded) {
110 Ext.Msg.alert('Warning', 'You must upload files before you can add them to an Album');
113 var dv = this.getDv();
114 var recs = dv.getRecords(dv.getNodes());
115 if (!this.albumWin) {
116 this.albumWin = new Imgorg.AlbumWin();
118 this.albumWin.selectedRecords = recs;
119 this.albumWin.show(btn.btnEl.dom);
122 tagAll: function(btn) {
123 if (!this.uploaded) {
124 Ext.Msg.alert('Warning', 'You must upload files before you can Tag them');
127 var dv = this.getDv();
128 var recs = dv.getRecords(dv.getNodes());
129 Imgorg.TagWin.selectedRecords = recs;
130 Imgorg.TagWin.show(btn.btnEl.dom);
133 updateProgress: function(swfu, file, complete, total) {
134 if (this.progressBars[file.id]) {
135 this.progressBars[file.id].updateProgress(file.percentUploaded/100,Math.round(file.percentUploaded)+'% Completed... '+Ext.util.Format.fileSize(file.currentSpeed)+'s');
137 this.progressBars[file.id] = new Ext.ProgressBar({
138 text:'0% Completed...',
139 renderTo: file.id+'-pb'
144 uploadSuccess: function(swfu, file, data) {
145 var store = this.getDv().store;
146 var rec = store.getById(file.id);
147 if (this.progressBars[file.id]) {
148 this.progressBars[file.id].updateProgress(1, '100% Completed...');
150 if (this.autoRemove) {
153 var data = Ext.decode(Ext.util.Format.stripTags(data));
154 rec.data.dbid = data.result.res.id;
155 this.uploaded = true;
158 Ext.reg('img-uploadqueue', Imgorg.UploadQueue);
160 Ext.ux.SwfuManager = Ext.extend(Ext.util.Observable, {
161 constructor: function(config) {
162 Ext.ux.SwfuManager.superclass.constructor.call(this, config);
173 Ext.ux.SwfuMgr = new Ext.ux.SwfuManager();