Solid results and dependable reporting. A couple of features took time to learn, but the support team made it easy.
Add Your Heading Text Here
shortcodes emit this script twice, so the flag below stops
// the second copy re-binding a picker that is already wired up.
[].slice.call(document.querySelectorAll('.at-form__stars')).forEach(function (wrap) {
if (wrap.getAttribute('data-at-stars-done')) return;
wrap.setAttribute('data-at-stars-done', '1');
var stars = [].slice.call(wrap.querySelectorAll('.at-form__star'));
var input = wrap.querySelector('.at-form__rating-val');
function setActive(n) {
stars.forEach(function (b, i) {
b.classList.toggle('is-active', i < n);
});
if (input) input.value = n;
}
stars.forEach(function (btn) {
var val = parseInt(btn.getAttribute('data-value'), 10);
btn.addEventListener('click', function () { setActive(val); });
btn.addEventListener('mouseenter', function () {
stars.forEach(function (b, i) { b.classList.toggle('at-form__star--hover', i < val); });
});
btn.addEventListener('focus', function () {
stars.forEach(function (b, i) { b.classList.toggle('at-form__star--hover', i < val); });
});
});
wrap.addEventListener('mouseleave', function () {
stars.forEach(function (b) { b.classList.remove('at-form__star--hover'); });
});
wrap.addEventListener('focusout', function (e) {
if (!wrap.contains(e.relatedTarget)) {
stars.forEach(function (b) { b.classList.remove('at-form__star--hover'); });
}
});
});
}());