Files
exodevices/medcenterstart/legacy/v3/business-hours.js
T
yuriy.pandClaude Opus 5.5 a61d53962a Add after-hours callbacks and persistent ad attribution to all four landings
- The callback dialog switches its copy outside business hours
  (shared/business-hours.ts); such leads get a "нерабочее время" tag,
  a marker in the deal name and a line in the note in amoCRM.
- utm_*, yclid and gclid are read on page load and kept for 30 days
  (src/lib/attribution.ts), last tagged visit wins, and are sent with
  every lead.
- The callback dialog is rebuilt: focus trap, focus return, phone
  masking and a full-number check.
- fitnes drops the floating MobileCta; header and mobile bars follow
  the new dialog state in the other three.
- Add the latest design mockups under legacy/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 20:53:40 +06:00

105 lines
3.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function(){
'use strict';
if (window.EXOBusinessHours) return;
var CONFIG = Object.freeze({
timeZone: 'Europe/Samara',
workDays: ['Mon','Tue','Wed','Thu','Fri'],
openMinutes: 9 * 60,
closeMinutes: 18 * 60,
label: 'Пн–Пт, 09:00–18:00',
phone: '+7 927 789-60-71'
});
function currentParts(){
try {
var parts = new Intl.DateTimeFormat('en-US', {
timeZone: CONFIG.timeZone,
weekday: 'short',
hour: '2-digit',
minute: '2-digit',
hourCycle: 'h23'
}).formatToParts(new Date());
var out = {};
parts.forEach(function(p){ if (p.type !== 'literal') out[p.type] = p.value; });
return { weekday: out.weekday, hour: Number(out.hour), minute: Number(out.minute) };
} catch (e) {
var d = new Date();
return { weekday: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][d.getDay()], hour: d.getHours(), minute: d.getMinutes() };
}
}
function isOpen(){
var p = currentParts();
var minutes = p.hour * 60 + p.minute;
return CONFIG.workDays.indexOf(p.weekday) !== -1 && minutes >= CONFIG.openMinutes && minutes < CONFIG.closeMinutes;
}
function applyModalState(){
var modal = document.getElementById('exoCallbackModal');
if (!modal) return;
var title = modal.querySelector('#exoCallbackTitle');
var intro = modal.querySelector('.exo-callback__intro');
var submit = modal.querySelector('#exoCallbackSubmit');
var open = isOpen();
modal.dataset.businessHoursState = open ? 'open' : 'closed';
if (open) {
if (title) title.textContent = 'Перезвоним вам';
if (intro) intro.textContent = 'Оставьте имя и телефон — наш специалист свяжется с вами и ответит на вопросы.';
if (submit && !submit.disabled) submit.textContent = 'Жду звонка →';
} else {
if (title) title.textContent = 'Мы сейчас не на связи';
if (intro) intro.textContent = 'Оставьте имя и телефон — перезвоним в ближайшее рабочее время.';
if (submit && !submit.disabled) submit.textContent = 'Перезвоните мне →';
}
}
function openCallbackFromTel(sourceLink){
applyModalState();
var trigger = document.querySelector('[data-exo-callback-open], .btn--call, .header-call');
if (trigger && trigger !== sourceLink) {
trigger.dispatchEvent(new MouseEvent('click', { bubbles:true, cancelable:true, view:window }));
return true;
}
var modal = document.getElementById('exoCallbackModal');
if (modal) {
if ('hidden' in modal) modal.hidden = false;
modal.classList.add('is-open');
modal.setAttribute('aria-hidden','false');
document.body.classList.add('exo-callback-open');
var phone = document.getElementById('exoCallbackPhone');
setTimeout(function(){ if (phone) phone.focus(); }, 60);
return true;
}
return false;
}
document.addEventListener('click', function(event){
var link = event.target.closest && event.target.closest('a[href^="tel:"]');
if (!link || isOpen()) return;
event.preventDefault();
event.stopPropagation();
openCallbackFromTel(link);
}, true);
document.addEventListener('click', function(event){
var trigger = event.target.closest && event.target.closest('[data-exo-callback-open], .btn--call, .header-call');
if (trigger) applyModalState();
}, true);
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', applyModalState, { once:true });
} else {
applyModalState();
}
window.EXOBusinessHours = Object.freeze({
config: CONFIG,
isOpen: isOpen,
applyModalState: applyModalState,
openCallbackFromTel: openCallbackFromTel,
state: function(){ return isOpen() ? 'open' : 'closed'; }
});
})();