},
getItemsNumbers: function () {
- return this.getItems().length;
+ let res = 0;
+ $.each(this.getItems(), function (i, item) {
+ res++;
+ });
+ return res;
},
getAllQuantities: function () {
},
updateIcon: function () {
+ console.log(this.getItemsNumbers());
$(this.fluidbook).trigger('fluidbook.cart.updateIcon', {number: this.getItemsNumbers()});
},
$(this.fluidbook).on('fluidbook.links.ready', function () {
$this.updateLinks();
});
+
+ $(this.fluidbook).on('fluidbook.cart.updateIcon', function (e, data) {
+ var n = data.number;
+ let l = $('div.link[data-action="basket"]');
+ if ($(l).length > 0) {
+ if (n === 0) {
+ $(l).find('span.number').remove();
+ } else {
+ if ($(l).find('span.number').length === 0) {
+ $(l).append('<span class="number"></span>');
+ }
+ $(l).find('span.number').text(n);
+ }
+ }
+ });
+
+ if (this.instance.updateIcon !== undefined) {
+ $(this.fluidbook).on('fluidbook.ready', function () {
+ $this.instance.updateIcon();
+ });
+ }
},
hasItem: function (ref) {
cursor: pointer;
}
}
+}
+
+div.link[data-action="basket"] {
+ position: relative;
+
+ span.number {
+ position: absolute;
+ background-color: #e30613;
+ color: #fff;
+ text-align: center;
+ right: -10px;
+ bottom: -10px;
+ width: 20px;
+ height: 20px;
+ border-radius: 50%;
+ font-weight: bold;
+ font-size: 12px;
+ line-height: 20px;
+ }
}
\ No newline at end of file