NIHVIVO-161 Minor Javascript refactoring.

This commit is contained in:
rjy7 2010-07-01 14:35:53 +00:00
parent b1a35f1588
commit 61714819b0
3 changed files with 18 additions and 8 deletions

View file

@ -28,12 +28,16 @@
}
};
$('#submitPhoto').click(function() {
function removeAlpha(str) {
return str.replace(/[^\d-]/g,'');
};
$('#cropImage').submit(function() {
var preview = $('#preview');
$('input[name=x]').val(preview.css('marginLeft').replace(/[^\d-]/g,''));
$('input[name=y]').val(preview.css('marginTop').replace(/[^\d-]/g,''));
$('input[name=w]').val(preview.css('width').replace(/[^\d-]/g,''));
$('input[name=h]').val(preview.css('height').replace(/[^\d-]/g,''));
$('input[name=x]').val(removeAlpha(preview.css('marginLeft')));
$('input[name=y]').val(removeAlpha(preview.css('marginTop')));
$('input[name=w]').val(removeAlpha(preview.css('width')));
$('input[name=h]').val(removeAlpha(preview.css('height')));
});
});

View file

@ -18,7 +18,13 @@ ${stylesheets.addFromTheme("/jquery.Jcrop.css")}
<div style="width:115px;height:115px;overflow:hidden;border:1px solid green;"> <img src="${imageUrl}" id="preview" /> </div>
<div id="photoCroppingHowTo">
<p class="photoCroppingNote">To make adjustments, you can drag around and resize the blue square to the right. When you are happy with your photo click the "Save Photo" button. </p>
<form action="${formAction}" method="post">
<form id="cropImage" action="${formAction}" method="post">
<!-- Javascript will populate these values -->
<input type="hidden" name="x" value="" />
<input type="hidden" name="y" value="" />
<input type="hidden" name="w" value="" />
<input type="hidden" name="h" value="" />
<input type="submit" value="Save photo">
or <a href="${cancelUrl}">Cancel</a>

View file

@ -16,9 +16,9 @@ ${stylesheets.addFromTheme("/uploadImages.css")}
<a href="${deleteUrl}">Delete photo</a></div>
<div id="photoUploadForm">
<form action="${formAction}" enctype="multipart/form-data" method="post">
<label>Replace Photo <span> (JPEG, GIF or PNG. Max Size: 50 MB)</span></label>
<label>Replace Photo <span> (JPEG, GIF or PNG. Max Size: 50 MB)</span></label>
<input type="file" name="datafile" size="30">
<input type="submit" value="Upload a photo"> or <a href="${cancelUrl}">Cancel</a>
<input type="submit" value="Upload photo"> or <a href="${cancelUrl}">Cancel</a>
</form>
</div>
</div>