1 //<script type="text/javascript">
14 this.dialog = new Ext.LayoutDialog(Ext.get(document.body).createChild({tag:'div'}), {
16 title: "Upload Image or File",
29 // tabPosition: 'top',
35 this.dialog.addKeyListener(27, this.dialog.hide, this.dialog);
36 this.dialog.addButton("Cancel", this.dialog.hide, this.dialog);
38 this.dialog.addButton("Save", this.save, this);
39 this.layout = this.dialog.getLayout();
40 this.layout.beginUpdate();
43 this.form = new Ext.form.Form({
47 actionfailed : function(f, act) {
48 _this.uploadComplete = true;
49 _this.dialog.el.unmask();
52 if (act.type == 'submit') {
53 Ext.MessageBox.alert("Error", "Saving failed = fix errors and try again");
57 // what about load failing..
58 Ext.MessageBox.alert("Error", "Error loading details");
61 actioncomplete: function(f, act) {
62 _this.uploadComplete = true;
63 _this.dialog.el.unmask();
66 if (act.type == 'load') {
68 _this.data = act.result.data;
74 if (act.type == 'submit') { // only submitted here if we are
78 _this.callback.call(this, act.result.data);
90 //?? will this work...
91 this.form.addxtype.apply(this.form,
94 { name: 'UPLOAD_IDENTIFIER' , xtype: 'Hidden' },
98 fieldLabel : "Upload Image or File",
101 { name: 'ontable', xtype: 'Hidden' },
102 { name: 'onid', xtype: 'Hidden' },
103 { name: 'imgtype', xtype: 'Hidden' }, // special value for sorting!!
104 { name: 'post_max_size', xtype: 'Hidden' , value :'32M'} ,
105 { name: 'upload_max_filesize', xtype: 'Hidden' , value :'32M'}
112 var ef = this.dialog.getLayout().getEl().createChild({tag: 'div'});
113 ef.dom.style.margin = 10;
115 this.form.render(ef.dom);
117 var vp = this.dialog.getLayout().add('center', new Ext.ContentPanel(ef, {
119 //title: 'Org Details',
129 this.layout.endUpdate();
133 show: function (data, callback)
136 this.callback = callback;
140 this.form.setValues(data);
141 this.form.findField('UPLOAD_IDENTIFIER').setValue((new Date() * 1) + '' + Math.random());
149 this.dialog.el.mask("Sending");
150 this.uploadComplete = false;
151 this.form.doAction('submit', {
152 url: baseURL + '/Roo/Images.html',
159 this.haveProgress = false,
160 this.uploadProgress.defer(1000, this);
163 uploadComplete : false,
165 uploadProgress : function()
167 if (!this.haveProgress) {
168 Roo.MessageBox.progress("Uploading", "Uploading");
170 if (this.uploadComplete) {
171 Roo.MessageBox.hide();
174 this.haveProgress = true;
176 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
178 url : baseURL + '/Core/UploadProgress.php',
183 success : function(data){
185 if (_this.uploadComplete) {
186 Roo.MessageBox.hide();
191 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
192 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
195 _this.uploadProgress.defer(2000, _this);
197 failure: function(data) {
198 // console.log('fail');
199 // console.log(data);