1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
10 show : function(data, cb)
18 this.dialog.show(this.data._el);
21 this.form.setValues(data);
22 this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });
30 this.dialog = Roo.factory({
31 xtype: 'LayoutDialog',
34 show : function (_self)
36 // this does not really work - escape on the borders works..
37 if (this.keylistener) {
40 this.keylistener = this.addKeyListener(27, this.hide, this);
50 title : "Upload an Image or File",
51 uploadComplete : false,
54 uploadProgress : function()
57 if (!dlg.haveProgress) {
58 Roo.MessageBox.progress("Uploading", "Uploading");
61 if (dlg.haveProgress == 2) {
62 // it's been closed elsewhere..
65 if (dlg.uploadComplete) {
66 Roo.MessageBox.hide();
72 var uid = _this.form.findField('UPLOAD_IDENTIFIER').getValue();
74 url : baseURL + '/Core/UploadProgress.php',
79 success : function(data){
82 if (dlg.haveProgress == 2) {
83 // it's been closed elsewhere..
87 if (dlg.uploadComplete) {
88 Roo.MessageBox.hide();
93 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
94 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
97 dlg.uploadProgress.defer(2000,dlg);
99 failure: function(data) {
100 // console.log('fail');
101 // console.log(data);
108 xtype: 'ContentPanel',
117 actioncomplete : function(_self,act)
119 _this.dialog.uploadComplete = true;
120 _this.dialog.haveProgress = 2;
121 Roo.MessageBox.hide(); // force hiding
122 _this.dialog.el.unmask();
124 if (act.type == 'setdata') {
125 this.url = _this.data._url ? _this.data._url : baseURL + '/Roo/Images.php';
126 this.el.dom.action = this.url;
127 this.findField('UPLOAD_IDENTIFIER').setValue(
128 (new Date() * 1) + '' + Math.random());
134 if (act.type == 'load') {
135 // should this happen?
136 _this.data = act.result.data;
142 if (act.type == 'submit') { // only submitted here if we are
144 Roo.log("Upload success");
147 if (_this.callback) {
148 _this.callback.call(this, act.result.data);
153 rendered : function (form)
157 actionfailed : function (_self, act)
159 _this.dialog.uploadComplete = true;
160 _this.dialog.el.unmask();
162 _this.dialog.haveProgress = 2;
163 if (act.type == 'submit') {
164 Roo.log("Upload error");
167 Roo.MessageBox.alert("Error", act.result.errorMsg);
170 Roo.MessageBox.alert("Error", "Saving failed = fix errors and try again");
175 // what about load failing..
176 Roo.MessageBox.alert("Error", "Error loading details");
182 style : 'margin:10px;',
183 url : baseURL + '/Roo/Images.php',
188 name : 'UPLOAD_IDENTIFIER'
193 name : 'post_max_size',
199 name : 'upload_max_filesize',
205 fieldLabel : 'Upload Image or File',
207 name : 'imageUpload',
236 xtype: 'LayoutRegion',
244 click : function (_self, e)
255 click : function (_self, e)
259 _this.dialog.el.mask("Sending");
260 _this.dialog.uploadComplete = false;
261 _this.form.doAction('submit', {
266 _this.dialog.haveProgress = 0; // set to show..
267 _this.dialog.uploadProgress.defer(1000, _this.dialog);