Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/lpost.delivery/lpost/delivery/map/dist/ |
Upload File : |
(function (exports) { 'use strict'; function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } var Formatting = /*#__PURE__*/function () { function Formatting() { babelHelpers.classCallCheck(this, Formatting); } babelHelpers.createClass(Formatting, [{ key: "paymentMethod", value: function paymentMethod(isCard, isCash) { isCard = parseInt(isCard); isCash = parseInt(isCash); if (isCard == 1 && isCash == 1) { return BX.message("LPOST_DELIVERY_SOA_METHOD_PAY_CARD_OR_CASH"); } else if (isCash == 1 && isCard == 0) { return BX.message("LPOST_DELIVERY_SOA_METHOD_PAY_CASH"); } else if (isCash == 0 && isCard == 0) { return BX.message("LPOST_DELIVERY_SOA_METHOD_PAY_PREPAYMENT"); } } }, { key: "getDayLogistic", value: function getDayLogistic(days) {// dev } /** * @deprecated */ }, { key: "dateDayDelivery", value: function dateDayDelivery() { var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var selectList = BX.create('select'); var _iterator = _createForOfIteratorHelper(date), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var day = _step.value; BX.selectUtils.addNewOption(selectList, day, day); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } selectList.classList.add("input-date-day-delivery"); return selectList.outerHTML; } /** * @deprecated */ }, { key: "dateTimeDelivery", value: function dateTimeDelivery(times) { console.log(times); var selectList = BX.create('select'); BX.selectUtils.addNewOption(selectList, '_0', times['_0']); delete times['_0']; Object.keys(times).forEach(function (i) { BX.selectUtils.addNewOption(selectList, i, times[i]); }); selectList.classList.add("input-date-time-delivery"); return selectList.outerHTML; } }, { key: "timeWork", value: function timeWork(arTime, deliveryDay) { if (!arTime) return BX.message("LPOST_DELIVERY_SOA_TIME_CLOSE"); var date = new Date(); date.setDate(date.getDate() + deliveryDay); var days = BX.message("LPOST_DELIVERY_SOA_DAYS"); for (var i = 0; i < arTime.length; i++) { var day = arTime[i]; if (days.indexOf(day.Day) == date.getDay()) { var dayFrom = day.From.substring(0, day.From.length - 3); var dayTo = day.To.substring(0, day.To.length - 3); return dayFrom + " - " + dayTo; } } } }]); return Formatting; }(); function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); } function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } var ViewManager = /*#__PURE__*/function () { function ViewManager(parent, popupContent) { babelHelpers.classCallCheck(this, ViewManager); this.parent = parent; this.popupContent = popupContent; this.mode = "pvz"; this._onEvent(); this._resize(); } /** * @param mode (pvz || zone || zone_with_map) */ babelHelpers.createClass(ViewManager, [{ key: "switch", value: function _switch(mode) { this._setMode(mode); this._action(); } }, { key: "_setMode", value: function _setMode(mode) { this.mode = mode; } }, { key: "_getMode", value: function _getMode() { return this.mode; } }, { key: "_action", value: function _action() { if (this._getMode() === "pvz") { this._zoneAction("hide"); this._zoneWithMapAction('hide'); this._pvzAction("show"); } else if (this._getMode() === "zone") { this._pvzAction("hide"); this._zoneWithMapAction('hide'); this._zoneAction("show"); } else { this._zoneAction("hide"); this._zoneWithMapAction('show'); } } }, { key: "_pvzAction", value: function _pvzAction(action) { if (action === "show") { this.popupContent.querySelector(".lpost-pvz__list").classList.remove("_disabled"); this.popupContent.querySelector(".lpost-pvz__ctrl-view._pvz").classList.remove("_disabled"); this.popupContent.querySelector(".lpost-pvz__map").classList.remove("_disabled"); } else { this.popupContent.querySelector(".lpost-pvz__list").classList.add("_disabled"); this.popupContent.querySelector(".lpost-pvz__ctrl-view._pvz").classList.add("_disabled"); this.popupContent.querySelector(".lpost-pvz__map").classList.add("_disabled"); } } }, { key: "_zoneAction", value: function _zoneAction(action) { if (action === "show") { this.popupContent.querySelector(".lpost-courier__form").classList.remove("_disabled"); } else { this.popupContent.querySelector(".lpost-courier__form").classList.add("_disabled"); } } }, { key: "_zoneWithMapAction", value: function _zoneWithMapAction(action) { if (action === "show") { this.popupContent.querySelector(".lpost-pvz__return").classList.remove("_disabled"); this.popupContent.querySelector(".lpost-pvz__map").classList.remove("_disabled"); } else { this.popupContent.querySelector(".lpost-pvz__return").classList.add("_disabled"); this.popupContent.querySelector(".lpost-pvz__map").classList.add("_disabled"); } } }, { key: "_resize", value: function _resize() { if (window.innerWidth <= 576) { this.popupContent.classList.add("_mobile"); } else { this.popupContent.classList.remove("_mobile"); } } }, { key: "_onEvent", value: function _onEvent() { var _self = this; BX.bindDelegate(this.popupContent.querySelector(".lpost-pvz__ctrl-view._pvz"), 'click', { className: "ctrl-view_item" }, function (e) { var btns = BX.findParent(this, { className: 'lpost-pvz__ctrl-view' }).querySelectorAll(".ctrl-view_item"); var _iterator = _createForOfIteratorHelper$1(btns), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var btn = _step.value; btn.classList.remove("_active"); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } this.classList.add("_active"); if (this.dataset.view === "list") { _self.popupContent.querySelector(".lpost-pvz__list").classList.remove("_disabled"); } else { _self.popupContent.querySelector(".lpost-pvz__list").classList.add("_disabled"); } }); BX.bindDelegate(this.popupContent, "click", { className: "lpost-pvz__item" }, function (e) { var btns = BX.findParent(this, { className: 'lpost-pvz__list-wrapper' }).querySelectorAll(".lpost-pvz__item"); var _iterator2 = _createForOfIteratorHelper$1(btns), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var btn = _step2.value; btn.classList.remove("_active"); } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } this.classList.add("_active"); }); BX.bind(window, 'resize', BX.proxy(this._resize, this)); BX.bindDelegate(this.popupContent.querySelector(".lpost-pvz__list-search"), "keyup", { tagName: "input" }, function (e) { // delay ~ 1s dev? var value = new RegExp(this.value, 'i'); _self.parent.createList(_self.parent.listPoints.filter(function (item) { if (item.address.search(value) >= 0) { return true; } else { if (item.metro && item.metro.search(value) >= 0) { return true; } } })); }); } }]); return ViewManager; }(); var Balloon = /*#__PURE__*/function () { function Balloon(type, params) { babelHelpers.classCallCheck(this, Balloon); this.type = type; this.html = ""; this.params = params; } babelHelpers.createClass(Balloon, [{ key: "generate", value: function generate() { switch (this.type) { case "pvz": this.templatePvz(); break; case "zone": this.templateZone(); break; default: this.templateEmpty(); break; } return this; } }, { key: "templatePvz", value: function templatePvz() { this.html = "\n <div class=\"lpost-pvz__map-balloon\">\n <div class=\"map-balloon__address _bold\">".concat(this.params.address, "</div>\n <div class=\"map-balloon__sum\">").concat(BX.message("LPOST_DELIVERY_SOA_LABLE_DELIVERY_SUM") + "#SUM_FORMAT#", "</div>\n <div class=\"map-balloon__description\">#DESCRIPTION#</div>\n <div class=\"map-balloon__time-work\">").concat(BX.message("LPOST_DELIVERY_SOA_LABLE_TIME_WORK") + "#TIME_WORK#", "</div>\n <div class=\"map-balloon__has-fitting-room\">").concat(this.params.has_fitting_room ? BX.message('LPOST_DELIVERY_SOA_HAS_FITTING_ROOM') : BX.message('LPOST_DELIVERY_SOA_NOT_HAS_FITTING_ROOM'), "</div>\n <div class=\"map-balloon__method-pay\">#METHOD_PAY#</div>\n <div class=\"map-balloon__day-delivery\">").concat(BX.message("LPOST_DELIVERY_SOA_LABLE_DELIVERY_DAY") + "#DELIVERY_DAY#", "</div>\n <div class=\"map-balloon__button\" \n data-id=\"").concat(this.params.id, "\" \n data-address=\"").concat(this.params.address, "\" \n data-price=\"#SUM#\"\n data-day=\"#DELIVERY_DAY#\" \n data-coords=\"").concat(this.params.coords || false, "\">").concat(this.params.buttonText, "</div>\n </div>\n "); } }, { key: "templateZone", value: function templateZone() { var additional_properties_html = ''; if (IS_SHOW_ADDITIONAL_PROPERTIES) { additional_properties_html = "\n <div class=\"map-balloon__additional-field\">\n <label class=\"map-balloon__additional-label\">\n \u041A\u0432\u0430\u0440\u0442\u0438\u0440\u0430:<input class=\"map-balloon__additional-input lpost-delivery-input-flat\" data-input-for=\"flat\" placeholder=\"\u041D\u043E\u043C\u0435\u0440 \u043A\u0432\u0430\u0440\u0442\u0438\u0440\u044B\" type=\"number\" step=\"1\" min=\"0\">\n </label>\n </div>\n <div class=\"map-balloon__additional-field\">\n <label class=\"map-balloon__additional-label\">\n \u042D\u0442\u0430\u0436:<input class=\"map-balloon__additional-input lpost-delivery-input-floor\" data-input-for=\"floor\" placeholder=\"\u042D\u0442\u0430\u0436\" type=\"number\" step=\"1\" min=\"0\">\n </label>\n </div>\n <div class=\"map-balloon__additional-field\">\n <label class=\"map-balloon__additional-label\">\n \u041F\u043E\u0434\u044A\u0435\u0437\u0434:<input class=\"map-balloon__additional-input lpost-delivery-input-porch\" data-input-for=\"porch\" placeholder=\"\u041D\u043E\u043C\u0435\u0440 \u043F\u043E\u0434\u044A\u0435\u0437\u0434\u0430\" type=\"number\" step=\"1\" min=\"0\">\n </label>\n </div>\n <div class=\"map-balloon__additional-field\">\n <label class=\"map-balloon__additional-label\">\n \u0414\u043E\u043C\u043E\u0444\u043E\u043D:<input class=\"map-balloon__additional-input lpost-delivery-input-code\" data-input-for=\"code\" placeholder=\"\u041A\u043E\u0434 \u0434\u043E\u043C\u043E\u0444\u043E\u043D\u0430\" type=\"text\">\n </label>\n </div>\n "; } this.html = " \n <div class=\"lpost-pvz__map-balloon\">\n <div class=\"map-balloon__address _bold\">".concat(this.params.address, "</div>\n <div class=\"map-balloon__sum\">").concat(BX.message("LPOST_DELIVERY_SOA_LABLE_DELIVERY_SUM") + "#SUM_FORMAT#", "</div>\n <div class=\"map-balloon__method-pay\">#METHOD_PAY#</div>\n <div class=\"map-balloon__day-delivery\">").concat(BX.message("LPOST_DELIVERY_SOA_LABLE_DELIVERY_DAY") + "#DELIVERY_DAY#", "</div>\n <div class=\"map-balloon__date-delivery\">#DATE_DELIVERY_SELECTOR#</div>\n ").concat(additional_properties_html, "\n <div class=\"map-balloon__button\" \n data-id=\"").concat(this.params.id, "\"\n data-address=\"").concat(this.params.address, "\" \n data-price=\"#SUM#\"\n data-day=\"#DELIVERY_DAY#\"\n data-date-day-delivery=\"#DATE_DAY_DELIVERY#\"\n data-date-time-delivery=\"#DATE_TIME_DELIVERY#\"\n data-coords=\"").concat(this.params.coords || false, "\">").concat(this.params.buttonText, "</div>\n </div>\n "); } }, { key: "templateEmpty", value: function templateEmpty() { this.html = "\n <div class=\"lpost-pvz__map-balloon\">\n <div class=\"map-balloon__address\">".concat(this.params.buttonText, "</div>\n </div>"); } }, { key: "getHtml", value: function getHtml() { return this.html; } }]); return Balloon; }(); var DateDeliverySelector = /*#__PURE__*/function () { function DateDeliverySelector() { var dateList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; babelHelpers.classCallCheck(this, DateDeliverySelector); this._dateList = dateList; this._html = ""; } babelHelpers.createClass(DateDeliverySelector, [{ key: "getHtmlDaySelector", value: function getHtmlDaySelector() { var select = BX.create('select'); select.classList.add("lpost-delivery-day-selector", "input-date-day-delivery"); this._dateList.forEach(function (e, i) { BX.selectUtils.addNewOption(select, e.DateDelive, e.DateDelive); }); return select.outerHTML; } }, { key: "getHtmlTimeSelector", value: function getHtmlTimeSelector() { var valueList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var indexId = arguments.length > 1 ? arguments[1] : undefined; var select = BX.create('select'); select.classList.add("lpost-delivery-time-selector", 'input-date-time-delivery'); select.dataset.id = indexId; valueList.forEach(function (e, i) { BX.selectUtils.addNewOption(select, "".concat(e.TimeFrom, ",").concat(e.TimeTo), "".concat(e.TimeFrom, " - ").concat(e.TimeTo)); }); return select.outerHTML; } }, { key: "getHtmlTimeSelectorList", value: function getHtmlTimeSelectorList() { var _this = this; var selectHtmlList = ''; this._dateList.forEach(function (e, i) { selectHtmlList += _this.getHtmlTimeSelector(e.Intervals, e.DateDelive); }); return selectHtmlList; } }, { key: "getTimeDefaultValue", value: function getTimeDefaultValue() { return this._dateList[0]["Intervals"][0]["TimeFrom"] + "," + this._dateList[0]["Intervals"][0]["TimeTo"]; } }, { key: "getDayDefaultValue", value: function getDayDefaultValue() { return this._dateList[0]["DateDelive"]; } }, { key: "generate", value: function generate() { this._html = "\n <div class=\"lpost-delivery-date-selector\">\n <div class=\"lpost-delivery-date-selector__row\">\n ".concat(this.getHtmlDaySelector(), "\n </div>\n <div class=\"lpost-delivery-date-selector__row\">\n ").concat(this.getHtmlTimeSelectorList(), "\n </div>\n </div>\n "); return this; } }, { key: "getHtml", value: function getHtml() { return this._html; } }]); return DateDeliverySelector; }(); function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); } function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } var WidgetManager = /*#__PURE__*/function () { function WidgetManager(options, orderManager) { babelHelpers.classCallCheck(this, WidgetManager); babelHelpers.defineProperty(this, "prevDeliveryActiveId", false); this.orderManager = orderManager; this.Formatting = new Formatting(); this.options = options; } babelHelpers.createClass(WidgetManager, [{ key: "init", value: function init() { var _this = this; return new Promise(function (resolve, reject) { _this.fetchHtml().then(function (html) { document.querySelector("body").insertAdjacentHTML("beforeend", html); _this.options.ajaxURL = "/bitrix/components/lpost/delivery.widget/ajax.php"; _this.options.selectPoint = false; _this.popup = _this.createPopup(); _this.container = BX("bx-soa-delivery"); _this.popupContent = BX("lpost-pvz-popup").querySelector(".lpost-pvz"); _this.point_options = { iconLayout: 'default#image', iconImageHref: '/bitrix/themes/lpost.delivery/map-point.png', iconImageOffset: [-15, -42] }; _this.viewManager = new ViewManager(_this, _this.popupContent); _this.setSelectedDelivery(); _this.clearOldAddress(); _this.createMap(); _this._event(); resolve(_this); }); }); } }, { key: "fetchHtml", value: function fetchHtml() { return new Promise(function (resolve, reject) { BX.ajax({ url: '/bitrix/components/lpost/delivery.widget/ajax.php', data: { action: "show" }, method: "POST", onsuccess: function onsuccess(data) { return resolve(data); } }); }); } }, { key: "createMap", value: function createMap() { var _this2 = this; if (typeof ymaps === "undefined") return false; ymaps.ready(function (e) { _this2.map = new ymaps.Map(_this2.popupContent.querySelector(".lpost-pvz__map"), { center: [55.757741, 37.624725], zoom: 10, controls: [] }, { suppressMapOpenBlock: true }); _this2.objectManagerZone = new ymaps.ObjectManager({ clusterize: false, clusterDisableClickZoom: false, geoObjectOpenBalloonOnClick: true }); _this2.objectManagerPvz = new ymaps.ObjectManager({ clusterize: false, clusterDisableClickZoom: false, geoObjectOpenBalloonOnClick: false }); var popupContent = _this2.popupContent; _this2.yandeSearch = new ymaps.SuggestView('search-location', { provider: { suggest: function suggest(request, options) { // ���, ���� ������ ��������� � ��� �������, ������ ������ � �������������� var cityName = popupContent.querySelector("#search-location").placeholder; var array = []; return ymaps.suggest(cityName + ", " + request).then(function (items) { items.forEach(function (item) { if (item.displayName.indexOf(cityName) !== -1) { array.push(item); } }); return ymaps.vow.resolve(array); }); } } }); }); } }, { key: "getNumberZone", value: function getNumberZone(coords) { var _iterator = _createForOfIteratorHelper$2(this.polygons), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var polygon = _step.value; if (polygon.geometry.contains(coords)) { return { zoneNumber: polygon.properties.get("zoneNumber"), idPickup: polygon.properties.get("idPickup"), params: polygon.properties.get("params") }; } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } return false; } }, { key: "getCityID", value: function getCityID() { return this.orderManager.getLocationId(); } }, { key: "setSelectedDelivery", value: function setSelectedDelivery() { if (!this.orderManager) { return false; } this.selectedDelivery = this.orderManager.getSelectedDeliveryProfile(); if (!this.selectedDelivery) { return false; } this.showDeliveryButtonLpost(this.selectedDelivery.ID); } }, { key: "showDeliveryButtonLpost", value: function showDeliveryButtonLpost(deliveryId) { var deliveryList = this.popupContent.querySelectorAll(".lpost-pvz__ctrl-item._button"); var _iterator2 = _createForOfIteratorHelper$2(deliveryList), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var deliveryItem = _step2.value; deliveryItem.classList.remove("_active"); if (deliveryItem.dataset.id == deliveryId) { deliveryItem.classList.add("_active"); } } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } } }, { key: "createListPvz", value: function createListPvz(cityID) { var _self = this; new Promise(function (resolve, reject) { var json = _self._request({ fields: { cityID: cityID, action: "pvz" }, async: false, type: "html" }); resolve(JSON.parse(json)); }).then(function (data) { _self.removeZone(); _self.setRegionBlock(data.city.name); _self.listPoints = data['pvz_list']; _self.createList(_self.listPoints); _self.viewManager["switch"]("pvz"); if (_self.map) { _self.createPointsPvz(_self.listPoints); _self.map.setCenter([data.city.lat, data.city["long"]], 12); } }); } }, { key: "createListZone", value: function createListZone(cityID) { var _self = this; new Promise(function (resolve, reject) { var json = _self._request({ fields: { cityID: cityID, action: "zone" }, async: false, type: "html" }); resolve(JSON.parse(json)); }).then(function (data) { _self.removePointsPvz(); _self.removePointsZone(); _self.setRegionBlock(data.city.name); _self.removeZone(); _self.createZone(data.zone, data['id_pickup'], { isCard: data['is_card'], isCash: data['is_cash'], deliverySpeed: data['params'] ? data['params']['deliverySpeed'] : {} }); _self.viewManager["switch"]("zone"); _self.getDefaultCoords(data.city).then(function (data) { _self.map.setCenter(data.cityCoords, 12); if (data.geocode && data.geoObject) { var coords = data.geoObject.geometry.getCoordinates(); var dataZone = _self.getNumberZone(coords); if (dataZone) { _self.createPoint(coords, { address: data.geoObject.getAddressLine(), zoneNumber: dataZone['zoneNumber'], idPickup: dataZone['idPickup'], premiseNumber: dataZone ? data.geoObject.getPremiseNumber() : "", params: dataZone.params }, false); } } }); }); } }, { key: "getDefaultCoords", value: function getDefaultCoords(city) { return new Promise(BX.proxy(function (resolve, reject) { if (this.options.address) { ymaps.geocode(this.options.address).then(function (res) { resolve({ geocode: true, geoObject: res.geoObjects.get(0), cityCoords: [city.lat, city["long"]] }); }); } else { resolve({ geocode: false, cityCoords: [city.lat, city["long"]] }); } }, this)); } }, { key: "createZone", value: function createZone(zones, idPickup) { var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; if (!zones) return false; this.polygons = []; zones = zones.filter(function (a) { return typeof a.ZoneNumber == 'undefined'; }); var _iterator3 = _createForOfIteratorHelper$2(zones.reverse()), _step3; try { for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { var zone = _step3.value; var dataPolygon = JSON.parse("{" + zone.WKT + "}"); var arPolygonCoordinates = []; var _iterator4 = _createForOfIteratorHelper$2(dataPolygon.Coordinates), _step4; try { for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { var arItem = _step4.value; var arItemReverse = []; for (var key in arItem) { arItemReverse[key] = arItem[key].reverse(); } if (this.isMultiPolygon(arItemReverse)) { arPolygonCoordinates = arPolygonCoordinates.concat(this.createArPolygonFromMultiPolygon(arItemReverse)); } else { arPolygonCoordinates.push(arItemReverse); } } } catch (err) { _iterator4.e(err); } finally { _iterator4.f(); } var _iterator5 = _createForOfIteratorHelper$2(arPolygonCoordinates), _step5; try { for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { var polygon = _step5.value; var ymapsPolygon = new ymaps.Polygon([polygon], { zoneNumber: 1, idPickup: idPickup, params: data }, { fillColor: "#6699ff", interactivityModel: 'default#transparent', opacity: 0.3, zIndex: 100, zIndexHover: 100, interactiveZIndex: 1 }); this.polygons.push(ymapsPolygon); this.map.geoObjects.add(ymapsPolygon); } } catch (err) { _iterator5.e(err); } finally { _iterator5.f(); } } } catch (err) { _iterator3.e(err); } finally { _iterator3.f(); } } }, { key: "removeZone", value: function removeZone() { if (this.map && this.map.geoObjects) { this.map.geoObjects.removeAll(); } } }, { key: "removePointsPvz", value: function removePointsPvz(type) { if (this.objectManagerPvz) { this.objectManagerPvz.removeAll(); } } }, { key: "removePointsZone", value: function removePointsZone() { if (this.objectManagerZone) { return this.objectManagerZone.removeAll(); } } }, { key: "createPointsPvz", value: function createPointsPvz(data) { if (!this.map) return false; this.removePointsPvz(); var features = []; var _iterator6 = _createForOfIteratorHelper$2(data), _step6; try { for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { var item = _step6.value; if (!item['coord_lat'] || !item['coord_long']) { continue; } if (item.params) { if (item.params.deliverySpeed) { item.params.deliverySpeed.selected = "slow"; } } else { item.params = {}; } item.params.isCard = item.is_card; item.params.isCash = item.is_cash; features.push({ id: item.id_pickup, type: 'Feature', params: item.params, description: item.pickup_dop, timeWork: item.time_work, geometry: { type: 'Point', coordinates: [item['coord_lat'], item['coord_long']], radius: 100 }, properties: { balloonContent: new Balloon("pvz", { address: item.address, has_fitting_room: item.has_fitting_room === 'Y', id: item.id_pickup, buttonText: BX.message("LPOST_DELIVERY_SOA_MAP_BUTTON_CHOICE") }).generate().getHtml() }, options: this.point_options }); } } catch (err) { _iterator6.e(err); } finally { _iterator6.f(); } var collection = { type: 'FeatureCollection', features: features }; this.objectManagerPvz.add(collection); this.map.geoObjects.add(this.objectManagerPvz); } }, { key: "createPointPvz", value: function createPointPvz(item) { var deliverySpeed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "slow"; var id = deliverySpeed === "fast" ? item.params.deliverySpeed.fast : item.params.deliverySpeed.slow; item.params.isCard = item.is_card; item.params.isCash = item.is_cash; var object = { id: id, type: 'Feature', params: item.params, description: item.pickup_dop, timeWork: item.time_work, geometry: { type: 'Point', coordinates: [item['coord_lat'], item['coord_long']], radius: 100 }, properties: { balloonContent: new Balloon("pvz", { address: item.address, has_fitting_room: item.has_fitting_room === 'Y', id: id, buttonText: BX.message("LPOST_DELIVERY_SOA_MAP_BUTTON_CHOICE") }).generate().getHtml() }, options: this.point_options }; this.objectManagerPvz.add(object); } }, { key: "getDataPoint", value: function getDataPoint(id) { var _iterator7 = _createForOfIteratorHelper$2(this.listPoints), _step7; try { for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) { var item = _step7.value; if (item.params && item.params.deliverySpeed) { if (item.params.deliverySpeed.fast === id) { return item; } else if (item.params.deliverySpeed.slow === id) { return item; } } } } catch (err) { _iterator7.e(err); } finally { _iterator7.f(); } return false; } }, { key: "renderPointPvz", value: function renderPointPvz(objectId) { var _this3 = this; var open = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var geoObject = this.objectManagerPvz.objects.getById(objectId); if (geoObject) { this.setSumDeliveryPoint(geoObject, objectId).then(function () { if (open) { _this3.objectManagerPvz.objects.balloon.open(objectId); } }); } } }, { key: "createList", value: function createList(data) { var containerList = this.popupContent.querySelector(".lpost-pvz__list-wrapper"); BX.cleanNode(containerList); var _iterator8 = _createForOfIteratorHelper$2(data), _step8; try { for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) { var item = _step8.value; var content = BX.create({ tag: "div", attrs: { className: "list-item_content" }, children: [BX.create({ tag: "div", text: this.Formatting.timeWork(JSON.parse(item.time_work), item.day_logistic) }), BX.create({ tag: "div", text: item.pickup_dop }), BX.create({ tag: "div", attrs: { className: "lpost-pvz-list_button" }, dataset: { id: item.id_pickup, address: item.address, coords: item.coord_lat + "," + item.coord_long }, text: BX.message("LPOST_DELIVERY_SOA_MAP_BUTTON_CHOICE_PICK_UP") })] }); var title = BX.create({ tag: "div", attrs: { className: "lpost-pvz-list_title" }, text: item.address, children: [BX.create({ tag: "div", attrs: { className: "title_item _metro" }, text: item.metro }), BX.create({ tag: "div", attrs: { className: "title_item _address" }, text: item.address }), BX.create({ tag: "div", attrs: { className: "title_item _payment" }, html: this.Formatting.paymentMethod(item.is_card, item.is_cash) })] }); var elem = BX.create("div", { attrs: { className: "lpost-pvz__item" }, children: [title, content] }); containerList.append(elem); } } catch (err) { _iterator8.e(err); } finally { _iterator8.f(); } } }, { key: "setRegionBlock", value: function setRegionBlock(name) { this.popupContent.querySelector(".lpost-pvz__ctrl-item._location span:last-child").innerHTML = name; this.popupContent.querySelector("#search-location").placeholder = name; } }, { key: "getProfileActive", value: function getProfileActive() { var _this$selectedDeliver; var selectedDeliveryID = (_this$selectedDeliver = this.selectedDelivery) === null || _this$selectedDeliver === void 0 ? void 0 : _this$selectedDeliver.ID; if (!selectedDeliveryID) { return false; } return this.getDeliveryProfileById(selectedDeliveryID); } }, { key: "getProfileActiveId", value: function getProfileActiveId() { var _profile$ID; var profile = this.getProfileActive(); return (_profile$ID = profile["ID"]) !== null && _profile$ID !== void 0 ? _profile$ID : false; } }, { key: "isLpostProfile", value: function isLpostProfile() { var profileActive = this.orderManager.getSelectedDeliveryProfile(); if (!profileActive) { return false; } var _iterator9 = _createForOfIteratorHelper$2(this.orderManager.options.profiles), _step9; try { for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) { var profile = _step9.value; if (profile.ID === profileActive.ID) { return true; } } } catch (err) { _iterator9.e(err); } finally { _iterator9.f(); } return false; } }, { key: "getDeliveryProfileById", value: function getDeliveryProfileById(id) { var _iterator10 = _createForOfIteratorHelper$2(this.orderManager.options.profiles), _step10; try { for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) { var profile = _step10.value; if (profile.ID == id) { return profile; } } } catch (err) { _iterator10.e(err); } finally { _iterator10.f(); } return false; } }, { key: "isActiveDeliverySpeedBlock", value: function isActiveDeliverySpeedBlock() { if (this.deliverySpeedContainer) { return this.deliverySpeedContainer.classList.contains("_active"); } return false; } }, { key: "updateDeliveryProfileActive", value: function updateDeliveryProfileActive() { var deliveryList = this.popupContent.querySelectorAll(".lpost-pvz__ctrl-item._button"); var _iterator11 = _createForOfIteratorHelper$2(deliveryList), _step11; try { for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) { var deliveryItem = _step11.value; if (!BX("ID_DELIVERY_ID_" + deliveryItem.dataset.id) && !this.getDeliveryById(deliveryItem.dataset.id)) { deliveryItem.classList.add("_disabled"); // deliveryItem.remove(); } else { deliveryItem.classList.remove("_disabled"); } } } catch (err) { _iterator11.e(err); } finally { _iterator11.f(); } } //// }, { key: "getDeliveryById", value: function getDeliveryById(id) { var deliverys = document.querySelectorAll('[name="DELIVERY_ID"]'); for (var i = 0; i < deliverys.length; i++) { if (deliverys[i].value == id) { return deliverys[i]; } } return false; } }, { key: "getActiveProfileType", value: function getActiveProfileType() { var activeProfile = this.getProfileActive(); if (activeProfile && this.isProfileZone(activeProfile)) { return "zone"; } else { return "pvz"; } } }, { key: "isProfileZone", value: function isProfileZone(profile) { if (profile) return profile.CLASS_NAME.indexOf("Zone") >= 0;else return false; } }, { key: "isProfilePvz", value: function isProfilePvz(profile) { if (profile) return profile.CLASS_NAME.includes('\Lpost\Delivery\Handlers\Pvz') || profile.CLASS_NAME.includes('\\Lpost\\Delivery\\Handlers\\Pvz');else return false; } }, { key: "getProfilePvz", value: function getProfilePvz() { var _iterator12 = _createForOfIteratorHelper$2(this.orderManager.options.profiles), _step12; try { for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) { var profile = _step12.value; if (profile.CLASS_NAME.includes('\Lpost\Delivery\Handlers\Pvz') || profile.CLASS_NAME.includes('\\Lpost\\Delivery\\Handlers\\Pvz')) { return profile; } } } catch (err) { _iterator12.e(err); } finally { _iterator12.f(); } return false; } }, { key: "getProfileZone", value: function getProfileZone() { var _iterator13 = _createForOfIteratorHelper$2(this.orderManager.options.profiles), _step13; try { for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) { var profile = _step13.value; if (profile.CLASS_NAME.includes('\Lpost\Delivery\Handlers\Zone') || profile.CLASS_NAME.includes('\\Lpost\\Delivery\\Handlers\\Zone')) { return profile; } } } catch (err) { _iterator13.e(err); } finally { _iterator13.f(); } return false; } }, { key: "createPopup", value: function createPopup() { var popup = new BX.PopupWindow("lpost-pvz-popup", null, { content: document.querySelector('.lpost-pvz'), bindOnResize: false, zIndex: 0, autoHide: true, offsetTop: 1, offsetLeft: 0, resizable: true, className: '', lightShadow: true, closeIcon: "x", closeByEsc: true, params: {}, overlay: { backgroundColor: "#000", opacity: 80 }, events: { onAfterPopupShow: function onAfterPopupShow(e) {}, onPopupDestroy: function onPopupDestroy(e) {}, onPopupShow: function onPopupShow(e) {} } }); popup.setAnimation("scale"); return popup; } }, { key: "selectPoint", value: function selectPoint(event) { var profileActive = this.getProfileActive(), typeProfile = ''; if (this.isProfileZone(profileActive)) { typeProfile = 'zone'; if (document.querySelector("input[name=LPOST_ZONE_NUMBER_ID]")) { document.querySelector("input[name=LPOST_ZONE_NUMBER_ID]").value = event.target.dataset.id; } if (document.querySelector("input[name=LPOST_ZONE_ADDRESS]")) { document.querySelector("input[name=LPOST_ZONE_ADDRESS]").value = event.target.dataset.address; } if (document.querySelector(".lpost-zone__choice-address")) document.querySelector(".lpost-zone__choice-address").innerHTML = "<span>".concat(BX.message("LPOST_DELIVERY_SOA_COURIER_FORM_ADDRESS"), "</span><span>").concat(event.target.dataset.address, "</span>"); if (document.querySelector("input[name=LPOST_ZONE_PRICE]")) { document.querySelector("input[name=LPOST_ZONE_PRICE]").value = event.target.dataset.price; } if (document.querySelector("input[name=LPOST_ZONE_COORDS]")) { document.querySelector("input[name=LPOST_ZONE_COORDS]").value = event.target.dataset.coords; } if (document.querySelector("input[name=LPOST_ZONE_DAY]")) { document.querySelector("input[name=LPOST_ZONE_DAY]").value = event.target.dataset.day; } if (IS_SHOW_ADDITIONAL_PROPERTIES) { var flat = event.target.dataset.flat, floor = event.target.dataset.floor, porch = event.target.dataset.porch, code = event.target.dataset.code; if (typeof flat !== 'undefined') { if (document.querySelector("input[name=LPOST_ZONE_FLAT]")) { document.querySelector("input[name=LPOST_ZONE_FLAT]").value = flat; } this.orderManager.renderAdditionalField(flat, ADDITIONAL_PROPERTY_OPTION_CODES['FLAT']); } if (typeof floor !== 'undefined') { if (document.querySelector("input[name=LPOST_ZONE_FLOOR]")) { document.querySelector("input[name=LPOST_ZONE_FLOOR]").value = floor; } this.orderManager.renderAdditionalField(floor, ADDITIONAL_PROPERTY_OPTION_CODES['FLOOR']); } if (typeof porch !== 'undefined') { if (document.querySelector("input[name=LPOST_ZONE_PORCH]")) { document.querySelector("input[name=LPOST_ZONE_PORCH]").value = porch; } this.orderManager.renderAdditionalField(porch, ADDITIONAL_PROPERTY_OPTION_CODES['PORCH']); } if (typeof code !== 'undefined') { if (document.querySelector("input[name=LPOST_ZONE_CODE]")) { document.querySelector("input[name=LPOST_ZONE_CODE]").value = code; } this.orderManager.renderAdditionalField(code, ADDITIONAL_PROPERTY_OPTION_CODES['CODE']); } } if (event.target.dataset.dateDayDelivery) { document.querySelector("input[name=LPOST_ZONE_DATE_DAY_DELIVERY]").value = event.target.dataset.dateDayDelivery; } if (event.target.dataset.dateTimeDelivery) { document.querySelector("input[name=LPOST_ZONE_DATE_TIME_DELIVERY]").value = event.target.dataset.dateTimeDelivery; } } else { typeProfile = 'pvz'; if (this.isActiveDeliverySpeedBlock()) { document.querySelector("input[name=LPOST_PVZ_ID]").value = this.getActiveDeliverySpeedId(); } else { document.querySelector("input[name=LPOST_PVZ_ID]").value = event.target.dataset.id; } document.querySelector("input[name=LPOST_PVZ_PRICE]").value = event.target.dataset.price; if (document.querySelector(".lpost-pvz__choice-address")) document.querySelector(".lpost-pvz__choice-address").innerHTML = "<span>".concat(BX.message("LPOST_DELIVERY_SOA_COURIER_FORM_ADDRESS"), "</span><span>").concat(event.target.dataset.address, "</span>"); document.querySelector("input[name=LPOST_PVZ_ADDRESS]").value = event.target.dataset.address; document.querySelector("input[name=LPOST_PVZ_DAY]").value = event.target.dataset.day; } this.options.selectPoint = event.target.dataset.id; this.popup.close(); this.orderManager.renderPrice(event.target.dataset.price); this.orderManager.renderAddress(event.target.dataset.address); if (this.orderManager.isOrderAjaxComponent('sendRequest')) this.orderManager.refresh();else { if (typeProfile != '') { var selector = typeProfile == 'zone' ? 'input[name*="LPOST_PVZ_"]' : 'input[name*="LPOST_ZONE_"]'; var inputLpost = document.querySelectorAll(selector); for (var i = 0; i < inputLpost.length; i++) { inputLpost[i].value = ''; } if (typeProfile == 'pvz' && document.querySelector(".lpost-zone__choice-address")) document.querySelector(".lpost-zone__choice-address").innerHTML = "<span>".concat(BX.message("LPOST_DELIVERY_SOA_ADDRESS_NOT_SPECIFIED"), "</span>");else if (typeProfile == 'zone' && document.querySelector(".lpost-pvz__choice-address")) document.querySelector(".lpost-pvz__choice-address").innerHTML = "<span>".concat(BX.message("LPOST_DELIVERY_SOA_ADDRESS_NOT_SPECIFIED"), "</span>"); } } } }, { key: "getSumCalcDelivery", value: function getSumCalcDelivery(coords, pickupID) { var _this4 = this; return new Promise(function (resolve, reject) { BX.ajax.runAction("lpost:delivery.api.DeliveryCalculate.getCalcForWidget", { data: { pickupId: pickupID, coords: coords, profileId: _this4.getProfileActive().ID, profileType: _this4.getActiveProfileType() } }).then(function (response) { resolve(response.data); }); }); } }, { key: "setSumDeliveryPoint", value: function setSumDeliveryPoint(geoObject, idPickup) { var _this5 = this; return new Promise(function (resolve, reject) { if (geoObject.properties.balloonContent.indexOf("#") >= 0) { _this5.getSumCalcDelivery(geoObject.geometry.coordinates, idPickup).then(function (data) { if (!data) { reject("data empty"); } geoObject.properties.balloonContent = geoObject.properties.balloonContent.replace("#SUM_FORMAT#", data.sumFormat ? data.sumFormat : 0); geoObject.properties.balloonContent = geoObject.properties.balloonContent.replace("#SUM#", data.sum ? data.sum : 0); geoObject.properties.balloonContent = geoObject.properties.balloonContent.replace(/#DELIVERY_DAY#/g, data.day); geoObject.properties.balloonContent = geoObject.properties.balloonContent.replace("#DESCRIPTION#", geoObject.description ? geoObject.description : ""); if (geoObject.params.isCard || geoObject.params.isCash) { geoObject.properties.balloonContent = geoObject.properties.balloonContent.replace("#METHOD_PAY#", _this5.Formatting.paymentMethod(geoObject.params.isCard, geoObject.params.isCash)); } if (geoObject.timeWork) { geoObject.properties.balloonContent = geoObject.properties.balloonContent.replace("#TIME_WORK#", _this5.Formatting.timeWork(JSON.parse(geoObject.timeWork), data.day)); } if (IS_SHOW_COURIER_DATES) { if (data.dateDelivery.length > 0) { var dateDeliverySelector = new DateDeliverySelector(data.dateDelivery); geoObject.properties.balloonContent = geoObject.properties.balloonContent.replace("#DATE_DELIVERY_SELECTOR#", dateDeliverySelector.generate().getHtml()); geoObject.properties.balloonContent = geoObject.properties.balloonContent.replace("#DATE_DAY_DELIVERY#", dateDeliverySelector.getDayDefaultValue()); geoObject.properties.balloonContent = geoObject.properties.balloonContent.replace("#DATE_TIME_DELIVERY#", dateDeliverySelector.getTimeDefaultValue()); } } else { geoObject.properties.balloonContent = geoObject.properties.balloonContent.replace('#DATE_DAY_DELIVERY#', ''); geoObject.properties.balloonContent = geoObject.properties.balloonContent.replace('#DATE_TIME_DELIVERY#', ''); geoObject.properties.balloonContent = geoObject.properties.balloonContent.replace('#DATE_DELIVERY_SELECTOR#', ''); } resolve({ sum: data.sum, day: data.day }); }); } else { resolve(true); } }); } }, { key: "_request", value: function _request() { var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var result; BX.ajax({ url: this.options.ajaxURL, method: "POST", data: data.fields, dataType: data.type || "html", async: data.async, onsuccess: function onsuccess(response) { result = response; } }); return result; } }, { key: "removeDeliverySpeedContainer", value: function removeDeliverySpeedContainer() { if (this.isActiveDeliverySpeedBlock()) { this.deliverySpeedContainer.classList.remove("_active"); this.deliverySpeedContainer.querySelector("#delivery-type-slow").checked = true; } } }, { key: "createDeliverySpeedContainer", value: function createDeliverySpeedContainer(objectId) { this.removeDeliverySpeedContainer(); var objectManager = this.isProfileZone(this.getProfileActive()) ? this.objectManagerZone : this.objectManagerPvz; var geoObject = objectManager.objects.getById(objectId); if (geoObject && geoObject.params && geoObject.params.deliverySpeed) { if (geoObject.params.deliverySpeed.fast && geoObject.params.deliverySpeed.slow) { var objectFastId = geoObject.params.deliverySpeed.fast; var objectSlowId = geoObject.params.deliverySpeed.slow; this.deliverySpeedContainer = this.popupContent.querySelector(".lpost-pvz__ctrl-item._delivery-type"); this.deliverySpeedContainer.classList.add("_active"); this.deliverySpeedContainer.querySelector("#delivery-type-slow").dataset.idPickup = objectSlowId; this.deliverySpeedContainer.querySelector("#delivery-type-fast").dataset.idPickup = objectFastId; if (geoObject.params.deliverySpeed.selected === "fast") { this.deliverySpeedContainer.querySelector("#delivery-type-fast").checked = true; } else { this.deliverySpeedContainer.querySelector("#delivery-type-slow").checked = true; } } } } }, { key: "getDeliverySpeed", value: function getDeliverySpeed() { return this.deliverySpeedContainer.querySelector(".delivery-type__group input:checked").value; } }, { key: "getActiveDeliverySpeedId", value: function getActiveDeliverySpeedId() { return this.deliverySpeedContainer.querySelector(".delivery-type__group input:checked").dataset.idPickup; } }, { key: "reCreatePointZone", value: function reCreatePointZone() { var newPickupID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var object = this.objectManagerZone.objects.balloon.getData(); var dataZone = this.getNumberZone(object.geometry.coordinates); this.createPoint(object.geometry.coordinates, { address: object.geometry.address, premiseNumber: object.geometry.premiseNumber, zoneNumber: dataZone['zoneNumber'], idPickup: newPickupID || dataZone['idPickup'], params: object.params }, true); } }, { key: "createPoint", value: function createPoint(coords) { var content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var balloonOpen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; var properties = {}; var propertiesType = "zone"; if (content.premiseNumber && content.idPickup) { properties = { address: content.address, id: content.idPickup, coords: coords, buttonText: BX.message("LPOST_DELIVERY_SOA_MAP_BUTTON_CHOICE_ZONE") }; } else { if (Number.isInteger(content.zoneNumber)) { properties = { buttonText: BX.message("LPOST_DELIVERY_SOA_MAP_ADDRESS_EMPTY").replace("#ADDRESS#", content.address) }; } else { properties = { buttonText: BX.message("LPOST_DELIVERY_SOA_MAP_ADDRESS_OUTSIDE").replace("#ADDRESS#", content.address) }; } propertiesType = "notDelivery"; } this.objectManagerZone.add({ type: 'FeatureCollection', features: [{ id: content.idPickup, type: 'Feature', params: content.params, geometry: { type: 'Point', coordinates: coords, radius: 100, address: content.address, premiseNumber: content.premiseNumber }, properties: { balloonContent: new Balloon(propertiesType, properties).generate().getHtml() }, options: this.point_options }] }); this.map.geoObjects.add(this.objectManagerZone); var geoObject = this.objectManagerZone.objects.getById(content.idPickup); if (content.premiseNumber) { this.setSumDeliveryPoint(geoObject, content.idPickup).then(BX.proxy(function (data) { if (balloonOpen) { setTimeout(BX.proxy(function () { var _this6 = this; if (balloonOpen) { this.objectManagerZone.objects.balloon.open(content.idPickup).then(function (resolve) { _this6.renderingInformationFromTheBallon(); var map_balloon = BX("lpost-pvz-popup").querySelector('.lpost-pvz__map-balloon'); var input_day = map_balloon.querySelector('.input-date-day-delivery'), input_time = map_balloon.querySelector('.input-date-time-delivery'); BX.fireEvent(input_day, 'change'); BX.fireEvent(input_time, 'change'); }); this.createDeliverySpeedContainer(content.idPickup); } }, this), 5); var search_input = BX("lpost-pvz-popup").querySelector('#search-location'); if (!properties.address) { search_input.value = ''; } else if (search_input.value.trim() !== properties.address) { search_input.value = properties.address; } } }, this)); } else { if (balloonOpen) { this.objectManagerZone.objects.balloon.open(content.idPickup).then(this.renderingInformationFromTheBallon); BX("lpost-pvz-popup").querySelector('#search-location').value = ''; } } } }, { key: "renderingInformationFromTheBallon", value: function renderingInformationFromTheBallon() { BX("lpost-pvz-popup").querySelector('.lpost-pvz__view div.lpost-courier__form div.lpost-courier__form-info').innerHTML = BX("lpost-pvz-popup").querySelector('.lpost-pvz__map-balloon').innerHTML; } }, { key: "clearOldAddress", value: function clearOldAddress() { if (this.isLpostProfile() && this.prevDeliveryActiveId != this.getProfileActiveId()) { this.orderManager.renderAddress(""); } this.prevDeliveryActiveId = this.getProfileActiveId(); } }, { key: "_event", value: function _event() { var _this8 = this; var _self = this; if (typeof ymaps !== "undefined") { ymaps.ready(BX.proxy(function () { var _this7 = this; this.map.events.add('click', BX.proxy(function (e) { var objectId = e.get('objectId'); var profileActive = this.getProfileActive(); if (!objectId && this.isProfileZone(profileActive)) { _self.removeDeliverySpeedContainer(); _self.removePointsZone(); var coords = e.get('coords'); ymaps.geocode(coords).then(function (res) { var newObject = res.geoObjects.get(0); var dataZone = _self.getNumberZone(coords); if (dataZone && dataZone['params']['deliverySpeed']['selected']) { dataZone['params']['deliverySpeed']['selected'] = "slow"; } _self.createPoint(coords, { address: newObject.getAddressLine(), zoneNumber: dataZone['zoneNumber'], idPickup: dataZone['idPickup'], params: dataZone.params, premiseNumber: newObject.getPremiseNumber() }); }); } }, this)); this.objectManagerZone.events.add("click", BX.proxy(function (e) {// event click point zone }, this)); this.objectManagerPvz.objects.events.add("click", function (e) { var objectId = e.get('objectId'); _this7.renderPointPvz(objectId, true); _this7.createDeliverySpeedContainer(objectId); }); this.yandeSearch.events.add('select', BX.proxy(function (e) { ymaps.geocode(e.get('item').value, { results: 1 }).then(BX.proxy(function (res) { var geoObject = res.geoObjects.get(0); var coords = geoObject.geometry.getCoordinates(); var dataZone = this.getNumberZone(coords); this.removePointsZone(); this.createPoint(coords, { address: geoObject.getAddressLine(), zoneNumber: dataZone['zoneNumber'], idPickup: dataZone['idPickup'], premiseNumber: geoObject.getPremiseNumber(), params: dataZone.params }); }, this)); }, this), this); }, this)); } BX.bindDelegate(this.popupContent, "click", { className: "map-balloon__button" }, function (e) { return _this8.selectPoint(e); }); BX.bindDelegate(this.popupContent, "click", { className: "lpost-courier__form-btn-for-map" }, function () { _self.viewManager["switch"]("zone_with_map"); }); BX.bindDelegate(this.popupContent, "click", { className: "lpost-pvz__return" }, function () { _self.viewManager["switch"]("zone"); }); BX.bindDelegate(this.popupContent, "click", { className: "lpost-pvz-list_button" }, BX.proxy(function (e) { var coords = e.target.dataset.coords; var pickupID = e.target.dataset.id; this.getSumCalcDelivery(coords, pickupID).then(BX.proxy(function (data) { e.target.dataset.price = data.sum; e.target.dataset.day = data.day; this.selectPoint(e); }, this)); }, this)); BX.bindDelegate(document, 'click', { className: "lpost-pvz__popup-run" }, BX.proxy(function (e) { if (!this.getCityID()) { alert(BX.message('LPOST_DELIVERY_SOA_ALERT_WHEN_THERE_IS_NO_CITY_ID')); return false; } var typeProfile = e.target.classList.contains('lpost-zone__popup-open') ? 'zone' : 'pvz'; if (typeProfile == 'pvz') { var _this$selectedDeliver2; var profilePvz = this.getProfilePvz(); if ((_this$selectedDeliver2 = this.selectedDelivery) !== null && _this$selectedDeliver2 !== void 0 && _this$selectedDeliver2.ID && profilePvz && this.selectedDelivery.ID != profilePvz.ID) if (BX("ID_DELIVERY_ID_" + profilePvz.ID)) BX.fireEvent(BX("ID_DELIVERY_ID_" + profilePvz.ID), "click");else if (this.getDeliveryById(profilePvz.ID)) BX.fireEvent(this.getDeliveryById(profilePvz.ID), "click"); } else { var _this$selectedDeliver3; var profileZone = this.getProfileZone(); if ((_this$selectedDeliver3 = this.selectedDelivery) !== null && _this$selectedDeliver3 !== void 0 && _this$selectedDeliver3.ID && profileZone && this.selectedDelivery.ID != profileZone.ID) if (BX("ID_DELIVERY_ID_" + profileZone.ID)) BX.fireEvent(BX("ID_DELIVERY_ID_" + profileZone.ID), "click");else if (this.getDeliveryById(profileZone.ID)) BX.fireEvent(this.getDeliveryById(profileZone.ID), "click"); } this.updateDeliveryProfileActive(); this.setSelectedDelivery(); var profileActive = this.getProfileActive(); if (this.isProfileZone(profileActive)) { this.createListZone(this.getCityID()); } else { this.createListPvz(this.getCityID(), this.selectedDelivery.ID); } this.popup.show(); }, this)); BX.bindDelegate(this.popupContent, 'change', { className: "delivery-type__group" }, BX.proxy(function (e) { var deliverySpeedId = this.getActiveDeliverySpeedId(); var objectManager; if (this.isProfileZone(this.getProfileActive())) { objectManager = this.objectManagerZone; } else { objectManager = this.objectManagerPvz; } var object = objectManager.objects.balloon.getData(); object.params.deliverySpeed.selected = this.getDeliverySpeed(); if (this.isProfileZone(this.getProfileActive())) { this.reCreatePointZone(deliverySpeedId); } else { objectManager.remove(object); this.createPointPvz(this.getDataPoint(deliverySpeedId), object.params.deliverySpeed.selected); this.renderPointPvz(deliverySpeedId, true); } }, this)); BX.bindDelegate(this.popupContent, 'click', { className: "lpost-pvz__ctrl-item" }, function (e) { if (!BX.hasClass(this, "_button")) return false; var deliveryID = this.dataset.id; _self.removeDeliverySpeedContainer(); if (deliveryID != _self.selectedDelivery.ID) { if (BX("ID_DELIVERY_ID_" + deliveryID)) BX.fireEvent(BX("ID_DELIVERY_ID_" + deliveryID), "click");else if (_self.getDeliveryById(deliveryID)) BX.fireEvent(_self.getDeliveryById(deliveryID), "click"); _self.setSelectedDelivery(); var profile = _self.getDeliveryProfileById(_self.selectedDelivery.ID); if (_self.isProfileZone(profile)) { _self.removePointsPvz(); _self.createListZone(_self.getCityID()); } else { _self.removePointsZone(); _self.createListPvz(_self.getCityID()); } } }); BX.bindDelegate(this.popupContent, 'change', { className: "input-date-day-delivery" }, function (e) { e.preventDefault(); var view = BX.findParent(e.target, { className: 'lpost-pvz__view' }); view.querySelectorAll('.map-balloon__button').forEach(function (elem) { return elem.dataset.dateDayDelivery = e.target.value; }); view.querySelectorAll('.input-date-day-delivery').forEach(function (elem) { return elem.value = e.target.value; }); }); BX.bindDelegate(this.popupContent, 'change', { className: "input-date-time-delivery" }, function (e) { e.preventDefault(); var view = BX.findParent(e.target, { className: 'lpost-pvz__view' }); view.querySelectorAll('.map-balloon__button').forEach(function (elem) { return elem.dataset.dateTimeDelivery = e.target.value; }); view.querySelectorAll('.input-date-time-delivery').forEach(function (elem) { return elem.value = e.target.value; }); }); BX.bindDelegate(this.popupContent, 'change', { className: "map-balloon__additional-input" }, function (e) { e.preventDefault(); var field_name = e.target.dataset.inputFor; var view = BX.findParent(e.target, { className: 'lpost-pvz__view' }); view.querySelectorAll('.map-balloon__button').forEach(function (elem) { elem.dataset[field_name] = e.target.value; }); view.querySelectorAll(".lpost-delivery-input-".concat(field_name)).forEach(function (elem) { elem.value = e.target.value; }); }); BX.bindDelegate(this.popupContent, 'change', { className: "lpost-delivery-day-selector" }, function (e) { return _this8.handlerChangeDaySelector(e); }); BX.addCustomEvent('onAjaxSuccess', function (data) { _this8.setSelectedDelivery(); _this8.clearOldAddress(); _this8.orderManager.displayInputAddressContainer(_this8.isLpostProfile()); }); //// BX.bindDelegate(document, 'change', { tagName: 'input', 'attr': { 'name': 'DELIVERY_ID' } }, function (e) { _this8.setSelectedDelivery(); _this8.clearOldAddress(); _this8.orderManager.displayInputAddressContainer(_this8.isLpostProfile()); }); } }, { key: "handlerChangeDaySelector", value: function handlerChangeDaySelector(event) { this.hideAllTimeSelector(); this.showTimeSelector(event.target.value); } }, { key: "hideAllTimeSelector", value: function hideAllTimeSelector() { this.popupContent.querySelectorAll(".lpost-delivery-time-selector").forEach(function (e) { e.style.display = "none"; }); } }, { key: "showTimeSelector", value: function showTimeSelector(selectorId) { var timeSelectList = this.popupContent.querySelectorAll(".lpost-delivery-time-selector[data-id='".concat(selectorId, "']")); timeSelectList.forEach(function (e, i) { e.style.display = "block"; }); } }, { key: "isEqualCoords", value: function isEqualCoords(arCoords1, arCoords2) { return arCoords1[0] === arCoords2[0] && arCoords1[1] === arCoords2[1]; } }, { key: "isMultiPolygon", value: function isMultiPolygon() { var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var first = array[0]; var last = array[array.length - 1]; return !this.isEqualCoords(first, last); } }, { key: "createArPolygonFromMultiPolygon", value: function createArPolygonFromMultiPolygon() { var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var arPolygon = []; var firstKey = 0; var coords = []; for (var key in array) { if (Number(key) === firstKey) { coords = array[key]; continue; } if (this.isEqualCoords(coords, array[key])) { arPolygon.push(array.slice(firstKey, Number(key) + 1)); firstKey = Number(key) + 1; coords = array[firstKey]; } } return arPolygon; } }]); return WidgetManager; }(); exports.WidgetManager = WidgetManager; }((this.window = this.window || {}))); //# sourceMappingURL=app.bundle.js.map