1 //<script type="text/javascript">
13 this.dialog = new Ext.LayoutDialog(Ext.get(document.body).createChild({tag:'div'}), {
15 title: "Upload Image or File",
28 // tabPosition: 'top',
34 this.dialog.addKeyListener(27, this.dialog.hide, this.dialog);
35 this.dialog.addButton("Cancel", this.dialog.hide, this.dialog);
37 this.dialog.addButton("Save", this.save, this);
38 this.layout = this.dialog.getLayout();
39 this.layout.beginUpdate();
42 this.form = new Ext.form.Form({
46 actionfailed : function(f, act) {
47 _this.uploadComplete = true;
48 _this.dialog.el.unmask();
51 if (act.type == 'submit') {
52 Ext.MessageBox.alert("Error", "Saving failed = fix errors and try again");
56 // what about load failing..
57 Ext.MessageBox.alert("Error", "Error loading details");
60 actioncomplete: function(f, act) {
61 _this.uploadComplete = true;
62 _this.dialog.el.unmask();
65 if (act.type == 'load') {
67 _this.data = act.result.data;
73 if (act.type == 'submit') { // only submitted here if we are
77 _this.callback.call(this, act.result.data);
89 //?? will this work...
90 this.form.addxtype.apply(this.form,
93 { name: 'UPLOAD_IDENTIFIER' , xtype: 'Hidden' },
97 fieldLabel : "Upload Image or File",
100 { name: 'ontable', xtype: 'Hidden' },
101 { name: 'onid', xtype: 'Hidden' },
102 { name: 'imgtype', xtype: 'Hidden' }, // special value for sorting!!
103 { name: 'post_max_size', xtype: 'Hidden' , value :'32M'} ,
104 { name: 'upload_max_filesize', xtype: 'Hidden' , value :'32M'}
111 var ef = this.dialog.getLayout().getEl().createChild({tag: 'div'});
112 ef.dom.style.margin = 10;
114 this.form.render(ef.dom);
116 var vp = this.dialog.getLayout().add('center', new Ext.ContentPanel(ef, {
118 //title: 'Org Details',
128 this.layout.endUpdate();
132 show: function (data, callback)
135 this.callback = callback;
139 this.form.setValues(data);
140 this.form.findField('UPLOAD_IDENTIFIER').setValue((new Date() * 1) + '' + Math.random());
148 this.dialog.el.mask("Sending");
149 this.uploadComplete = false;
150 this.form.doAction('submit', {
151 url: baseURL + '/Roo/Images.html',
158 this.haveProgress = false,
159 this.uploadProgress.defer(1000, this);
162 uploadComplete : false,
164 uploadProgress : function()
166 if (!this.haveProgress) {
167 Roo.MessageBox.progress("Uploading", "Uploading");
169 if (this.uploadComplete) {
170 Roo.MessageBox.hide();
173 this.haveProgress = true;
175 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
177 url : baseURL + '/Core/UploadProgress.php',
182 success : function(data){
184 if (_this.uploadComplete) {
185 Roo.MessageBox.hide();
190 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
191 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
194 _this.uploadProgress.defer(2000, _this);
196 failure: function(data) {
197 // console.log('fail');
198 // console.log(data);