source: [view]
dojo.provide("dojox.form.uploader.Base");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.declare("dojox.form.uploader.Base", [dijit._Widget, dijit._Templated], {
//
// Version: 1.6
//
// summary:
// The Base class used for dojox.form.Uploader and dojox.form.uploader.FileList.
//
// description:
// Should not be used as a standalone. To be mixed in with other classes.
//
getForm: function(){
// summary:
// Finds the parent form of the Uploader, if it exists.
//
if(!this.form){
var n = this.domNode;
while(n && n.tagName && n !== document.body){
if(n.tagName.toLowerCase() == "form"){
this.form = n;
break;
}
n = n.parentNode;
}
}
return this.form // Node;
},
getUrl: function(){
// summary:
// Finds the URL to upload to, whether it be the action in the parent form, this.url or
// this.uploadUrl
//
if(this.uploadUrl) this.url = this.uploadUrl;
if(this.url) return this.url;
if(this.getForm()) this.url = this.form.action;
return this.url; // String
},
connectForm: function(){
//console.log("connectForm...", this.url, !!this.uploadUrl, !!this.getForm())
this.url = this.getUrl();
if(!this._fcon && !!this.getForm()){
this._fcon = true;
this.connect(this.form, "onsubmit", function(evt){
dojo.stopEvent(evt);
this.submit(dojo.formToObject(this.form));
});
//console.log("----------------form connected:", this.url)
}
//console.log("form:", this.form, this.url);