diff options
| -rw-r--r-- | edit_storage_inc.php | 4 | ||||
| -rw-r--r-- | scripts/LibertyAttachment.js | 43 | ||||
| -rw-r--r-- | templates/attachment_uploader.tpl | 8 | ||||
| -rw-r--r-- | templates/attachment_uploader_inc.tpl | 3 |
4 files changed, 33 insertions, 25 deletions
diff --git a/edit_storage_inc.php b/edit_storage_inc.php index 51e9505..6fc41d4 100644 --- a/edit_storage_inc.php +++ b/edit_storage_inc.php @@ -3,7 +3,7 @@ * edit_storage_inc * * @author spider <spider@steelsun.com> - * @version $Revision: 1.29 $ + * @version $Revision: 1.30 $ * @package liberty * @subpackage functions */ @@ -38,7 +38,7 @@ if( !empty( $_REQUEST['deleteAttachment'] )) { // make sure js is being loaded if( $gBitSystem->getConfig( 'liberty_attachment_style' ) == 'ajax' ) { - $gBitThemes->loadAjax( 'mochikit' ); + $gBitThemes->loadAjax( 'mochikit', array( 'DOM.js' ) ); $gBitThemes->loadJavascript( LIBERTY_PKG_PATH.'scripts/LibertyAttachment.js', TRUE ); } ?> diff --git a/scripts/LibertyAttachment.js b/scripts/LibertyAttachment.js index b046022..c3219a4 100644 --- a/scripts/LibertyAttachment.js +++ b/scripts/LibertyAttachment.js @@ -6,18 +6,24 @@ LibertyAttachment = { if (LibertyAttachment.uploader_under_way) { alert(waitmsg); }else{ - LibertyAttachment.uploader_under_way = 1; - BitAjax.showSpinner(); - var old_target = file.form.target; - file.form.target = frmid; - var old_action = file.form.action; - // var action_item = document.getElementById(actionid); - // action_item.value = old_action; - file.form.action=action; - file.form.submit(); - file.form.target = old_target; - file.form.action = old_action; - // action_item.value = ''; + var t = document.forms.editpageform.title.value; + if ( MochiKit.Base.isEmpty(t) ){ + alert( "Please enter a title for your new content before attempting to upload a file." ); + }else{ + $('la_title').value = t; + LibertyAttachment.uploader_under_way = 1; + BitAjax.showSpinner(); + var old_target = file.form.target; + file.form.target = frmid; + var old_action = file.form.action; + // var action_item = document.getElementById(actionid); + // action_item.value = old_action; + file.form.action=action; + file.form.submit(); + file.form.target = old_target; + file.form.action = old_action; + // action_item.value = ''; + } } }, @@ -36,12 +42,15 @@ LibertyAttachment = { return; } - // - for( n=0; n<document.forms.length; n++ ){ - if ( typeof( document.forms[n].content_id != "undefined" ) ){ - document.forms[n].content_id.value = d.getElementById("new_content_id").value; - } + var form = document.forms.editpageform; + 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 ); + form.insertBefore( i, form.firstChild ); + }else{ + form.content_id.value = cid; } + $('la_content_id').value = cid; var errMsg = "<div>Sorry, there was a problem retrieving results.</div>"; var divO = document.getElementById(divid); diff --git a/templates/attachment_uploader.tpl b/templates/attachment_uploader.tpl index 1588729..3d924ae 100644 --- a/templates/attachment_uploader.tpl +++ b/templates/attachment_uploader.tpl @@ -1,7 +1,7 @@ {strip} -{if !empty($errors)} +{if $errors} <script type="text/javascript"> - alert("Error with upload: {$errors}"); + alert("Error with upload: {$errors|addslashes}"); </script> {/if} <div id="result_tab"> @@ -15,7 +15,5 @@ <div id="result_list"> {include file="bitpackage:liberty/edit_storage_list.tpl" uploadTab=0} </div> -{if $gContent->mContentId} - <input type="hidden" name="new_content_id" id="new_content_id" value="{$gContent->mContentId}" /> -{/if} +<input type="hidden" name="upload_content_id" id="upload_content_id" value="{if $gContent->mContentId}{$gContent->mContentId}{/if}" /> {/strip} diff --git a/templates/attachment_uploader_inc.tpl b/templates/attachment_uploader_inc.tpl index 343c177..f520407 100644 --- a/templates/attachment_uploader_inc.tpl +++ b/templates/attachment_uploader_inc.tpl @@ -8,8 +8,9 @@ </noscript> {* Ensure content_id and content_type_guid are sent with the form if possible. *} -<input type="hidden" name="liberty_attachments[content_id]" value="{$gContent->mContentId}" /> +<input type="hidden" name="liberty_attachments[content_id]" id="la_content_id" value="{$gContent->mContentId}" /> <input type="hidden" name="liberty_attachments[content_type_guid]" value="{$gContent->mContentTypeGuid}" /> +<input type="hidden" name="liberty_attachments[title]" id="la_title" value="{* this is a place holder populated by our upload scrpt - see LibertyAttachable.js *}" /> {* Note! iFrame MUST not be display: none or Safari pops a window instead. *} {* I am not dynamically creating the iFrame to give a warning for browsers with no iframe support. *} |
