fix payment UI UX
This commit is contained in:
1 parent
bb3ddd1610
commit
90931a5a64
6 files changed
+104
-10
No files matched your search
@@ -4,12 +4,13 @@
|
||||
let toast;
|
||||
function status(text){if(!toast){toast=document.createElement('div');toast.className='pay-copy-status';toast.setAttribute('role','status');document.body.append(toast);}toast.textContent=text;toast.hidden=false;setTimeout(()=>{toast.hidden=true;},3000);}
|
||||
async function copy(text){
|
||||
try{await navigator.clipboard.writeText(text);status('کپی شد');}
|
||||
try{await navigator.clipboard.writeText(text);status('کپی شد');return true;}
|
||||
catch{
|
||||
const dialog=document.createElement('dialog');dialog.className='pay-manual-copy';dialog.setAttribute('aria-label','کپی اطلاعات');
|
||||
const title=document.createElement('h2');title.textContent='متن را انتخاب و کپی کنید';const area=document.createElement('textarea');area.readOnly=true;area.value=text;
|
||||
const select=document.createElement('button');select.className='pay-button';select.textContent='انتخاب متن';select.onclick=()=>{area.focus();area.select();};
|
||||
const close=document.createElement('button');close.className='pay-button secondary';close.textContent='بستن';close.onclick=()=>dialog.close();dialog.append(title,area,select,close);document.body.append(dialog);dialog.addEventListener('close',()=>dialog.remove());dialog.showModal();area.focus();area.select();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
document.querySelectorAll('[data-copy]').forEach(button=>button.addEventListener('click',()=>copy(button.dataset.copy)));
|
||||
@@ -17,18 +18,26 @@ document.querySelectorAll('[data-notice-sms]').forEach(form=>form.addEventListen
|
||||
if(form.dataset.sending==='true'){event.preventDefault();return;}
|
||||
form.dataset.sending='true';const button=form.querySelector('button');button.disabled=true;button.textContent='در حال ثبت درخواست ارسال…';
|
||||
}));
|
||||
document.querySelectorAll('[data-share-link]').forEach(form=>form.addEventListener('submit',async event=>{
|
||||
document.querySelectorAll('[data-share-link]').forEach(form=>{
|
||||
const button=form.querySelector('button'),label=button.querySelector('span'),originalLabel=label.textContent;
|
||||
const feedback=form.querySelector('[role="status"]');
|
||||
form.addEventListener('submit',async event=>{
|
||||
event.preventDefault();
|
||||
const button=form.querySelector('button'),feedback=form.querySelector('[role="status"]');
|
||||
button.disabled=true;button.setAttribute('aria-busy','true');feedback.textContent='در حال آمادهسازی لینک…';
|
||||
// This AJAX form owns its button state; keep the generic navigation submit handler out.
|
||||
event.stopPropagation();
|
||||
if(button.disabled)return;
|
||||
button.disabled=true;button.setAttribute('aria-busy','true');label.textContent='در حال آمادهسازی لینک…';feedback.textContent='در حال آمادهسازی لینک…';
|
||||
try{
|
||||
const response=await fetch(form.action,{method:'POST',body:new FormData(form),credentials:'same-origin',cache:'no-store',headers:{'Accept':'application/json'}});
|
||||
if(!response.ok || !response.headers.get('Content-Type')?.includes('application/json'))throw new Error('share unavailable');
|
||||
const data=await response.json();
|
||||
await copy(data.url);feedback.textContent='لینک آماده است؛ میتوانید آن را برای دیگران ارسال کنید.';
|
||||
}catch{feedback.textContent='دریافت لینک ممکن نشد. دوباره تلاش کنید یا لینک پرداخت دریافتی را باز کنید.';}
|
||||
const copied=await copy(data.url);
|
||||
label.textContent=copied?'لینک کپی شد؛ کپی دوباره':originalLabel;
|
||||
feedback.textContent=copied?'لینک کوتاه کپی شد؛ میتوانید آن را برای دیگران ارسال کنید.':'لینک آماده است؛ کپی خودکار ممکن نشد. متن را از پنجرهٔ بازشده انتخاب و کپی کنید.';
|
||||
}catch{label.textContent=originalLabel;feedback.textContent='دریافت لینک ممکن نشد. دوباره تلاش کنید یا لینک پرداخت دریافتی را باز کنید.';}
|
||||
finally{button.disabled=false;button.removeAttribute('aria-busy');}
|
||||
}));
|
||||
});
|
||||
});
|
||||
const identifiers=document.querySelector('#identifier-accounts'),account=document.querySelector('#id_account'),deposit=document.querySelector('#id_deposit_id');
|
||||
if(identifiers && account && deposit){const ids=JSON.parse(identifiers.textContent).map(String);function update(){deposit.required=ids.includes(account.value);document.querySelector('#identifier-help').textContent=deposit.required?'این حساب شناسهدار است؛ شناسه واریز مشتری الزامی است.':'شناسه واریز در صورت اعلام بانک وارد شود.';}account.addEventListener('change',update);update();}
|
||||
const badge=document.querySelector('[data-payment-count]');
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
const input=document.querySelector('#id_paid_amount, #id_amount');if(!input)return;
|
||||
input.inputMode='numeric';
|
||||
const words=document.querySelector('#amount-words');
|
||||
if(words)input.setAttribute('aria-describedby',[input.getAttribute('aria-describedby'),words.id].filter(Boolean).join(' '));
|
||||
const small=['صفر','یک','دو','سه','چهار','پنج','شش','هفت','هشت','نه','ده','یازده','دوازده','سیزده','چهارده','پانزده','شانزده','هفده','هجده','نوزده'];
|
||||
const tens=['','','بیست','سی','چهل','پنجاه','شصت','هفتاد','هشتاد','نود'];
|
||||
const hundreds=['','صد','دویست','سیصد','چهارصد','پانصد','ششصد','هفتصد','هشتصد','نهصد'];
|
||||
|
||||
Reference in new issue
Block a user