$(document).ready(function () { new WOW().init(); $('.phone').mask("+7 (999) 999-99-99",{autoclear:false}); $('.password').focus(function(){ $(this).attr("type","text"); }); $('.password').blur(function(){ $(this).attr("type","password"); }); new dateDropper({ defaultDate:true, selector:'.input_date', format:'dd.mm.y', lang:'ru', expandable:true, expandedDefault:true, startFromMonday:true }); document.querySelectorAll('.copy-phone').forEach(span=>{ span.addEventListener('click',function(){ const phone=this.getAttribute('data-phone'); const user=this.getAttribute('data-user'); const baseDomain='лучшие-мастера74.рф'; const currentPath=window.location.pathname+window.location.search+window.location.hash; const cleanUrl=`https://${baseDomain}${currentPath}`; const copyText=`Это номер с сайта ${cleanUrl}: ${formatPhoneNumber(phone)} ${user}`; const icon=this.querySelector('i.fa-copy'); icon.classList.add('shake'); setTimeout(()=>icon.classList.remove('shake'),500); navigator.clipboard.writeText(copyText).then(()=>{ const notification=this.nextElementSibling; notification.textContent=`${formatPhoneNumber(phone)}`; notification.classList.add('show'); notification.style.display='inline-block'; this.style.display='none'; }).catch(err=>console.error('Ошибка копирования:',err)); }); }); (function(){ const balloonQueue=[]; function showBalloon(target,text){ const balloon=document.createElement('div'); balloon.className='copy-balloon'; balloon.textContent=text; document.body.appendChild(balloon); const rect=target.getBoundingClientRect(); balloon.style.left=(rect.left+rect.width/2-balloon.offsetWidth/2)+'px'; balloon.style.top=(rect.top+window.scrollY)+'px'; balloonQueue.push(balloon); setTimeout(()=>balloon.classList.add('show'),50); setTimeout(()=>{ balloon.classList.remove('show'); setTimeout(()=>{ document.body.removeChild(balloon); const index=balloonQueue.indexOf(balloon); if(index>-1) balloonQueue.splice(index,1); },300); },10000); } function attachCopyClick(button){ button.addEventListener('click',function(){ const textToCopy=this.getAttribute('data-copy'); if(!textToCopy) return; navigator.clipboard.writeText(textToCopy).then(()=>showBalloon(this,'Скопировано!')).catch(err=>console.error('Ошибка копирования:',err)); }); } document.querySelectorAll('.copy-click').forEach(attachCopyClick); })(); }); function formatPhoneNumber(phone){ return phone.replace(/^(\+7)(\d{3})(\d{3})(\d{4})$/,'$1 $2 $3 $4'); } function FormSend(result_id,form_id,url){ const old_title=$("#"+result_id).html(); $("#"+result_id).closest(".btn").removeClass("btn-primary").addClass("btn-light"); $("#"+result_id).html(" Загрузка"); $.ajax({ url:url, type:"POST", dataType:"html", data:$("#"+form_id).serialize(), success:function(response){ $("#"+result_id).html(response); }, error:function(){ $("#"+result_id).closest(".btn").removeClass("btn-light").addClass("btn-danger"); $("#"+result_id).html("Ошибка при отправке формы"); } }); setTimeout(()=>{ $("#"+result_id).html(old_title); $("#"+result_id).closest(".btn").removeClass("btn-danger btn-light").addClass("btn-primary"); },5000); } function commentFocus(el,orderId,dbId,mainId){ el.rows=5; const counter=document.getElementById(`counter_${orderId}_${dbId}_${mainId}`); counter.style.opacity="1"; counter.style.maxHeight="40px"; el.placeholder=""; } function commentBlur(el,orderId,dbId,mainId){ if(el.value.trim()==="") el.rows=1; const counter=document.getElementById(`counter_${orderId}_${dbId}_${mainId}`); counter.style.opacity="0"; counter.style.maxHeight="0"; el.placeholder="Ответить..."; el.style.boxShadow=''; } function commentHandler(el,orderId,dbId,mainId){ let text=el.value.replace(/m2/gi,'м²').replace(/m3/gi,'м³'); el.value=text; const len=text.length; const counter=document.getElementById(`count_${orderId}_${dbId}_${mainId}`); counter.innerText=len; const btn=document.getElementById(`btn_send_${orderId}_${dbId}_${mainId}`); if(btn) btn.classList.toggle("d-none",len<5); if(document.activeElement===el){ if(len<=5 || len===4000) el.style.boxShadow='0 0 6px 2px #dc3545'; else if(len>=6 && len<=1000) el.style.boxShadow='0 0 6px 2px #28a745'; else if(len>=1001 && len<=3999) el.style.boxShadow='0 0 6px 2px #fd7e14'; else el.style.boxShadow=''; } else el.style.boxShadow=''; el.style.transition='box-shadow 0.25s ease'; } let debounceTimer,lastCheckedEmail=''; function checkUniqEmail(emailInput){ const login=emailInput.value.trim(); const emailHelp=$('#emailHelp'); const progressBtn=$('#progress_register').closest(".btn"); if(!login){ emailHelp.removeClass("d-none alert-success mt-2").addClass("d-block alert alert-danger mt-2").html("Поле email обязательно к заполнению."); progressBtn.addClass("d-none").removeClass("d-block"); return; } if(login===lastCheckedEmail) return; lastCheckedEmail=login; emailHelp.removeClass("d-none alert-success alert-danger").addClass("d-block").html('Проверка...'); progressBtn.addClass("d-none").removeClass("d-block"); clearTimeout(debounceTimer); debounceTimer=setTimeout(()=>{ $.ajax({ url:"/ajax", type:"GET", data:{func:'check_uniq',login:login}, dataType:"json", success:function(data){ if(data.success){ emailHelp.removeClass("alert-danger").addClass("alert alert-success mt-2").html("Email свободен"); progressBtn.addClass("d-block").removeClass("d-none"); } else{ emailHelp.removeClass("alert-success").addClass("alert alert-danger mt-2").html(data.message); progressBtn.addClass("d-none").removeClass("d-block"); } }, error:function(){ emailHelp.removeClass("alert-success").addClass("alert alert-danger mt-2").html("Ошибка сервера, попробуйте позже."); progressBtn.addClass("d-none").removeClass("d-block"); } }); },600); } $(document).ready(function(){ $('input[name="email"]').on('input',function(){ checkUniqEmail(this); }); }); document.addEventListener("DOMContentLoaded",function(){ var tooltipTriggerList=[].slice.call(document.querySelectorAll("[data-bs-toggle='tooltip']")); tooltipTriggerList.map(function(tooltipTriggerEl){ return new bootstrap.Tooltip(tooltipTriggerEl); }); });