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 { Component } from "../core/component";
|
||||||
import { apiService } from "../services/api.service";
|
import { apiService } from "../services/api.service";
|
||||||
import { renderItemsOne } from "../templates/itemsOne.template";
|
import { renderItemsOne } from "../templates/itemsCategory.template";
|
||||||
import { renderItems } from "../templates/items.template";
|
import { renderItems } from "../templates/items.template";
|
||||||
|
|
||||||
export class CategoryComponent extends Component {
|
export class CategoryComponent extends Component {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Component } from "../core/component";
|
import { Component } from "../core/component";
|
||||||
import { apiService } from "../services/api.service";
|
import { apiService } from "../services/api.service";
|
||||||
import { renderItems } from "../templates/items.template";
|
import { renderItems } from "../templates/items.template";
|
||||||
import { renderItemsOne } from "../templates/itemsOne.template";
|
import { renderItemsOne } from "../templates/itemsCategory.template";
|
||||||
|
|
||||||
export class FilterComponent extends Component {
|
export class FilterComponent extends Component {
|
||||||
constructor(id, {items}) {
|
constructor(id, {items}) {
|
||||||
|
|||||||
@ -86,37 +86,37 @@ function addItem(e) {
|
|||||||
}
|
}
|
||||||
renderObj(item, this, target);
|
renderObj(item, this, target);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function renderObj(obj, context, target) {
|
function renderObj(obj, context, target) {
|
||||||
if (context.cart.length > 0) {
|
if (context.cart.length > 0) {
|
||||||
let insterted = false;
|
let insterted = false;
|
||||||
let index;
|
let index;
|
||||||
// Проверка на существующий айтем в корзине
|
// Проверка на существующий айтем в корзине
|
||||||
context.cart.forEach((item, i) => {
|
context.cart.forEach((item, i) => {
|
||||||
if (item.id === obj.id) {
|
if (item.id === obj.id) {
|
||||||
insterted = true;
|
insterted = true;
|
||||||
index = i;
|
index = i;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (insterted === false) {
|
if (insterted === false) {
|
||||||
context.cart.push(obj)
|
context.cart.push(obj)
|
||||||
localStorage.setItem('cart', JSON.stringify(context.cart));
|
localStorage.setItem('cart', JSON.stringify(context.cart));
|
||||||
target.classList.add('orange');
|
target.classList.add('orange');
|
||||||
target.querySelector('i').innerHTML = 'close';
|
target.querySelector('i').innerHTML = 'close';
|
||||||
insertCount('counter', context.cart)
|
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 {
|
} else {
|
||||||
context.cart.push(obj);
|
context.cart.splice(index, 1);
|
||||||
localStorage.setItem('cart', JSON.stringify(context.cart));
|
localStorage.setItem('cart', JSON.stringify(context.cart));
|
||||||
target.classList.add('orange');
|
target.classList.remove('orange');
|
||||||
target.querySelector('i').innerHTML = 'close';
|
target.querySelector('i').innerHTML = 'shopping_cart';
|
||||||
insertCount('counter', context.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();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow() {}
|
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this.open.addEventListener('click', openHandler.bind(this));
|
this.open.addEventListener('click', openHandler.bind(this));
|
||||||
this.close.addEventListener('click', closeHandler.bind(this));
|
this.close.addEventListener('click', closeHandler.bind(this));
|
||||||
@ -26,7 +24,6 @@ export class Modal {
|
|||||||
|
|
||||||
function openHandler(e) {
|
function openHandler(e) {
|
||||||
this.show();
|
this.show();
|
||||||
this.onShow(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeHandler() {
|
function closeHandler() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user