| Server IP : 38.190.208.107 / Your IP : 216.73.217.21 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.2/wp-content/themes/blocksy/static/js/frontend/woocommerce/ |
Upload File : |
import $ from 'jquery'
import ctEvents from 'ct-events'
let timeoutId = null
let focusedEl = null
const handleInputChange = (input, e) => {
if (input.closest('tr')) {
;[...input.closest('tr').querySelectorAll('.quantity input')]
.filter((i) => i !== input)
.map((input) => (input.value = e.target.value))
}
if (document.activeElement === input) {
focusedEl = input.name
}
if (input.closest('.ct-cart-auto-update')) {
if (timeoutId) {
clearTimeout(timeoutId)
}
timeoutId = setTimeout(function () {
$("[name='update_cart']").trigger('click')
}, 300)
}
}
$(document.body).on('updated_cart_totals', () => {
setTimeout(() => {
;[...document.querySelectorAll(`[name="${focusedEl}"]`)].map((el) => {
el.focus()
})
}, 500)
ctEvents.trigger('blocksy:frontend:init')
})
$(document.body).on('updated_checkout', (_, data) => {
if (!data?.fragments?.['.woocommerce-checkout-review-order-table']) {
return
}
const node = document.createElement('div')
node.innerHTML = data.fragments['.woocommerce-checkout-review-order-table']
if ([...node.querySelectorAll('.cart_item')].length) {
node.remove()
return
}
window.location.reload()
})
export const mount = (el, { event }) => {
if (el.matches('input')) {
handleInputChange(el, event)
return
}
if (
!el.classList.contains('ct-increase') &&
!el.classList.contains('ct-decrease')
) {
return
}
const singleQuantity = el.parentNode
const input = singleQuantity.querySelector('input')
const properValue = parseFloat(input.value, 10) || 0
if (el.classList.contains('ct-increase')) {
const max = input.getAttribute('max')
? parseFloat(input.getAttribute('max'), 0) || Infinity
: Infinity
input.value =
properValue < max
? Math.round(
(properValue + parseFloat(input.step || '1')) * 100
) / 100
: max
}
if (el.classList.contains('ct-decrease')) {
const min = input.getAttribute('min')
? Math.round(parseFloat(input.getAttribute('min'), 0) * 100) / 100
: 0
input.value =
properValue > min
? Math.round(
(properValue - parseFloat(input.step || '1')) * 100
) / 100
: min
}
$(input).trigger('change')
$(input).trigger('input')
input.dispatchEvent(new Event('input', { bubbles: true }))
if (input.closest('tr')) {
;[...input.closest('tr').querySelectorAll('.quantity input')]
.filter((i) => i !== input)
.map((i) => (i.value = input.value))
}
}