mirror of
https://github.com/sergeyyarkov/digital-store.git
synced 2026-10-11 10:19:15 +03:00
rename file
This commit is contained in:
parent
f872737a3e
commit
58a41aa82e
18
dist/public/js/bundle.js
vendored
18
dist/public/js/bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
import { Component } from "../core/component";
|
||||
import { apiService } from "../services/api.service";
|
||||
import { renderItemsOne } from "../templates/itemsOne.template";
|
||||
import { renderItemsOne } from "../templates/itemsCategory.template";
|
||||
import { renderItems } from "../templates/items.template";
|
||||
|
||||
export class CategoryComponent extends Component {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Component } from "../core/component";
|
||||
import { apiService } from "../services/api.service";
|
||||
import { renderItems } from "../templates/items.template";
|
||||
import { renderItemsOne } from "../templates/itemsOne.template";
|
||||
import { renderItemsOne } from "../templates/itemsCategory.template";
|
||||
|
||||
export class FilterComponent extends Component {
|
||||
constructor(id, {items}) {
|
||||
|
||||
@ -86,37 +86,37 @@ function addItem(e) {
|
||||
}
|
||||
renderObj(item, this, target);
|
||||
}
|
||||
|
||||
function renderObj(obj, context, target) {
|
||||
if (context.cart.length > 0) {
|
||||
let insterted = false;
|
||||
let index;
|
||||
// Проверка на существующий айтем в корзине
|
||||
context.cart.forEach((item, i) => {
|
||||
if (item.id === obj.id) {
|
||||
insterted = true;
|
||||
index = i;
|
||||
}
|
||||
});
|
||||
if (insterted === false) {
|
||||
context.cart.push(obj)
|
||||
localStorage.setItem('cart', JSON.stringify(context.cart));
|
||||
target.classList.add('orange');
|
||||
target.querySelector('i').innerHTML = 'close';
|
||||
insertCount('counter', context.cart)
|
||||
} else {
|
||||
context.cart.splice(index, 1);
|
||||
localStorage.setItem('cart', JSON.stringify(context.cart));
|
||||
target.classList.remove('orange');
|
||||
target.querySelector('i').innerHTML = 'shopping_cart';
|
||||
insertCount('counter', context.cart)
|
||||
}
|
||||
} else {
|
||||
context.cart.push(obj);
|
||||
localStorage.setItem('cart', JSON.stringify(context.cart));
|
||||
target.classList.add('orange');
|
||||
target.querySelector('i').innerHTML = 'close';
|
||||
insertCount('counter', context.cart)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function renderObj(obj, context, target) {
|
||||
if (context.cart.length > 0) {
|
||||
let insterted = false;
|
||||
let index;
|
||||
// Проверка на существующий айтем в корзине
|
||||
context.cart.forEach((item, i) => {
|
||||
if (item.id === obj.id) {
|
||||
insterted = true;
|
||||
index = i;
|
||||
}
|
||||
});
|
||||
if (insterted === false) {
|
||||
context.cart.push(obj)
|
||||
localStorage.setItem('cart', JSON.stringify(context.cart));
|
||||
target.classList.add('orange');
|
||||
target.querySelector('i').innerHTML = 'close';
|
||||
insertCount('counter', context.cart)
|
||||
} else {
|
||||
context.cart.splice(index, 1);
|
||||
localStorage.setItem('cart', JSON.stringify(context.cart));
|
||||
target.classList.remove('orange');
|
||||
target.querySelector('i').innerHTML = 'shopping_cart';
|
||||
insertCount('counter', context.cart)
|
||||
}
|
||||
} else {
|
||||
context.cart.push(obj);
|
||||
localStorage.setItem('cart', JSON.stringify(context.cart));
|
||||
target.classList.add('orange');
|
||||
target.querySelector('i').innerHTML = 'close';
|
||||
insertCount('counter', context.cart)
|
||||
}
|
||||
};
|
||||
@ -6,8 +6,6 @@ export class Modal {
|
||||
this.init();
|
||||
}
|
||||
|
||||
onShow() {}
|
||||
|
||||
init() {
|
||||
this.open.addEventListener('click', openHandler.bind(this));
|
||||
this.close.addEventListener('click', closeHandler.bind(this));
|
||||
@ -26,7 +24,6 @@ export class Modal {
|
||||
|
||||
function openHandler(e) {
|
||||
this.show();
|
||||
this.onShow(e);
|
||||
}
|
||||
|
||||
function closeHandler() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user