JS tweaks for form validation (file upload) and delete confirmation NIHVIVO-577
This commit is contained in:
parent
98ce002973
commit
8d5e7a2dc0
3 changed files with 19 additions and 26 deletions
|
@ -1,27 +1,20 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
|
||||||
/* comments */
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
$("#photoUploadContainer").removeClass("hidden");
|
$("#photoUploadContainer").removeClass("hidden");
|
||||||
|
|
||||||
|
|
||||||
$('#photoUploadForm form').submit(function() {
|
|
||||||
if (form_passed.datafile.value == "") {
|
|
||||||
alert ("Please browse and select a photo");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
$('#photoUploadForm form').submit(function() {
|
||||||
|
if ($("#datafile").val() == '') {
|
||||||
|
alert('Please browse and select a photo.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function delete_photo(passUrl) {
|
$('a.delete').click(function(){
|
||||||
var delete_photo_answer = confirm ("Are you sure you want to delete your photo?");
|
var answer = confirm('Are you sure you want to '+ jQuery(this).attr('title') +'?' );
|
||||||
if (delete_photo_answer){
|
// jQuery(this).attr('title') gets anchor title attribute
|
||||||
window.open(passUrl);
|
return answer;
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
});
|
|
@ -38,8 +38,8 @@ ${stylesheets.addFromTheme("/uploadImages.css")}
|
||||||
<form action="${formAction}" enctype="multipart/form-data" method="post">
|
<form action="${formAction}" enctype="multipart/form-data" method="post">
|
||||||
|
|
||||||
<label>Upload a photo <span> (JPEG, GIF or PNG)</span></label>
|
<label>Upload a photo <span> (JPEG, GIF or PNG)</span></label>
|
||||||
<input type="file" name="datafile" size="30">
|
<input id="datafile" type="file" name="datafile" size="30">
|
||||||
<input type="submit" value="Upload photo"> or <a class="cancelUpload" href="${cancelUrl}">Cancel</a>
|
<input type="submit" value="Upload photo"> or <a class="cancelUpload" href="${cancelUrl}">Cancel</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -23,12 +23,12 @@ ${stylesheets.addFromTheme("/uploadImages.css")}
|
||||||
<div id="photoUploadDefaultImageContainer">
|
<div id="photoUploadDefaultImageContainer">
|
||||||
<h6>Current Photo</h6>
|
<h6>Current Photo</h6>
|
||||||
<img src="${thumbnailUrl}" width="115" />
|
<img src="${thumbnailUrl}" width="115" />
|
||||||
<a href='javascript:delete_photo("${deleteUrl}");'>Delete photo</a></div>
|
<a class="delete" href="${deleteUrl}" title="delete the current photo">Delete photo</a></div>
|
||||||
<div id="photoUploadForm">
|
<div id="photoUploadForm">
|
||||||
<form action="${formAction}" enctype="multipart/form-data" method="post">
|
<form action="${formAction}" enctype="multipart/form-data" method="post">
|
||||||
<label>Replace Photo <span> (JPEG, GIF or PNG)</span></label>
|
<label>Replace Photo <span> (JPEG, GIF or PNG)</span></label>
|
||||||
<input type="file" name="datafile" size="30">
|
<input type="file" name="datafile" size="30">
|
||||||
<input type="submit" value="Upload photo"> or <a class="cancelUpload" href="${cancelUrl}">Cancel</a>
|
<input type="submit" value="Upload photo"> or <a class="cancelUpload" href="${cancelUrl}">Cancel</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue