| 1 |
lars |
1 |
Prado.WebUI.TActiveFileUpload = Base.extend(
|
|
|
2 |
{
|
|
|
3 |
constructor : function(options)
|
|
|
4 |
{
|
|
|
5 |
this.options = options || {};
|
|
|
6 |
Prado.WebUI.TActiveFileUpload.register(this);
|
|
|
7 |
|
|
|
8 |
this.input = $(options.inputID);
|
|
|
9 |
this.flag = $(options.flagID);
|
|
|
10 |
this.form = $(options.formID);
|
|
|
11 |
|
|
|
12 |
this.indicator = $(options.indicatorID);
|
|
|
13 |
this.complete = $(options.completeID);
|
|
|
14 |
this.error = $(options.errorID);
|
|
|
15 |
|
|
|
16 |
// set up events
|
|
|
17 |
Event.observe(this.input,"change",this.fileChanged.bind(this));
|
|
|
18 |
},
|
|
|
19 |
|
|
|
20 |
fileChanged:function(){
|
|
|
21 |
// show the upload indicator, and hide the complete and error indicators (if they areSn't already).
|
|
|
22 |
this.flag.value = '1';
|
|
|
23 |
this.complete.style.display = 'none';
|
|
|
24 |
this.error.style.display = 'none';
|
|
|
25 |
this.indicator.style.display = '';
|
|
|
26 |
|
|
|
27 |
// set the form to submit in the iframe, submit it, and then reset it.
|
|
|
28 |
this.oldtargetID = this.form.target;
|
|
|
29 |
this.form.target = this.options.targetID;
|
|
|
30 |
this.form.submit();
|
|
|
31 |
this.form.target = this.oldtargetID;
|
|
|
32 |
},
|
|
|
33 |
|
|
|
34 |
finishUpload:function(options){
|
|
|
35 |
// hide the display indicator.
|
|
|
36 |
this.flag.value = '';
|
|
|
37 |
this.indicator.style.display = 'none';
|
|
|
38 |
if (this.options.targetID == options.targetID){
|
|
|
39 |
// show the complete indicator.
|
|
|
40 |
if (options.errorCode == 0){
|
|
|
41 |
this.complete.style.display = '';
|
|
|
42 |
this.input.value = '';
|
|
|
43 |
} else {
|
|
|
44 |
this.error.style.display = '';
|
|
|
45 |
}
|
|
|
46 |
Prado.Callback(this.options.EventTarget, options, null, this.options);
|
|
|
47 |
}
|
|
|
48 |
}
|
|
|
49 |
},
|
|
|
50 |
{
|
|
|
51 |
// class methods
|
|
|
52 |
controls : {},
|
|
|
53 |
|
|
|
54 |
register : function(control)
|
|
|
55 |
{
|
|
|
56 |
Prado.WebUI.TActiveFileUpload.controls[control.options.ID] = control;
|
|
|
57 |
},
|
|
|
58 |
|
|
|
59 |
onFileUpload: function(options)
|
|
|
60 |
{
|
|
|
61 |
Prado.WebUI.TActiveFileUpload.controls[options.clientID].finishUpload(options);
|
|
|
62 |
}
|
|
|
63 |
});
|