From 34a875505c170316dba94343a5c005f4f652edc8 Mon Sep 17 00:00:00 2001 From: Stas Demin Date: Fri, 20 Dec 2024 16:39:18 +0300 Subject: [PATCH 01/10] fix: checkout pvz button styles fix for different themes --- src/Frontend/CheckoutMapShortcode/style/main.scss | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Frontend/CheckoutMapShortcode/style/main.scss b/src/Frontend/CheckoutMapShortcode/style/main.scss index 03798d9..c92b45b 100644 --- a/src/Frontend/CheckoutMapShortcode/style/main.scss +++ b/src/Frontend/CheckoutMapShortcode/style/main.scss @@ -21,6 +21,17 @@ white-space: nowrap; margin-bottom: 10px; margin-top: 10px; + + & a { + color: inherit; + font-size: inherit; + } + + @media only screen and (max-width: 400px){ + .open-pvz-btn { + font-size: 10px; + } + } } .cdek-office-info { From 3e93393b4e40d1fed36bc41198e95852f3ff4670 Mon Sep 17 00:00:00 2001 From: Stas Demin Date: Sun, 22 Dec 2024 10:14:05 +0300 Subject: [PATCH 02/10] fix: media query fix --- src/Frontend/CheckoutMapShortcode/style/main.scss | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Frontend/CheckoutMapShortcode/style/main.scss b/src/Frontend/CheckoutMapShortcode/style/main.scss index c92b45b..954c8ac 100644 --- a/src/Frontend/CheckoutMapShortcode/style/main.scss +++ b/src/Frontend/CheckoutMapShortcode/style/main.scss @@ -28,9 +28,7 @@ } @media only screen and (max-width: 400px){ - .open-pvz-btn { - font-size: 10px; - } + font-size: 10px; } } From 7cb37dc870fb87b9db1a5f95f7e7735b68dba0c8 Mon Sep 17 00:00:00 2001 From: Stas Demin Date: Tue, 24 Dec 2024 12:57:39 +0300 Subject: [PATCH 03/10] fix: pvz button block size check and font-size change --- src/Frontend/CheckoutMapShortcode/index.js | 51 ++++++++++++++++++- .../CheckoutMapShortcode/style/main.scss | 9 ---- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/src/Frontend/CheckoutMapShortcode/index.js b/src/Frontend/CheckoutMapShortcode/index.js index 5b16432..1b67f7d 100644 --- a/src/Frontend/CheckoutMapShortcode/index.js +++ b/src/Frontend/CheckoutMapShortcode/index.js @@ -6,6 +6,10 @@ import { debounce } from 'lodash'; const billingCityInput = $('#billing_city'); const shippingCityInput = $('#shipping_city'); +const buttonNormalSize = 200; + +let needChange; +let isNormalSize; let widget = null; let el; @@ -62,19 +66,64 @@ const debouncedCheckoutUpdate = debounce(() => { $(document.body).trigger('update_checkout'); }, 500); +const initChanges = () => { + needChange = false; + isNormalSize = true; +} + +const resizeObserver = new ResizeObserver(entries => { + for (let entry of entries) { + if(entry.contentRect){ + const targetNode = entry.target; + + if(entry.contentRect.width < buttonNormalSize){ + if(isNormalSize){ + isNormalSize = false; + needChange = true; + } + }else{ + if(!isNormalSize){ + isNormalSize = true; + needChange = true; + } + } + + if(targetNode && needChange) { + targetNode.style.fontSize = isNormalSize ? '14px' : '10px'; + needChange = false; + } + } + } +}); + $(document.body) .on('input', '#billing_city, #billing_postcode, #shipping_city, #shipping_postcode', debouncedCheckoutUpdate) .on('updated_checkout', () => { + const targetNode = document.querySelector('.open-pvz-btn'); + if (widget !== null) { console.debug('[CDEK-MAP] Clearing widget selection'); widget.clearSelection(); } + + if(targetNode) { + initChanges(); + resizeObserver.observe(targetNode); + } }) .on('change', '.shipping_method', - () => $(document.body).trigger('update_checkout')) + () => { + $(document.body).trigger('update_checkout') + const targetNode = document.querySelector('.open-pvz-btn'); + + if(targetNode) { + initChanges(); + resizeObserver.observe(targetNode); + } + }) .on('click', '.open-pvz-btn', null, (e) => { el = e.target.tagName === 'A' ? $(e.target.parentElement) : $(e.target); closeMap(el); diff --git a/src/Frontend/CheckoutMapShortcode/style/main.scss b/src/Frontend/CheckoutMapShortcode/style/main.scss index 954c8ac..03798d9 100644 --- a/src/Frontend/CheckoutMapShortcode/style/main.scss +++ b/src/Frontend/CheckoutMapShortcode/style/main.scss @@ -21,15 +21,6 @@ white-space: nowrap; margin-bottom: 10px; margin-top: 10px; - - & a { - color: inherit; - font-size: inherit; - } - - @media only screen and (max-width: 400px){ - font-size: 10px; - } } .cdek-office-info { From cb2ddbc3864ae5d95c766610eb141261dcd0fc4b Mon Sep 17 00:00:00 2001 From: Stas Demin Date: Tue, 24 Dec 2024 12:59:11 +0300 Subject: [PATCH 04/10] fix: font sizes as constants --- src/Frontend/CheckoutMapShortcode/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Frontend/CheckoutMapShortcode/index.js b/src/Frontend/CheckoutMapShortcode/index.js index 1b67f7d..ea45485 100644 --- a/src/Frontend/CheckoutMapShortcode/index.js +++ b/src/Frontend/CheckoutMapShortcode/index.js @@ -7,6 +7,8 @@ import { debounce } from 'lodash'; const billingCityInput = $('#billing_city'); const shippingCityInput = $('#shipping_city'); const buttonNormalSize = 200; +const baseFontSize = 14; +const smallFontSize = 10; let needChange; let isNormalSize; @@ -89,7 +91,7 @@ const resizeObserver = new ResizeObserver(entries => { } if(targetNode && needChange) { - targetNode.style.fontSize = isNormalSize ? '14px' : '10px'; + targetNode.style.fontSize = (isNormalSize ? baseFontSize : smallFontSize) + 'px'; needChange = false; } } From 2d982eaf7a75d350b4bfba2b89a3bb18fac34de5 Mon Sep 17 00:00:00 2001 From: Stas Demin Date: Tue, 24 Dec 2024 13:10:32 +0300 Subject: [PATCH 05/10] fix: font sizes change as css class --- src/Frontend/CheckoutMapShortcode/index.js | 15 +++++++++++---- src/Frontend/CheckoutMapShortcode/style/main.scss | 9 +++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Frontend/CheckoutMapShortcode/index.js b/src/Frontend/CheckoutMapShortcode/index.js index ea45485..2e417b9 100644 --- a/src/Frontend/CheckoutMapShortcode/index.js +++ b/src/Frontend/CheckoutMapShortcode/index.js @@ -6,9 +6,8 @@ import { debounce } from 'lodash'; const billingCityInput = $('#billing_city'); const shippingCityInput = $('#shipping_city'); -const buttonNormalSize = 200; -const baseFontSize = 14; -const smallFontSize = 10; +const buttonNormalSize = 160; +const smallFontClass = 'small-open-pvz-btn'; let needChange; let isNormalSize; @@ -91,7 +90,15 @@ const resizeObserver = new ResizeObserver(entries => { } if(targetNode && needChange) { - targetNode.style.fontSize = (isNormalSize ? baseFontSize : smallFontSize) + 'px'; + if(isNormalSize){ + if(targetNode.classList.contains(smallFontClass)){ + targetNode.classList.remove(smallFontClass); + } + }else{ + if(!targetNode.classList.contains(smallFontClass)){ + targetNode.classList.add(smallFontClass); + } + } needChange = false; } } diff --git a/src/Frontend/CheckoutMapShortcode/style/main.scss b/src/Frontend/CheckoutMapShortcode/style/main.scss index 03798d9..9cbb2d9 100644 --- a/src/Frontend/CheckoutMapShortcode/style/main.scss +++ b/src/Frontend/CheckoutMapShortcode/style/main.scss @@ -21,6 +21,15 @@ white-space: nowrap; margin-bottom: 10px; margin-top: 10px; + + &.small-open-pvz-btn { + font-size: 10px; + } + + & a { + color: inherit; + font-size: inherit; + } } .cdek-office-info { From 7800a6c88c17b9ac8281beed314ef6fec789762a Mon Sep 17 00:00:00 2001 From: Stas Demin Date: Tue, 24 Dec 2024 13:11:29 +0300 Subject: [PATCH 06/10] fix: code style fix --- src/Frontend/CheckoutMapShortcode/index.js | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Frontend/CheckoutMapShortcode/index.js b/src/Frontend/CheckoutMapShortcode/index.js index 2e417b9..af11c02 100644 --- a/src/Frontend/CheckoutMapShortcode/index.js +++ b/src/Frontend/CheckoutMapShortcode/index.js @@ -70,32 +70,32 @@ const debouncedCheckoutUpdate = debounce(() => { const initChanges = () => { needChange = false; isNormalSize = true; -} +}; const resizeObserver = new ResizeObserver(entries => { for (let entry of entries) { - if(entry.contentRect){ + if (entry.contentRect) { const targetNode = entry.target; - if(entry.contentRect.width < buttonNormalSize){ - if(isNormalSize){ + if (entry.contentRect.width < buttonNormalSize) { + if (isNormalSize) { isNormalSize = false; needChange = true; } - }else{ - if(!isNormalSize){ + } else { + if (!isNormalSize) { isNormalSize = true; needChange = true; } } - if(targetNode && needChange) { - if(isNormalSize){ - if(targetNode.classList.contains(smallFontClass)){ + if (targetNode && needChange) { + if (isNormalSize) { + if (targetNode.classList.contains(smallFontClass)) { targetNode.classList.remove(smallFontClass); } - }else{ - if(!targetNode.classList.contains(smallFontClass)){ + } else { + if (!targetNode.classList.contains(smallFontClass)) { targetNode.classList.add(smallFontClass); } } @@ -118,21 +118,21 @@ $(document.body) widget.clearSelection(); } - if(targetNode) { + if (targetNode) { initChanges(); resizeObserver.observe(targetNode); } }) .on('change', '.shipping_method', () => { - $(document.body).trigger('update_checkout') + $(document.body).trigger('update_checkout'); const targetNode = document.querySelector('.open-pvz-btn'); - if(targetNode) { + if (targetNode) { initChanges(); resizeObserver.observe(targetNode); } - }) + }) .on('click', '.open-pvz-btn', null, (e) => { el = e.target.tagName === 'A' ? $(e.target.parentElement) : $(e.target); closeMap(el); From 63f9f828043917bebf510687ca1c2a56fc251f92 Mon Sep 17 00:00:00 2001 From: Stas Demin Date: Tue, 24 Dec 2024 13:24:48 +0300 Subject: [PATCH 07/10] fix: change class to attr --- src/Frontend/CheckoutMapShortcode/index.js | 10 +++++----- src/Frontend/CheckoutMapShortcode/style/main.scss | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Frontend/CheckoutMapShortcode/index.js b/src/Frontend/CheckoutMapShortcode/index.js index af11c02..853332f 100644 --- a/src/Frontend/CheckoutMapShortcode/index.js +++ b/src/Frontend/CheckoutMapShortcode/index.js @@ -7,7 +7,7 @@ import { debounce } from 'lodash'; const billingCityInput = $('#billing_city'); const shippingCityInput = $('#shipping_city'); const buttonNormalSize = 160; -const smallFontClass = 'small-open-pvz-btn'; +const smallFontAttribute = 'aria-small'; let needChange; let isNormalSize; @@ -91,12 +91,12 @@ const resizeObserver = new ResizeObserver(entries => { if (targetNode && needChange) { if (isNormalSize) { - if (targetNode.classList.contains(smallFontClass)) { - targetNode.classList.remove(smallFontClass); + if (targetNode.hasAttribute(smallFontAttribute)) { + targetNode.removeAttribute(smallFontAttribute); } } else { - if (!targetNode.classList.contains(smallFontClass)) { - targetNode.classList.add(smallFontClass); + if (!targetNode.hasAttribute(smallFontAttribute)) { + targetNode.setAttribute(smallFontAttribute, ''); } } needChange = false; diff --git a/src/Frontend/CheckoutMapShortcode/style/main.scss b/src/Frontend/CheckoutMapShortcode/style/main.scss index 9cbb2d9..85deb05 100644 --- a/src/Frontend/CheckoutMapShortcode/style/main.scss +++ b/src/Frontend/CheckoutMapShortcode/style/main.scss @@ -22,7 +22,7 @@ margin-bottom: 10px; margin-top: 10px; - &.small-open-pvz-btn { + &[aria-small]{ font-size: 10px; } From 9db016f2678feea748bbcb5010f04338b4b9de82 Mon Sep 17 00:00:00 2001 From: Stas Demin Date: Wed, 25 Dec 2024 11:02:25 +0300 Subject: [PATCH 08/10] fix: code logic fixed --- src/Frontend/CheckoutMapShortcode/index.js | 59 +++++++++------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/src/Frontend/CheckoutMapShortcode/index.js b/src/Frontend/CheckoutMapShortcode/index.js index 853332f..f87087b 100644 --- a/src/Frontend/CheckoutMapShortcode/index.js +++ b/src/Frontend/CheckoutMapShortcode/index.js @@ -73,35 +73,34 @@ const initChanges = () => { }; const resizeObserver = new ResizeObserver(entries => { - for (let entry of entries) { - if (entry.contentRect) { - const targetNode = entry.target; - - if (entry.contentRect.width < buttonNormalSize) { - if (isNormalSize) { - isNormalSize = false; - needChange = true; - } - } else { - if (!isNormalSize) { - isNormalSize = true; - needChange = true; - } + for (const entry of entries) { + if(!entry.contentRect || !entry.target) { + continue; + } + + if (entry.contentRect.width < buttonNormalSize) { + if (isNormalSize) { + isNormalSize = false; + needChange = true; } + } else if (!isNormalSize) { + isNormalSize = true; + needChange = true; + } + + if(!needChange){ + continue; + } - if (targetNode && needChange) { - if (isNormalSize) { - if (targetNode.hasAttribute(smallFontAttribute)) { - targetNode.removeAttribute(smallFontAttribute); - } - } else { - if (!targetNode.hasAttribute(smallFontAttribute)) { - targetNode.setAttribute(smallFontAttribute, ''); - } - } - needChange = false; + if (isNormalSize) { + if (entry.target.hasAttribute(smallFontAttribute)) { + entry.target.removeAttribute(smallFontAttribute); } + } else if (!entry.target.hasAttribute(smallFontAttribute)) { + entry.target.setAttribute(smallFontAttribute, ''); } + + needChange = false; } }); @@ -124,15 +123,7 @@ $(document.body) } }) .on('change', '.shipping_method', - () => { - $(document.body).trigger('update_checkout'); - const targetNode = document.querySelector('.open-pvz-btn'); - - if (targetNode) { - initChanges(); - resizeObserver.observe(targetNode); - } - }) + () => $(document.body).trigger('update_checkout')) .on('click', '.open-pvz-btn', null, (e) => { el = e.target.tagName === 'A' ? $(e.target.parentElement) : $(e.target); closeMap(el); From 1f56c55c00a736801f073cb916a9259398cbc42d Mon Sep 17 00:00:00 2001 From: Stas Demin Date: Wed, 25 Dec 2024 15:18:21 +0300 Subject: [PATCH 09/10] fix: check is contentRect and target in entry object --- src/Frontend/CheckoutMapShortcode/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Frontend/CheckoutMapShortcode/index.js b/src/Frontend/CheckoutMapShortcode/index.js index f87087b..91a0589 100644 --- a/src/Frontend/CheckoutMapShortcode/index.js +++ b/src/Frontend/CheckoutMapShortcode/index.js @@ -74,7 +74,7 @@ const initChanges = () => { const resizeObserver = new ResizeObserver(entries => { for (const entry of entries) { - if(!entry.contentRect || !entry.target) { + if(!('contentRect' in entry) || !('target' in entry) ) { continue; } From 08d26f5865d98cbd7db3fe079b7908bbd804e443 Mon Sep 17 00:00:00 2001 From: AlexV Date: Thu, 26 Dec 2024 15:07:05 +0700 Subject: [PATCH 10/10] fix: ini_set string --- src/Actions/GenerateBarcodeAction.php | 4 ++-- src/Actions/GenerateWaybillAction.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Actions/GenerateBarcodeAction.php b/src/Actions/GenerateBarcodeAction.php index 38eeb65..f6363aa 100644 --- a/src/Actions/GenerateBarcodeAction.php +++ b/src/Actions/GenerateBarcodeAction.php @@ -30,9 +30,9 @@ public function __invoke(string $uuid): array ini_set( 'max_execution_time', - 30 + + (string)(30 + Config::GRAPHICS_FIRST_SLEEP + - Config::GRAPHICS_TIMEOUT_SEC * Config::MAX_REQUEST_RETRIES_FOR_GRAPHICS, + Config::GRAPHICS_TIMEOUT_SEC * Config::MAX_REQUEST_RETRIES_FOR_GRAPHICS), ); try { diff --git a/src/Actions/GenerateWaybillAction.php b/src/Actions/GenerateWaybillAction.php index b5b8a02..edfd70e 100644 --- a/src/Actions/GenerateWaybillAction.php +++ b/src/Actions/GenerateWaybillAction.php @@ -27,9 +27,9 @@ public function __invoke(string $orderUuid): array ini_set( 'max_execution_time', - 30 + + (string)(30 + Config::GRAPHICS_FIRST_SLEEP + - Config::GRAPHICS_TIMEOUT_SEC * Config::MAX_REQUEST_RETRIES_FOR_GRAPHICS, + Config::GRAPHICS_TIMEOUT_SEC * Config::MAX_REQUEST_RETRIES_FOR_GRAPHICS), ); $order = $api->orderGet($orderUuid);