Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into WP-130
Browse files Browse the repository at this point in the history
  • Loading branch information
DEMAxx committed Dec 26, 2024
2 parents ef7f6ad + 08d26f5 commit 2c7b18e
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Actions/GenerateBarcodeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/Actions/GenerateWaybillAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
49 changes: 49 additions & 0 deletions src/Frontend/CheckoutMapShortcode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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'))
Expand Down
9 changes: 9 additions & 0 deletions src/Frontend/CheckoutMapShortcode/style/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2c7b18e

Please sign in to comment.