| @@ -7,12 +7,36 @@ | ||
| 7 | 7 | const $dropdown = $wrapper.find(".basalam-orders-fetch-dropdown"); |
| 8 | 8 | $dropdown.toggle(); |
| 9 | 9 | }); |
| 10 | 10 | |
| 11 | + // Toggle product synchronization options from the split-button arrow. | |
| 12 | + $(document).on("click", ".basalam-product-sync-arrow-btn", function (e) { | |
| 13 | + e.preventDefault(); | |
| 14 | + e.stopPropagation(); | |
| 15 | + | |
| 16 | + const $btn = $(this); | |
| 17 | + const $wrapper = $btn.closest(".basalam-product-sync-wrapper"); | |
| 18 | + const $dropdown = $wrapper.find(".basalam-product-sync-dropdown"); | |
| 19 | + const isOpen = $dropdown.is(":visible"); | |
| 20 | + | |
| 21 | + $(".basalam-product-sync-dropdown").hide(); | |
| 22 | + $(".basalam-product-sync-arrow-btn").attr("aria-expanded", "false"); | |
| 23 | + | |
| 24 | + if (!isOpen) { | |
| 25 | + $dropdown.show(); | |
| 26 | + $btn.attr("aria-expanded", "true"); | |
| 27 | + } | |
| 28 | + }); | |
| 29 | + | |
| 11 | 30 | // Close dropdown when clicking outside |
| 12 | 31 | $(document).on("click", function (e) { |
| 13 | 32 | if (!$(e.target).closest(".basalam-orders-fetch-wrapper").length) { |
| 14 | 33 | $(".basalam-orders-fetch-dropdown").hide(); |
| 34 | + } | |
| 35 | + | |
| 36 | + if (!$(e.target).closest(".basalam-product-sync-wrapper").length) { | |
| 37 | + $(".basalam-product-sync-dropdown").hide(); | |
| 38 | + $(".basalam-product-sync-arrow-btn").attr("aria-expanded", "false"); | |
| 15 | 39 | } |
| 16 | 40 | }); |
| 17 | 41 | |
| 18 | 42 | // Fetch orders with default 7 days |