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); diff --git a/src/Frontend/CheckoutMapShortcode/index.js b/src/Frontend/CheckoutMapShortcode/index.js index 5b16432..91a0589 100644 --- a/src/Frontend/CheckoutMapShortcode/index.js +++ b/src/Frontend/CheckoutMapShortcode/index.js @@ -6,6 +6,11 @@ import { debounce } from 'lodash'; const billingCityInput = $('#billing_city'); const shippingCityInput = $('#shipping_city'); +const buttonNormalSize = 160; +const smallFontAttribute = 'aria-small'; + +let needChange; +let isNormalSize; let widget = null; let el; @@ -62,16 +67,60 @@ const debouncedCheckoutUpdate = debounce(() => { $(document.body).trigger('update_checkout'); }, 500); +const initChanges = () => { + needChange = false; + isNormalSize = true; +}; + +const resizeObserver = new ResizeObserver(entries => { + for (const entry of entries) { + if(!('contentRect' in entry) || !('target' in entry) ) { + continue; + } + + if (entry.contentRect.width < buttonNormalSize) { + if (isNormalSize) { + isNormalSize = false; + needChange = true; + } + } else if (!isNormalSize) { + isNormalSize = true; + needChange = true; + } + + if(!needChange){ + continue; + } + + if (isNormalSize) { + if (entry.target.hasAttribute(smallFontAttribute)) { + entry.target.removeAttribute(smallFontAttribute); + } + } else if (!entry.target.hasAttribute(smallFontAttribute)) { + entry.target.setAttribute(smallFontAttribute, ''); + } + + 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')) diff --git a/src/Frontend/CheckoutMapShortcode/style/main.scss b/src/Frontend/CheckoutMapShortcode/style/main.scss index 03798d9..85deb05 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; + + &[aria-small]{ + font-size: 10px; + } + + & a { + color: inherit; + font-size: inherit; + } } .cdek-office-info {