You are on page 1of 4

function onUpdatePanelFinished_AuctionDataPanel() {

var startingPrice = parseFloat($('#data_mb').val


());
var highestBid = parseFloat($('#data_hbv').val()
);
var myBid = parseFloat($('#data_mbv').val());
var reservePrice = parseFloat($('#data_rp').val(
));

/*$('.handle h2 .async_value').text($('#starting
Price').text());
$('.pointer .async_value').text($('#highestBid')
.text());
$('.mypointer .async_value').text($('#myBidValue
').text());*/

var barHolderWidth = $('.barholder').css('width'
).replace('px', '');
var barWidth = $('.bar').css('width').replace('p
x', '');
var hbvWidth = $('.pointer').css('width').replac
e('px', '');
var mbvWidth = $('.mypointer').css('width').repl
ace('px', '');
//handle
var startingPriceP = getPositionOnBar(startingPr
ice, reservePrice);
startingPriceP = startingPriceP < 0 ? 0 : starti
ngPriceP;
startingPriceP = startingPriceP > barWidth ? bar
Width : startingPriceP;
//pointer
var highestBidP = getPositionOnBar(highestBid, r
eservePrice);
highestBidP = highestBidP < 0 ? 0 : highestBidP;
highestBidP = highestBidP > barWidth ? barWidth
: highestBidP;
//mypointer
var myBidP = getPositionOnBar(myBid, reservePric
e);
myBidP = myBidP < 0 ? 0 : myBidP;
myBidP = myBidP > barWidth ? barWidth : myBidP;
var barPosition;
if (highestBid >= startingPrice) {
//+ (highestBidP + hbvWidth >= barHolderWidt
h ? parseFloat(hbvWidth) : 0)
barPosition = parseFloat(highestBidP) ; //g
ive some extra space to the right side (hbvWidth = 120:the width of pointer)
} else {
barPosition = parseFloat(startingPriceP);
}
barPosition = barPosition > barWidth ? barWidth
: barPosition; //don't scroll more than the total width
barPosition = parseFloat(barPosition) - parseFlo
at(barHolderWidth); //scroll back viewport.width pixels in order to make the des
ired part visible and not squeezed to the left.
barPosition = barPosition < 0 ? 0 : barPosition;
//But also, we should also never deattach the bar from the left wall
//var scrollBG = parseFloat(highestBidP) >= (par
seFloat(barPosition) + (parseFloat(barHolderWidth) / 2));



var barLeft = -barPosition ;
var handleLeft = startingPriceP - barPosition ;
var pointerLeft = highestBidP - barPosition ;
var mypointerLeft = myBidP - barPosition ;
//do the animations if the values have changed
if(parseFloat($('.bar').attr('target_left')) !=
barLeft){
$('.bar').animate({ 'left': barLeft }, { dur
ation: 1000, queue: false});
}
if (parseFloat($('.handle h2').attr('target_left
')) != handleLeft) {
$('.handle h2').animate({
'left': handleLeft
, 'z-index': 1
}
, {
duration: 1500
, queue: false
, progress: fun
ction () {
//$(this).c
hildren('.async_value').text(getPriceFromPositionOnBar(parseFloat($(this).css('l
eft').replace('px', '')),reservePrice));
if (parseFl
oat($(this).css('left').replace('px', '')) < 0

|| parseFloat($(this).css('left').replace('px', '')) > barHolderWidth) {
$(this)
.css('display', 'none');
} else {
$(this)
.css('display', 'block');
}
}
,step: function
() {
$(this).fin
d('.async_value').text(localizeNum(roundFixed(getPriceFromPositionOnBar(parseFlo
at($(this).css('left').replace('px', '')) - parseFloat($('.bar').css('left').rep
lace('px', '')), reservePrice, startingPrice), 2)).toString() + ' ' + userCurren
cySymbol);
}
});
}
if (parseFloat($('.pointer').attr('target_left')
) != pointerLeft) {
$('.pointer').animate({
'left': pointerLeft
, 'margin-left': -(h
bvWidth / 2)
, 'z-index': 3
}
,
{
duration: 1500
, queue: false
, progress: fun
ction () {
if (parseFl
oat($(this).css('left').replace('px', '')) < 0

|| parseFloat($(this).css('left').replace('px', '')) > barHolderWidth) {
$(this)
.css('display', 'none');
} else {
$(this)
.css('display', 'block');
}
}
, step: functio
n () {
$(this).fin
d('.async_value').text(localizeNum(roundFixed(getPriceFromPositionOnBar(parseFlo
at($(this).css('left').replace('px', '')) - parseFloat($('.bar').css('left').rep
lace('px', '')), reservePrice, highestBid), 2)).toString() + ' ' + userCurrencyS
ymbol);
}
});
}
if (parseFloat($('.mypointer').attr('target_left
')) != mypointerLeft ) {
$('.mypointer').animate({
'left': mypointe
rLeft
, 'margin-left':
-(mbvWidth / 2)
, 'z-index' : 2
}
,
{
duration: 2000
, queue: false
, progress: fun
ction ()
{
if (pars
eFloat($(this).css('left').replace('px', '')) < 0

|| parseFloat($(this).css('left').replace('px', '')) > barHolderWidth) {
$(th
is).css('display','none');
} else {
$(th
is).css('display','block');
}
}
, step: functio
n () {
$(this).fin
d('.async_value').text(localizeNum(roundFixed(getPriceFromPositionOnBar(parseFlo
at($(this).css('left').replace('px', '')) - parseFloat($('.bar').css('left').rep
lace('px', '')), reservePrice, myBid), 2)).toString() + ' ' + userCurrencySymbol
);
}
});
}
//set the new target positions
$('.bar').attr('target_left', barLeft);
$('.handle h2').attr('target_left', handleLeft);
$('.pointer').attr('target_left', pointerLeft);
$('.mypointer').attr('target_left', mypointerLef
t);
var timeRemaining = $('.lower .lft p');
$(timeRemaining).html($('#AuctionDataPanel_HtmlD
ata #data_timeRemaining').html());
$('#AuctionDataPanel_HtmlData #data_timeRemainin
g').html('');
$('#tempAsyncData').html($('#AuctionDataPanel_Ht
mlData #data_AuctionValues').html());
if ($('#bidValue').val() == null ||$('#bidValue'
).val() == '' || parseFloat($('#bidValue').val()) < parseFloat($('#data_hbv').va
l()) + parseFloat($('#data_i').val())) {
$('#bidValue').val(parseFloat($('#data_hbv')
.val()) + parseFloat($('#data_i').val()));
if (parseFloat($('#bidValue').val()) < parse
Float($('#data_mb').val())) {
$('#bidValue').val(parseFloat($('#data_m
b').val()));
}
}
var addedFunds = parseFloat($('#bidValue').val()
) - parseFloat($('#data_hbv').val());
$('#addedFunds').text('+' + addedFunds);
}

You might also like