diff options
| author | wjames5 <will@tekimaki.com> | 2008-09-07 00:24:33 +0000 |
|---|---|---|
| committer | wjames5 <will@tekimaki.com> | 2008-09-07 00:24:33 +0000 |
| commit | 4463647e7a8b282eb1d7558cf04d30ac4266ec84 (patch) | |
| tree | 4009a682e72e7f5f4cc3a2dd635dcfed252e285f /scripts | |
| parent | 3bcf6bb5a029f4ecd83d28d8d2628368781407f5 (diff) | |
| download | liberty-4463647e7a8b282eb1d7558cf04d30ac4266ec84.tar.gz liberty-4463647e7a8b282eb1d7558cf04d30ac4266ec84.tar.bz2 liberty-4463647e7a8b282eb1d7558cf04d30ac4266ec84.zip | |
remove input ids which are unnecessary and can cause collision if multiple forms are loaded to the same page. also replace file input if ajax upload fails so onchange works on subsequent attempts
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/LibertyAttachment.js | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/scripts/LibertyAttachment.js b/scripts/LibertyAttachment.js index 495b989..ed39917 100644 --- a/scripts/LibertyAttachment.js +++ b/scripts/LibertyAttachment.js @@ -7,11 +7,11 @@ LibertyAttachment = { LibertyAttachment.fileInputClones[fileid] = $(fileid).cloneNode(true); }, - "uploader": function(file, action, waitmsg, frmid, cform) { + "uploader": function(file, action, waitmsg, frmid, cformid ) { if (LibertyAttachment.uploader_under_way) { alert(waitmsg); }else{ - if ( LibertyAttachment.preflightCheck( cform ) ){ + if ( LibertyAttachment.preflightCheck( cformid ) ){ LibertyAttachment.uploader_under_way = 1; BitBase.showSpinner(); var old_target = file.form.target; @@ -21,22 +21,28 @@ LibertyAttachment = { file.form.submit(); file.form.target = old_target; file.form.action = old_action; + }else{ + var fileid = file.id; + LibertyAttachment.fileInputClones[fileid].id = fileid; + MochiKit.DOM.swapDOM(file, LibertyAttachment.fileInputClones[fileid]); + LibertyAttachment.uploaderSetup( fileid ); } } }, - "preflightCheck": function( cform ){ - var t = $(cform).title.value; + "preflightCheck": function( cformid ){ + var f = $(cformid); + var t = f.title.value; if ( MochiKit.Base.isEmpty(t) ){ alert( "Please enter a title for your new content before attempting to upload a file." ); return false; }else{ - $('la_title').value = t; + f['liberty_attachments[title]'].value = t; return true; } }, - "uploaderComplete": function(frmid, divid, fileid, cform) { + "uploaderComplete": function(frmid, divid, fileid, cformid) { if (LibertyAttachment.uploader_under_way){ BitBase.hideSpinner(); var ifrm = document.getElementById(frmid); @@ -51,7 +57,7 @@ LibertyAttachment = { return; } - LibertyAttachment.postflightCheck( cform, d ); + LibertyAttachment.postflightCheck( cformid, d ); var errMsg = "<div>Sorry, there was a problem retrieving results.</div>"; var divO = document.getElementById(divid); @@ -74,8 +80,8 @@ LibertyAttachment = { } }, - "postflightCheck": function( cform, d ){ - var form = $(cform); + "postflightCheck": function( cformid, d ){ + var form = $(cformid); var cid = d.getElementById("upload_content_id").value; if ( typeof( form.content_id ) == "undefined" ){ var i = INPUT( {'name':'content_id', 'type':'hidden', 'value':cid}, null ); @@ -83,6 +89,6 @@ LibertyAttachment = { }else{ form.content_id.value = cid; } - $('la_content_id').value = cid; + form['liberty_attachments[content_id]'].value = cid; } } |
