")
.load("basket","/shop/get-basket?full=1")
.set("rows",[])
.set("object",{})
.set("mixin",{
addSum:addSum,
clearSum:clearSum
})
;
}
app.onLoaded=function(vals){
var b=Jos.jsonify(vals.basket);
if(!b) {
alert("Greška pri obradi zahteva");
Jos.go("/");
return;
}
vals.object=b;
vals.rows=Jos.jsonify(b.items);
}
app.onOpen=function(){
}
app.onOpened=function(){
updatePage(app.component.object.quantity);
Jos.talk(null,"jos-resize"); // iepage correction
Jos.libs.ga.gaBeginCheckout();
}
app.onRender=function(sel){
if(sel=="#shopcartContainer tbody") {
app.win.find(".spinner-container input").on("blur",function(e){
var sku=$(this).prop("name").substring(2);
var q=app.val("q_"+sku);
setQuantity(sku,q);
});
}
JosBundle.run(Jos.cfg.serverUrl+"/"+Jos.cfg.lang+"/getTemplate?path=/private/blocks/shop/shopsteps","shopsteps",{step:0});
}
function addSum(x){
priceSum+=x;
}
function clearSum(){
priceSum=0;
}
function updatePage(quantity){
if(!quantity) {
$("#OrderForm_OrderForm").hide();
$("#shopheader").hide();
$("#emptyBasket").show();
}
app.find(".pricesum").text(frmnum(priceSum,2));
var but=app.named("action_next");
if(!areStickersConfigured()) {
but.addClass("disabled");
} else {
but.removeClass("disabled");
}
}
function setQuantity(sku,q){
clearSum();
Jos.showLoading(100);
var u="/shop/set-quantity?sku="+sku+"&quantity="+q;
JosStore.load(u,function(ret){
Jos.hideLoading();
var b=Jos.jsonify(ret);
app.component.object=b;
app.component.update(b.items,true);
Jos.talk(null,"shopUpdated",null,ret);
updatePage(b.quantity);
},true);
}
function submitQuantities(){
Jos.go("/sr/shop/details");
}
function areStickersConfigured(){
var rows=app.component.rows;
for(var f=0;f0) q--;
setQuantity(sku,q);
}
app.route.remove=function(e,sku){
setQuantity(sku,0);
}
app.route.enterKey=function(e,sku){
if(e.which==13) {
var q=app.val("q_"+sku);
setQuantity(sku,q);
}
}
app.route.editLabel=function(e,sku){
Jos.go("/sr/labelConfig?sku="+sku);
}
app.route.nextStep=function(){
if(!areStickersConfigured()) {
alert("Please configure stickers before proceeding");
return;
}
submitQuantities();
}
},"list");
Jos.autoRun("shopcart");
-->