1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Roo.namespace('Pman.Dialog');
12 show : function(data, cb)
20 this.dialog.show(this.data._el);
23 this.form.setValues(data);
24 this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });
32 this.dialog = Roo.factory({
35 xtype : 'LayoutRegion',
42 title : "Upload an Image or File",
43 xtype : 'LayoutDialog',
44 uploadComplete : false,
51 uploadProgress : function()
54 if (!dlg.haveProgress) {
55 Roo.MessageBox.progress("Uploading", "Uploading");
58 if (dlg.haveProgress == 2) {
59 // it's been closed elsewhere..
62 if (dlg.uploadComplete) {
63 Roo.MessageBox.hide();
69 var uid = _this.form.findField('UPLOAD_IDENTIFIER').getValue();
71 url : baseURL + '/Core/UploadProgress.php',
76 success : function(res){
79 if (dlg.haveProgress == 2) {
80 // it's been closed elsewhere..
84 if (dlg.uploadComplete) {
85 Roo.MessageBox.hide();
90 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
91 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
94 Roo.MessageBox.updateProgress(1,
95 "Upload Complete - processing"
99 dlg.uploadProgress.defer(2000,dlg);
101 failure: function(data) {
102 // console.log('fail');
103 // console.log(data);
115 click : function (_self, e)
127 click : function (_self, e)
131 //_this.dialog.el.mask("Sending");
132 _this.dialog.uploadComplete = false;
133 _this.form.doAction('submit', {
138 _this.dialog.haveProgress = 0; // set to show..
139 _this.dialog.uploadProgress.defer(1000, _this.dialog);
146 show : function (_self)
149 // this does not really work - escape on the borders works..
150 // resize to fit.. if we have styled stuff...
157 var pad = d.el.getSize().height - (d.header.getSize().height +
158 d.footer.getSize().height +
159 d.layout.getRegion('center').getPanel(0).el.getSize().height
164 d.header.getSize().height +
165 d.footer.getSize().height +
166 d.layout.getRegion('center').getPanel(0).el.child('div').getSize().height
168 this.resizeTo(d.el.getSize().width, height);
170 if (this.keylistener) {
173 this.keylistener = this.addKeyListener(27, this.hide, this);
182 xtype : 'ContentPanel',
187 url : baseURL + '/Roo/Images.php',
190 style : 'margin:10px;',
196 actionfailed : function (_self, act)
200 _this.dialog.uploadComplete = true;
201 // _this.dialog.el.unmask();
203 _this.dialog.haveProgress = 2;
204 if (act.type == 'submit') {
205 Roo.log("Upload error");
209 Roo.MessageBox.alert("Error", act.result.errorMsg.split(/\n/).join('<BR/>'));
212 Roo.MessageBox.alert("Error", "Saving failed = fix errors and try again");
217 // what about load failing..
218 Roo.MessageBox.alert("Error", "Error loading details");
220 actioncomplete : function(_self,act)
222 _this.dialog.uploadComplete = true;
223 _this.dialog.haveProgress = 2;
224 Roo.MessageBox.hide(); // force hiding
225 //_this.dialog.el.unmask();
227 if (act.type == 'setdata') {
228 this.url = _this.data._url ? _this.data._url : baseURL + '/Roo/Images.php';
229 this.el.dom.action = this.url;
230 if (typeof(_this.data.timeout) != 'undefined') {
231 this.timeout = _this.data.timeout;
234 this.findField('UPLOAD_IDENTIFIER').setValue(
235 (new Date() * 1) + '' + Math.random());
241 if (act.type == 'load') {
242 // should this happen?
243 _this.data = act.result.data;
249 if (act.type == 'submit') { // only submitted here if we are
251 Roo.log("Upload success");
254 if (_this.callback) {
255 _this.callback.call(this, act.result.data, act.result.extra);
263 rendered : function (form)
273 name : 'UPLOAD_IDENTIFIER'
280 name : 'post_max_size'
287 name : 'upload_max_filesize'
292 fieldLabel : 'Upload Image or File',