Witam
Od dłuższego czasu walczę z przerobieniem skryptu Jcrop. Niestety nie znam Jquery jaki i wogólne z programowania nie jestem najlepszy.
$(this).fadeIn().Jcrop({
bgFade: true,
bgOpacity: .3,
onChange: showPreview,
onSelect: showPreview,
//onChange: updateCoords,
//onSelect: updateCoords,
setSelect: [ 0, 0,400,400]
},function(){
jcrop_api = this;
});
Muszę w jednym działaniu wywoływać dwie funkcje : showPreview oraz updateCoords no ale się nie da.
To jest pierwszy problem. Nie wiem jak mogę wywołać tą funkcję updateCoords. Czy można wywołać np jedną funkcję w drugiej?
function updateCoords(c)
{
$('#x').val(c.x);
$('#y').val(c.y);
$('#w').val(c.w);
$('#h').val(c.h);
};
function showPreview(coords)
{
if (parseInt(coords.w) > 0)
{
var rx = $imgpos.width / coords.w;
var ry = $imgpos.height / coords.h;
$('#preview').css({
width
: Math
.round($imgpos.width
) + 'px', height
: Math
.round($imgpos.height
) + 'px', marginLeft
: '-' + Math
.round(coords
.x
) + 'px', marginTop
: '-' + Math
.round(coords
.y
) + 'px' });
$('#preview_container').css({
width
: Math
.round(coords
.w
) + 'px', height
: Math
.round(coords
.h
) + 'px'
});
}
};
Drugim problemem jest funkcja
function checkCoords()
{
if (parseInt($('#w').val())){
return true;
}
$('#x').val(100);
$('#y').val(100);
$('#w').val(100);
$('#h').val(100);
wywołana jest w formularzu i dane przekazane są do php.
<form id="cropattrform" action="crop.php" method="post" onSubmit="return checkCoords();">
<input type="hidden" id="x" name="x" />
<input type="hidden" id="y" name="y" />
<input type="hidden" id="w" name="w" />
<input type="hidden" id="h" name="h" />
<input type="hidden" id="tempfile" name="tempfile" />
<input type="hidden" class="jq_step" id="step" name="step" value="process" />
</form>
Chciałbym przekazać zamiasta
$('#x').val(100); np:
$('#x').val(c.x); z funkcji updateCoords©
Z góry dziękuje za pomoc.