3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Imgorg.UploadQueue = Ext.extend(Ext.Panel,{
13 initComponent: function() {
21 tpl: new Ext.XTemplate(
23 '<div class="upload-file" id="{id}">',
24 '<div class="upload-name">{name}</div>',
25 '<div id="{id}-pb" class="upload-pb"></div>',
26 '<div class="x-clear"></div>',
27 '<div class="upload-info">{size:fileSize}</div>',
31 store: new Ext.data.JsonStore({
35 {name: 'creationdate', type: 'date'},
36 {name: 'modificationdate', type: 'date'},
37 'filestatus','id','index','name','size','type','dbid'
40 itemSelector: 'div.upload-file',
41 selectedClass: 'upload-file-selected',
46 handler: this.startUpload,
48 iconCls: 'start-upload'
51 handler: this.cancelUpload,
56 handler: this.addAllAlbum,
67 checked: this.autoRemove,
69 check: function(cb, checked) {
70 this.autoRemove = checked;
74 },'Auto-Remove Uploaded']
76 Imgorg.UploadQueue.superclass.initComponent.call(this);
78 this.progressBars = {};
80 Ext.ux.SwfuMgr.on('filequeued', this.addFile, this);
81 Ext.ux.SwfuMgr.on('uploadprogress', this.updateProgress, this);
82 Ext.ux.SwfuMgr.on('uploadsuccess', this.uploadSuccess, this);
87 this.imgUplDv = this.getComponent('img-uploaddv');
92 startUpload: function() {
93 this.swfu.startUpload();
96 cancelUpload: function() {
97 this.swfu.cancelUpload();
98 for (var pb in this.progressBars) {
99 this.progressBars[pb].destroy();
101 this.getDv().store.removeAll();
102 this.uploaded = false;
105 addFile: function(swfu, file) {
106 this.getDv().store.loadData([file], true);
109 addAllAlbum: function(btn) {
110 if (!this.uploaded) {
111 Ext.Msg.alert('Warning', 'You must upload files before you can add them to an Album');
114 var dv = this.getDv();
115 var recs = dv.getRecords(dv.getNodes());
116 if (!this.albumWin) {
117 this.albumWin = new Imgorg.AlbumWin();
119 this.albumWin.selectedRecords = recs;
120 this.albumWin.show(btn.btnEl.dom);
123 tagAll: function(btn) {
124 if (!this.uploaded) {
125 Ext.Msg.alert('Warning', 'You must upload files before you can Tag them');
128 var dv = this.getDv();
129 var recs = dv.getRecords(dv.getNodes());
130 Imgorg.TagWin.selectedRecords = recs;
131 Imgorg.TagWin.show(btn.btnEl.dom);
134 updateProgress: function(swfu, file, complete, total) {
135 if (this.progressBars[file.id]) {
136 this.progressBars[file.id].updateProgress(file.percentUploaded/100,Math.round(file.percentUploaded)+'% Completed... '+Ext.util.Format.fileSize(file.currentSpeed)+'s');
138 this.progressBars[file.id] = new Ext.ProgressBar({
139 text:'0% Completed...',
140 renderTo: file.id+'-pb'
145 uploadSuccess: function(swfu, file, data) {
146 var store = this.getDv().store;
147 var rec = store.getById(file.id);
148 if (this.progressBars[file.id]) {
149 this.progressBars[file.id].updateProgress(1, '100% Completed...');
151 if (this.autoRemove) {
154 var data = Ext.decode(Ext.util.Format.stripTags(data));
155 rec.data.dbid = data.result.res.id;
156 this.uploaded = true;
159 Ext.reg('img-uploadqueue', Imgorg.UploadQueue);
161 Ext.ux.SwfuManager = Ext.extend(Ext.util.Observable, {
162 constructor: function(config) {
163 Ext.ux.SwfuManager.superclass.constructor.call(this, config);
174 Ext.ux.SwfuMgr = new Ext.ux.SwfuManager();