var ArtboxBasket = (function () { function ArtboxBasket() { this.init(true, true); } Object.defineProperty(ArtboxBasket.prototype, "items", { get: function () { return this._items; }, enumerable: true, configurable: true }); ArtboxBasket.prototype.init = function (update_modal, update_cart) { $.get('/basket', function (data) { this._items = data.basket; if (update_modal) { this.updateModal(data.modal, false); } if (update_cart) { this.updateCart(data.cart); } }.bind(this), 'json').fail(function () { console.error('Basket cannot be init'); }); }; ArtboxBasket.prototype.add = function (product_variant_id) { $.post('/basket/add?product_variant_id=' + product_variant_id, function (data) { this._items = data.basket; this.updateModal(data.modal, data.cart, true); showForm(); }.bind(this), 'json').fail(function (xhr, status, error) { console.error(error); }); }; ArtboxBasket.prototype.remove = function (product_variant_id) { $.post('/basket/remove?product_variant_id=' + product_variant_id, function (data) { this._items = data.basket; this.updateCart(data.cart); // this.updateModal(data.modal, data.cart, true); }.bind(this), 'json').fail(function (xhr, status, error) { console.error(error); }); }; ArtboxBasket.prototype.updateModal = function (modal, cart_html, show) { if (show === void 0) { show = false; } var modalBox = $('#modal_form-2'); modalBox.html(modal); if (cart_html) { this.updateCart(cart_html); } }; ArtboxBasket.prototype.updateCart = function (cart_html) { var cart = $('.question-form '); cart.html(cart_html); }; Object.defineProperty(ArtboxBasket.prototype, "count", { get: function () { return Object.keys(this._items).length; }, enumerable: true, configurable: true }); return ArtboxBasket; }()); //# sourceMappingURL=artbox_basket.js.map