﻿Type.registerNamespace("WantTheLook.Core.Basket.Summary");
Type.registerNamespace("WantTheLook.Core.Basket.Summary.Constructor");

WantTheLook.Core.Basket.Summary.Constructor = $.Class.extend({
    init: function () {
        this.BasketTotalControl = arguments[0];
        this.BasketItemTotalContol = arguments[1];
        this.ViewPreviewControl = arguments[2];
        this.BasketIcon = arguments[3];

        this.LoadSummary();
    },
    LoadSummary: function () {
        dotCommerce.Clients.WantTheLook.Shop.Resources.Services.Basket.Summary(this.SetSummaryValues.bind(this));
    },
    SetSummaryValues: function (e) {
        this.BasketTotalControl.html('<span>Total:</span>' + e.BasketTotal);
        this.BasketItemTotalContol.html('<span>Items:</span>' + e.ItemsInBasket);

        if (e.ItemsInBasket > 0) {
            this.BasketIcon.addClass('full');
        } else {
            this.BasketIcon.removeClass('full');
        }

        WantTheLook.Core.Basket.Preview.Update(e);
    }
});
