70 lines
1.2 KiB
JavaScript
70 lines
1.2 KiB
JavaScript
|
|
Hedera.Basket = new Class
|
|
({
|
|
Extends: Hedera.Form
|
|
|
|
,open: function ()
|
|
{
|
|
this.close ();
|
|
this.isOpen = true;
|
|
|
|
Hedera.BasketChecker.check (this.conn, this.hash,
|
|
this.onBasketCheck.bind (this));
|
|
}
|
|
|
|
,onBasketCheck: function (isOk)
|
|
{
|
|
if (isOk)
|
|
this.loadUi ();
|
|
}
|
|
|
|
,activate: function ()
|
|
{
|
|
this.$.items.setInfo ('i', 'basket_item', 'hedera');
|
|
}
|
|
|
|
,onConfigureClick: function ()
|
|
{
|
|
Htk.Toast.showWarning (_('RememberReconfiguringImpact'));
|
|
this.hash.setAll ({form: 'ecomerce/checkout'});
|
|
}
|
|
|
|
,onCatalogClick: function ()
|
|
{
|
|
this.hash.setAll ({form: 'ecomerce/catalog'});
|
|
}
|
|
|
|
,onCheckoutClick: function ()
|
|
{
|
|
this.hash.setAll ({form: 'ecomerce/confirm'});
|
|
}
|
|
|
|
,repeaterFunc: function (scope, lot)
|
|
{
|
|
var $ = lot.$;
|
|
scope.$.subtotal.value = this.subtotal (lot);
|
|
|
|
if ($.available <= 0)
|
|
text = _('Not available');
|
|
else
|
|
text = $.available +' '+ _('availables');
|
|
|
|
Vn.Node.setText (scope.$.available, text);
|
|
Vn.Node.setVisible (scope.$.available, $.available < $.amount);
|
|
}
|
|
|
|
,onDeleteClick: function (button)
|
|
{
|
|
if (confirm (_('ReallyDelete')))
|
|
button.lot.deleteRow ();
|
|
}
|
|
|
|
,subtotal: function (lot)
|
|
{
|
|
return lot.$.amount * lot.$.price;
|
|
}
|
|
});
|
|
|
|
|
|
|