From 99290c29cab7861a46c0a62e8ac6dff9f5d5b65d Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Wed, 11 Dec 2019 21:56:35 +0300 Subject: [PATCH] deted non-unique ids --- dist/public/js/admin/materialize.config.js | 1 - dist/public/js/main/main.js | 4 ++-- dist/views/assets/templates/modals/cart.pug | 8 ++++---- dist/views/assets/templates/modals/pay.pug | 10 +++++----- src/main/modals/cart.modal.js | 12 ++++++------ src/main/modals/pay.modal.js | 12 ++++++------ 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/dist/public/js/admin/materialize.config.js b/dist/public/js/admin/materialize.config.js index 3236137..bd47399 100644 --- a/dist/public/js/admin/materialize.config.js +++ b/dist/public/js/admin/materialize.config.js @@ -27,7 +27,6 @@ document.addEventListener('DOMContentLoaded', function () { M.Collapsible.init(document.querySelectorAll('.collapsible')); M.Modal.init(document.querySelectorAll('.modal')); - //- active временно!!!!! const currentPage = document.querySelector('#currentPage').dataset.current; const pages = Array.from(document.querySelectorAll('.collapsible li')); pages.forEach(function (page) { diff --git a/dist/public/js/main/main.js b/dist/public/js/main/main.js index ca9d040..4811dd1 100644 --- a/dist/public/js/main/main.js +++ b/dist/public/js/main/main.js @@ -4014,7 +4014,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _com /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"CartModal\", function() { return CartModal; });\n/* harmony import */ var _core_modal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../core/modal */ \"./src/main/core/modal.js\");\n/* harmony import */ var _other_counter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../other/counter */ \"./src/main/other/counter.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\nvar CartModal =\n/*#__PURE__*/\nfunction (_Modal) {\n _inherits(CartModal, _Modal);\n\n function CartModal(id, open, close, _ref) {\n var _this;\n\n var items = _ref.items;\n\n _classCallCheck(this, CartModal);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(CartModal).call(this, id, open, close));\n _this.items = items;\n\n if (_this.$el) {\n _this.open.addEventListener('click', _this.openHandler.bind(_assertThisInitialized(_this)));\n\n _this.close.addEventListener('click', _this.closeHandler.bind(_assertThisInitialized(_this)));\n\n _this.list = _this.$el.querySelector('#modalList');\n }\n\n return _this;\n }\n\n _createClass(CartModal, [{\n key: \"closeHandler\",\n value: function closeHandler() {\n this.removeItem = null;\n this.makePay = null;\n }\n }, {\n key: \"openHandler\",\n value: function openHandler() {\n this.removeItem != null ? this.list.addEventListener('click', this.removeItem.bind(this)) : false;\n this.makePay != null ? this.$el.querySelector('#purchaseInfo').addEventListener('submit', this.makePay.bind(this)) : false;\n this.list.innerHTML = '';\n this.insertItems(this.list);\n }\n }, {\n key: \"insertItems\",\n value: function insertItems(list) {\n var _this2 = this;\n\n if (localStorage.getItem('cart')) {\n var items = JSON.parse(localStorage.getItem('cart'));\n\n if (items.length == 0) {\n list.innerHTML = '

Вы не добавили ни один товар

';\n this.$el.querySelector('#purchaseInfo').classList.add('hide');\n } else {\n this.$el.querySelector('#purchaseInfo').classList.remove('hide');\n }\n\n items.forEach(function (item) {\n return _this2.list.innerHTML += \"
\").concat(item.title, \"
\\u0412 \\u043D\\u0430\\u043B\\u0438\\u0447\\u0438\\u0438: \").concat(item.count, \" (\\u0448\\u0442)
\").concat(parseFloat(item.price).toFixed(2), \"\\u20BD
close
\");\n });\n Object(_other_counter__WEBPACK_IMPORTED_MODULE_1__[\"insertCount\"])('modalCounter', this.items.cart);\n Object(_other_counter__WEBPACK_IMPORTED_MODULE_1__[\"insertCount\"])('counter', this.items.cart);\n this.insertTotalPrice('totalPrice', this.items.cart);\n } else {\n list.innerHTML = '

Вы не добавили ни один товар

';\n }\n }\n }, {\n key: \"removeItem\",\n value: function removeItem(e) {\n if (e.target.id === 'removeItem') {\n var id = e.target.dataset.id;\n var index;\n this.items.cart.forEach(function (item, i) {\n return item.id === id ? index = i : false;\n });\n this.items.cart.splice(index, 1);\n localStorage.setItem('cart', JSON.stringify(this.items.cart));\n this.list.innerHTML = '';\n this.insertItems(this.list);\n this.defaultBtnColor(id);\n }\n }\n }, {\n key: \"insertTotalPrice\",\n value: function insertTotalPrice(id, array) {\n var totalPrice = 0;\n array.forEach(function (item) {\n return totalPrice += parseFloat(item.price);\n });\n this.$el.querySelector(\"#\".concat(id)).innerHTML = \"\".concat(totalPrice.toFixed(2), \"\\u20BD\");\n }\n }, {\n key: \"makePay\",\n value: function makePay(e) {\n e.preventDefault();\n var payInfo = {\n items: this.items.cart.map(function (item) {\n return {\n id: item.id,\n title: item.title,\n price: parseFloat(item.price)\n };\n })\n };\n var totalPrice = 0;\n payInfo.items.forEach(function (item) {\n return totalPrice += parseFloat(item.price);\n });\n payInfo.totalPrice = Math.round(totalPrice * 100) / 100;\n payInfo.payMethod = this.$el.querySelector('.payment-field #payment').value;\n payInfo.phone = this.$el.querySelector('.phone-field #phone').value;\n payInfo.email = this.$el.querySelector('.email-field #email').value;\n console.log('Pay info:', payInfo);\n }\n }, {\n key: \"defaultBtnColor\",\n value: function defaultBtnColor(id) {\n if (this.items.roster) {\n if (this.items.roster.querySelector(\"#rosterButtons[data-id=\\\"\".concat(id, \"\\\"] #addItem\"))) {\n this.items.roster.querySelector(\"#rosterButtons[data-id=\\\"\".concat(id, \"\\\"] #addItem\")).classList.remove('orange');\n this.items.roster.querySelector(\"#rosterButtons[data-id=\\\"\".concat(id, \"\\\"] #addItem i\")).innerHTML = 'shopping_cart';\n }\n }\n }\n }]);\n\n return CartModal;\n}(_core_modal__WEBPACK_IMPORTED_MODULE_0__[\"Modal\"]);\n\n//# sourceURL=webpack:///./src/main/modals/cart.modal.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"CartModal\", function() { return CartModal; });\n/* harmony import */ var _core_modal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../core/modal */ \"./src/main/core/modal.js\");\n/* harmony import */ var _other_counter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../other/counter */ \"./src/main/other/counter.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\nvar CartModal =\n/*#__PURE__*/\nfunction (_Modal) {\n _inherits(CartModal, _Modal);\n\n function CartModal(id, open, close, _ref) {\n var _this;\n\n var items = _ref.items;\n\n _classCallCheck(this, CartModal);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(CartModal).call(this, id, open, close));\n _this.items = items;\n\n if (_this.$el) {\n _this.open.addEventListener('click', _this.openHandler.bind(_assertThisInitialized(_this)));\n\n _this.close.addEventListener('click', _this.closeHandler.bind(_assertThisInitialized(_this)));\n\n _this.list = _this.$el.querySelector('#modalList');\n }\n\n return _this;\n }\n\n _createClass(CartModal, [{\n key: \"closeHandler\",\n value: function closeHandler() {\n this.removeItem = null;\n this.makePay = null;\n }\n }, {\n key: \"openHandler\",\n value: function openHandler() {\n this.removeItem != null ? this.list.addEventListener('click', this.removeItem.bind(this)) : false;\n this.makePay != null ? this.$el.querySelector('form').addEventListener('submit', this.makePay.bind(this)) : false;\n this.list.innerHTML = '';\n this.insertItems(this.list);\n }\n }, {\n key: \"insertItems\",\n value: function insertItems(list) {\n var _this2 = this;\n\n if (localStorage.getItem('cart')) {\n var items = JSON.parse(localStorage.getItem('cart'));\n\n if (items.length == 0) {\n list.innerHTML = '

Вы не добавили ни один товар

';\n this.$el.querySelector('form').classList.add('hide');\n } else {\n this.$el.querySelector('form').classList.remove('hide');\n }\n\n items.forEach(function (item) {\n return _this2.list.innerHTML += \"
\").concat(item.title, \"
\\u0412 \\u043D\\u0430\\u043B\\u0438\\u0447\\u0438\\u0438: \").concat(item.count, \" (\\u0448\\u0442)
\").concat(parseFloat(item.price).toFixed(2), \"\\u20BD
close
\");\n });\n Object(_other_counter__WEBPACK_IMPORTED_MODULE_1__[\"insertCount\"])('modalCounter', this.items.cart);\n Object(_other_counter__WEBPACK_IMPORTED_MODULE_1__[\"insertCount\"])('counter', this.items.cart);\n this.insertTotalPrice('totalPrice', this.items.cart);\n } else {\n list.innerHTML = '

Вы не добавили ни один товар

';\n }\n }\n }, {\n key: \"removeItem\",\n value: function removeItem(e) {\n if (e.target.id === 'removeItem') {\n var id = e.target.dataset.id;\n var index;\n this.items.cart.forEach(function (item, i) {\n return item.id === id ? index = i : false;\n });\n this.items.cart.splice(index, 1);\n localStorage.setItem('cart', JSON.stringify(this.items.cart));\n this.list.innerHTML = '';\n this.insertItems(this.list);\n this.defaultBtnColor(id);\n }\n }\n }, {\n key: \"insertTotalPrice\",\n value: function insertTotalPrice(id, array) {\n var totalPrice = 0;\n array.forEach(function (item) {\n return totalPrice += parseFloat(item.price);\n });\n this.$el.querySelector(\"#\".concat(id)).innerHTML = \"\".concat(totalPrice.toFixed(2), \"\\u20BD\");\n }\n }, {\n key: \"makePay\",\n value: function makePay(e) {\n e.preventDefault();\n var payInfo = {\n items: this.items.cart.map(function (item) {\n return {\n id: item.id,\n title: item.title,\n price: parseFloat(item.price)\n };\n })\n };\n var totalPrice = 0;\n payInfo.items.forEach(function (item) {\n return totalPrice += parseFloat(item.price);\n });\n payInfo.totalPrice = Math.round(totalPrice * 100) / 100;\n payInfo.payMethod = this.$el.querySelector('.payment-field input').value;\n payInfo.phone = this.$el.querySelector('.phone-field input').value;\n payInfo.email = this.$el.querySelector('.email-field input').value;\n console.log('Pay info:', payInfo);\n }\n }, {\n key: \"defaultBtnColor\",\n value: function defaultBtnColor(id) {\n if (this.items.roster) {\n if (this.items.roster.querySelector(\"#rosterButtons[data-id=\\\"\".concat(id, \"\\\"] #addItem\"))) {\n this.items.roster.querySelector(\"#rosterButtons[data-id=\\\"\".concat(id, \"\\\"] #addItem\")).classList.remove('orange');\n this.items.roster.querySelector(\"#rosterButtons[data-id=\\\"\".concat(id, \"\\\"] #addItem i\")).innerHTML = 'shopping_cart';\n }\n }\n }\n }]);\n\n return CartModal;\n}(_core_modal__WEBPACK_IMPORTED_MODULE_0__[\"Modal\"]);\n\n//# sourceURL=webpack:///./src/main/modals/cart.modal.js?"); /***/ }), @@ -4026,7 +4026,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"PayModal\", function() { return PayModal; });\n/* harmony import */ var _core_modal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../core/modal */ \"./src/main/core/modal.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\nvar PayModal =\n/*#__PURE__*/\nfunction (_Modal) {\n _inherits(PayModal, _Modal);\n\n function PayModal(id, open, close) {\n var _this;\n\n _classCallCheck(this, PayModal);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(PayModal).call(this, id, open, close));\n\n if (_this.open != null) {\n _this.open.addEventListener('click', _this.openHandler.bind(_assertThisInitialized(_this)));\n\n _this.close.addEventListener('click', _this.closeHandler.bind(_assertThisInitialized(_this)));\n }\n\n return _this;\n }\n\n _createClass(PayModal, [{\n key: \"closeHandler\",\n value: function closeHandler() {\n this.$el.querySelector('#purchaseInfo').onsubmit = null;\n }\n }, {\n key: \"openHandler\",\n value: function openHandler(e) {\n var _this2 = this;\n\n if (e.target.id === 'payOpen') {\n var targetInfo = e.target.parentNode.dataset;\n this.$el.querySelector('.title-field #title').value = targetInfo.title;\n this.show();\n\n this.$el.querySelector('#purchaseInfo').onsubmit = function (e) {\n _this2.makePay(e, targetInfo);\n };\n } else {\n this.hide();\n }\n }\n }, {\n key: \"makePay\",\n value: function makePay(e, info) {\n e.preventDefault();\n var payInfo = {\n items: [{\n id: info.id,\n title: info.title\n }],\n totalPrice: parseFloat(info.price)\n };\n payInfo.payMethod = this.$el.querySelector('.payment-field #payment').value;\n payInfo.phone = this.$el.querySelector('.phone-field #phone').value;\n payInfo.email = this.$el.querySelector('.email-field #email').value;\n console.log('Pay info: ', payInfo);\n }\n }]);\n\n return PayModal;\n}(_core_modal__WEBPACK_IMPORTED_MODULE_0__[\"Modal\"]);\n\n//# sourceURL=webpack:///./src/main/modals/pay.modal.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"PayModal\", function() { return PayModal; });\n/* harmony import */ var _core_modal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../core/modal */ \"./src/main/core/modal.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\nvar PayModal =\n/*#__PURE__*/\nfunction (_Modal) {\n _inherits(PayModal, _Modal);\n\n function PayModal(id, open, close) {\n var _this;\n\n _classCallCheck(this, PayModal);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(PayModal).call(this, id, open, close));\n\n if (_this.open != null) {\n _this.open.addEventListener('click', _this.openHandler.bind(_assertThisInitialized(_this)));\n\n _this.close.addEventListener('click', _this.closeHandler.bind(_assertThisInitialized(_this)));\n }\n\n return _this;\n }\n\n _createClass(PayModal, [{\n key: \"closeHandler\",\n value: function closeHandler() {\n this.$el.querySelector('form').onsubmit = null;\n }\n }, {\n key: \"openHandler\",\n value: function openHandler(e) {\n var _this2 = this;\n\n if (e.target.id === 'payOpen') {\n var targetInfo = e.target.parentNode.dataset;\n this.$el.querySelector('.title-field input').value = targetInfo.title;\n this.show();\n\n this.$el.querySelector('form').onsubmit = function (e) {\n _this2.makePay(e, targetInfo);\n };\n } else {\n this.hide();\n }\n }\n }, {\n key: \"makePay\",\n value: function makePay(e, info) {\n e.preventDefault();\n var payInfo = {\n items: [{\n id: info.id,\n title: info.title\n }],\n totalPrice: parseFloat(info.price)\n };\n payInfo.payMethod = this.$el.querySelector('.payment-field input').value;\n payInfo.phone = this.$el.querySelector('.phone-field input').value;\n payInfo.email = this.$el.querySelector('.email-field input').value;\n console.log('Pay info: ', payInfo);\n }\n }]);\n\n return PayModal;\n}(_core_modal__WEBPACK_IMPORTED_MODULE_0__[\"Modal\"]);\n\n//# sourceURL=webpack:///./src/main/modals/pay.modal.js?"); /***/ }), diff --git a/dist/views/assets/templates/modals/cart.pug b/dist/views/assets/templates/modals/cart.pug index 12478aa..fbdecfb 100644 --- a/dist/views/assets/templates/modals/cart.pug +++ b/dist/views/assets/templates/modals/cart.pug @@ -20,17 +20,17 @@ b Сумма к оплате span b#totalPrice 0 ₽ - form#purchaseInfo.modal-content__purchase.hide + form.modal-content__purchase.hide span Информация необходимая для оплаты .email-field label(for='email') Ваш E-mail - input#email(required='' type='text' name='email') + input(required='' type='text' name='email') .phone-field label(for="phone") Номер QIWI - input#phone(required='' type='text' name='phone') + input(required='' type='text' name='phone') .payment-field label(for='payment') Способ оплаты - select#payment(name='payment') + select(name='payment') option(value='qiwi' data-icon='../img/payments-icons/qiwi.svg') QIWI button.purchase-btn.waves-effect.btn Перейти к оплате // Cart Modal END diff --git a/dist/views/assets/templates/modals/pay.pug b/dist/views/assets/templates/modals/pay.pug index 4f5843b..f8721d2 100644 --- a/dist/views/assets/templates/modals/pay.pug +++ b/dist/views/assets/templates/modals/pay.pug @@ -9,20 +9,20 @@ h4.small-title Оплатить товар span#payClose.cart-close i.material-icons close - form#purchaseInfo(action='#') + form(action='#') .modal-content__fields .title-field label(for='title') Наименование - input#title(name='title' readonly) + input(name='title' readonly) .email-field label(for='email') Ваш E-mail - input#email(required='' type='text' name='email') + input(required='' type='text' name='email') .phone-field label(for="phone") Номер QIWI - input#phone(required='' type='text' name='phone') + input(required='' type='text' name='phone') .payment-field label(for='payment') Способ оплаты - select#payment(name='payment') + select(name='payment') option(value='qiwi' data-icon='../img/payments-icons/qiwi.svg') QIWI .modal-content__purchase button.purchase-btn.waves-effect.btn(type='submit' href='#') Перейти к оплате diff --git a/src/main/modals/cart.modal.js b/src/main/modals/cart.modal.js index 1841c1c..fce965c 100644 --- a/src/main/modals/cart.modal.js +++ b/src/main/modals/cart.modal.js @@ -19,7 +19,7 @@ export class CartModal extends Modal { openHandler() { this.removeItem != null ? this.list.addEventListener('click', this.removeItem.bind(this)) : false - this.makePay != null ? this.$el.querySelector('#purchaseInfo').addEventListener('submit', this.makePay.bind(this)) : false; + this.makePay != null ? this.$el.querySelector('form').addEventListener('submit', this.makePay.bind(this)) : false; this.list.innerHTML = ''; this.insertItems(this.list); } @@ -30,9 +30,9 @@ export class CartModal extends Modal { if (items.length == 0) { list.innerHTML = '

Вы не добавили ни один товар

'; - this.$el.querySelector('#purchaseInfo').classList.add('hide'); + this.$el.querySelector('form').classList.add('hide'); } else { - this.$el.querySelector('#purchaseInfo').classList.remove('hide'); + this.$el.querySelector('form').classList.remove('hide'); } items.forEach(item => this.list.innerHTML += ``); @@ -77,9 +77,9 @@ export class CartModal extends Modal { let totalPrice = 0; payInfo.items.forEach(item => totalPrice += parseFloat(item.price)); payInfo.totalPrice = Math.round(totalPrice * 100) / 100; - payInfo.payMethod = this.$el.querySelector('.payment-field #payment').value; - payInfo.phone = this.$el.querySelector('.phone-field #phone').value; - payInfo.email = this.$el.querySelector('.email-field #email').value; + payInfo.payMethod = this.$el.querySelector('.payment-field input').value; + payInfo.phone = this.$el.querySelector('.phone-field input').value; + payInfo.email = this.$el.querySelector('.email-field input').value; console.log('Pay info:', payInfo); } diff --git a/src/main/modals/pay.modal.js b/src/main/modals/pay.modal.js index 104854c..6700292 100644 --- a/src/main/modals/pay.modal.js +++ b/src/main/modals/pay.modal.js @@ -10,16 +10,16 @@ export class PayModal extends Modal { } closeHandler() { - this.$el.querySelector('#purchaseInfo').onsubmit = null; + this.$el.querySelector('form').onsubmit = null; } openHandler(e) { if (e.target.id === 'payOpen') { const targetInfo = e.target.parentNode.dataset; - this.$el.querySelector('.title-field #title').value = targetInfo.title; + this.$el.querySelector('.title-field input').value = targetInfo.title; this.show(); - this.$el.querySelector('#purchaseInfo').onsubmit = (e) => { + this.$el.querySelector('form').onsubmit = (e) => { this.makePay(e, targetInfo); } } else { @@ -37,9 +37,9 @@ export class PayModal extends Modal { }], totalPrice: parseFloat(info.price) } - payInfo.payMethod = this.$el.querySelector('.payment-field #payment').value; - payInfo.phone = this.$el.querySelector('.phone-field #phone').value; - payInfo.email = this.$el.querySelector('.email-field #email').value; + payInfo.payMethod = this.$el.querySelector('.payment-field input').value; + payInfo.phone = this.$el.querySelector('.phone-field input').value; + payInfo.email = this.$el.querySelector('.email-field input').value; console.log('Pay info: ', payInfo); }