| |
| |
| |
| |
|
|
| class AuthDialog { |
| constructor() { |
| this.createStyles(); |
| } |
|
|
| createStyles() { |
| const styles = ` |
| .auth-dialog-overlay { |
| position: fixed; |
| top: 0; |
| left: 0; |
| width: 100%; |
| height: 100%; |
| background: rgba(0, 0, 0, 0.8); |
| backdrop-filter: blur(5px); |
| display: flex; |
| align-items: center; |
| justify-content: center; |
| z-index: 15000; |
| animation: auth-dialog-fade-in 0.3s ease-out; |
| } |
| |
| .auth-dialog-box { |
| background: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 100%); |
| border: 2px solid #333; |
| border-radius: 12px; |
| padding: 30px; |
| max-width: 400px; |
| width: 90%; |
| box-shadow: |
| 0 20px 40px rgba(0, 0, 0, 0.5), |
| 0 0 0 1px rgba(255, 255, 255, 0.1), |
| inset 0 1px 0 rgba(255, 255, 255, 0.1); |
| animation: auth-dialog-slide-up 0.3s ease-out; |
| text-align: center; |
| } |
| |
| .auth-dialog-header { |
| color: #e0e0e0; |
| font-size: 18px; |
| font-weight: 600; |
| margin-bottom: 8px; |
| padding-bottom: 15px; |
| border-bottom: 1px solid #333; |
| } |
| |
| .auth-dialog-message { |
| color: #b0b0b0; |
| font-size: 16px; |
| line-height: 1.5; |
| margin-bottom: 25px; |
| margin-top: 15px; |
| } |
| |
| .auth-dialog-button { |
| background: linear-gradient(135deg, #0ea5e9, #0284c7); |
| border: none; |
| color: white; |
| padding: 12px 24px; |
| border-radius: 8px; |
| font-size: 14px; |
| font-weight: 600; |
| cursor: pointer; |
| transition: all 0.3s ease; |
| box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3); |
| min-width: 100px; |
| } |
| |
| .auth-dialog-button:hover { |
| background: linear-gradient(135deg, #0284c7, #0369a1); |
| transform: translateY(-2px); |
| box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4); |
| } |
| |
| .auth-dialog-button:active { |
| transform: translateY(0); |
| } |
| |
| @keyframes auth-dialog-fade-in { |
| from { |
| opacity: 0; |
| } |
| to { |
| opacity: 1; |
| } |
| } |
| |
| @keyframes auth-dialog-slide-up { |
| from { |
| opacity: 0; |
| transform: translateY(30px) scale(0.9); |
| } |
| to { |
| opacity: 1; |
| transform: translateY(0) scale(1); |
| } |
| } |
| `; |
|
|
| |
| if (!document.getElementById('auth-dialog-styles')) { |
| const styleElement = document.createElement('style'); |
| styleElement.id = 'auth-dialog-styles'; |
| styleElement.textContent = styles; |
| document.head.appendChild(styleElement); |
| } |
| } |
|
|
| show(options = {}) { |
| const { |
| title = 'ข้อความจาก chahuadev.com', |
| message = 'กรุณาล็อกอินก่อนใช้งาน', |
| buttonText = 'ตกลง' |
| } = options; |
|
|
| |
| this.hide(); |
|
|
| |
| const overlay = document.createElement('div'); |
| overlay.className = 'auth-dialog-overlay'; |
| overlay.id = 'auth-dialog-overlay'; |
|
|
| |
| const dialog = document.createElement('div'); |
| dialog.className = 'auth-dialog-box'; |
|
|
| dialog.innerHTML = ` |
| <div class="auth-dialog-header">${title}</div> |
| <div class="auth-dialog-message">${message}</div> |
| <button class="auth-dialog-button" onclick="authDialog.hide()">${buttonText}</button> |
| `; |
|
|
| overlay.appendChild(dialog); |
| document.body.appendChild(overlay); |
|
|
| |
| overlay.addEventListener('click', (e) => { |
| if (e.target === overlay) { |
| this.hide(); |
| } |
| }); |
|
|
| |
| const escapeHandler = (e) => { |
| if (e.key === 'Escape') { |
| this.hide(); |
| document.removeEventListener('keydown', escapeHandler); |
| } |
| }; |
| document.addEventListener('keydown', escapeHandler); |
| } |
|
|
| hide() { |
| const overlay = document.getElementById('auth-dialog-overlay'); |
| if (overlay) { |
| overlay.style.animation = 'auth-dialog-fade-in 0.2s ease-out reverse'; |
| setTimeout(() => { |
| overlay.remove(); |
| }, 200); |
| } |
| } |
| } |
|
|
| |
| window.authDialog = new AuthDialog(); |