hedera-web/web/forms/ecomerce/basket/basket.js

96 lines
1.8 KiB
JavaScript
Raw Normal View History

2015-02-01 03:21:54 +00:00
Vn.Basket = new Class
({
Extends: Vn.Module
,open: function ()
{
if (this.basketChecked)
this.parent ();
}
2015-07-10 12:30:08 +00:00
,activate: function ()
{
Vn.BasketChecker.check (this.conn,
2015-07-15 13:39:07 +00:00
this.onBasketCheck.bind (this));
2015-07-10 12:30:08 +00:00
}
2015-02-01 03:21:54 +00:00
,onBasketCheck: function (isOk)
2015-02-01 03:21:54 +00:00
{
if (!isOk)
return;
this.basketChecked = true;
this.open ();
2015-02-01 03:21:54 +00:00
}
,onConfigureClick: function ()
2015-02-01 03:21:54 +00:00
{
2015-08-17 18:02:14 +00:00
Htk.Toast.showWarning (_('RememberReconfiguringImpact'));
2015-07-10 12:30:08 +00:00
this.hash.set ({'form': 'ecomerce/checkout'});
2015-02-01 03:21:54 +00:00
}
,onCatalogClick: function ()
{
this.hash.set ({'form': 'ecomerce/catalog'});
}
,onCheckoutClick: function ()
2015-02-01 03:21:54 +00:00
{
this.hash.set ({'form': 'ecomerce/confirm'});
}
,amountRender: function (renderer, form)
{
var amount = form.get ('amount');
var grouping = form.get ('grouping');
if (amount && grouping)
renderer.value = amount / grouping;
else
renderer.value = null;
}
,onAmountChange: function (renderer, row, newValue)
{
var model = this.$('items');
model.set (row, 'amount', newValue * model.get (row, 'grouping'));
}
2015-07-07 15:27:47 +00:00
,featuresRender: function (renderer, form)
{
renderer.value = form.get ('Medida') +' '+ form.get ('Categoria') +' '+ form.get ('Color');
}
,stemsRender: function (renderer, form)
{
2015-07-07 15:27:47 +00:00
renderer.value = Vn.Value.format (form.get ('price'), '%.2d€') +' x '+ form.get ('amount');
if (form.get ('amount') > form.get ('available'))
renderer.td.className = 'available-exceeded';
else
renderer.td.className = '';
}
,subtotalRender: function (renderer, form)
{
renderer.value = this.subtotal (form);
}
,subtotal: function (form)
{
return form.get ('amount') * form.get ('price');
}
,availableRender: function (renderer, form)
{
if (form.get ('amount') > form.get ('avail'))
renderer.value = 'unavailable';
else
renderer.value = 'invisible';
}
});
2015-07-10 12:30:08 +00:00