Created
February 11, 2010 21:03
-
-
Save apipkin/301952 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI.add('echofin-modal-upload',function(Y){ | |
var ioUpload = Y.clone(BASE_IO), | |
ul = Y.one(this.FORM_CONTAINER + ' ul'); | |
; | |
ioUpload.method = 'POST'; | |
ioUpload.url = BASE_URL + 'properties/property-pdfs/uploadImage/'; | |
Y.Echofin.Modal.Upload = { | |
FORM_CONTAINER : '#uploadImage', | |
_uploadInitialize : function(e) { | |
if(!ul) { | |
Y.one(this.FORM_CONTAINER).append('<ul>'); | |
ul = Y.one(this.FORM_CONTAINER + ' ul'); | |
} | |
Y.log('upload init'); | |
e.preventDefault(); | |
var io = Y.clone(ioUpload); | |
io.on.start = Y.bind(this._uploadStart,this); | |
io.on.complete = Y.bind(this._uploadComplete,this); | |
io.arguments = {'name' : Y.one(this.FORM_CONTAINER + ' input[type=file]').get('value') }; | |
Y.io(io.url,io); | |
}, | |
_uploadStart : function(id,args) { | |
Y.log('upload start'); | |
if(Y.all(this.FORM_CONTAINER + ' li.upload-complete').size() > 2) { | |
Y.one(this.FORM_CONTAINER + ' li.upload-complete').remove(true); | |
} | |
ul.append('<li class="upload-loading" id="image-upload-' + id + '>' + args.name + '</li>') | |
}, | |
_uploadComplete : function(id,o,args) { | |
Y.log('upload Complete'); | |
Y.log('id : ' + id); | |
ul.one('#image-upload-' + id).replaceClass('upload-loading','upload-complete'); | |
}, | |
_domready : function() { | |
Y.log('upload domready'); | |
ioUpload.form = { | |
id:'uploadImage-form', | |
upload:true | |
}; | |
Y.delegate('submit',this._uploadInitialize,'div.echofin-modal-async','form',this); | |
} | |
}; | |
Y.on('domready',Y.bind(Y.Echofin.Modal.Upload._domready,Y.Echofin.Modal.Upload)); | |
},'0.1',{requires:['echofin-modal','io-upload-iframe']}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment