Sada8888 commited on
Commit
54244d0
·
verified ·
1 Parent(s): 61aad51

Update templates/image_studio.html

Browse files
Files changed (1) hide show
  1. templates/image_studio.html +139 -44
templates/image_studio.html CHANGED
@@ -115,12 +115,12 @@
115
  .ratio-btn:hover { border-color: var(--accent-primary); transform: translateY(-3px); }
116
  .ratio-btn.active { background: #fff; border-color: var(--accent-primary); color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-primary-glow); }
117
 
118
- .ratio-icon-box { background-color: var(--panel-bg); border: 2px solid var(--text-tertiary); border-radius: 4px; transition: var(--transition-smooth); }
119
- .ratio-btn.active .ratio-icon-box { border-color: var(--accent-primary); background-color: var(--accent-primary-glow); }
120
  .icon-1-1 { width: 28px; height: 28px; }
121
  .icon-16-9 { width: 40px; height: 22px; }
122
  .icon-9-16 { width: 22px; height: 40px; }
123
- .icon-4-3 { width: 34px; height: 25px; }
124
 
125
  /* Model Selector Grid (Square) */
126
  .model-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
@@ -219,7 +219,7 @@
219
  @keyframes fadeInBackdrop { from { opacity: 0; } to { opacity: 1; } }
220
  @keyframes fadeInModal { from { opacity: 0; transform: translateY(-20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
221
 
222
- /* --- Custom Confirm Dialog --- */
223
  .confirm-modal-backdrop {
224
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
225
  background-color: rgba(26, 32, 44, 0.7); z-index: 3000;
@@ -245,6 +245,8 @@
245
  .btn-cancel:hover { background: #e2e8f0; color: var(--text-primary); }
246
  .btn-danger { background: var(--danger-color); color: white; box-shadow: 0 4px 10px rgba(229,62,62,0.3); }
247
  .btn-danger:hover { background: #C53030; transform: translateY(-2px); box-shadow: 0 6px 15px rgba(229,62,62,0.4); }
 
 
248
 
249
  /* --- History Section Styles --- */
250
  .history-section {
@@ -268,7 +270,7 @@
268
  .danger-btn:hover { background: var(--danger-color); color: #fff; }
269
 
270
  .history-grid {
271
- display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; /* تنظیم نمایش دقیقاً ۲ تصویر در هر ردیف */
272
  }
273
  .history-item {
274
  background: var(--input-bg); border: 1px solid var(--input-border); border-radius: var(--radius-sm);
@@ -301,30 +303,37 @@
301
  /* --- Image View Modal & Toolbar --- */
302
  .image-view-modal {
303
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
304
- background-color: rgba(26, 32, 44, 0.9); z-index: 2000;
305
- display: flex; align-items: center; justify-content: center;
306
  opacity: 0; animation: fadeInBackdrop 0.3s forwards;
307
- flex-direction: column;
 
 
 
 
 
 
308
  }
309
  .image-view-modal img {
310
- max-width: 90%; max-height: 80vh; border-radius: var(--radius-card); box-shadow: 0 0 30px rgba(0,0,0,0.5); object-fit: contain;
311
  }
312
  .image-view-close {
313
- position: absolute; top: 25px; right: 25px; background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.3);
314
  color: white; font-size: 1.5rem; cursor: pointer; width: 45px; height: 45px; border-radius: 50%;
315
  display: flex; align-items: center; justify-content: center; transition: all 0.3s; z-index: 2002;
 
316
  }
317
  .image-view-close:hover {
318
- background: rgba(255,255,255,0.2); border-color: white; transform: scale(1.1);
319
  }
320
 
321
  .image-view-toolbar {
322
- position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%);
323
- display: flex; gap: 15px; z-index: 2001; background: rgba(0,0,0,0.7); padding: 12px 20px; border-radius: 20px; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1);
324
  }
325
  .iv-action-btn {
326
  background: var(--accent-primary); color: white; border: none; padding: 10px 18px; border-radius: var(--radius-btn);
327
- font-family: inherit; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.2s; font-size: 0.95rem; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
328
  }
329
  .iv-action-btn:hover { background: var(--accent-primary-hover); transform: translateY(-3px); box-shadow: 0 6px 15px rgba(0,0,0,0.4); }
330
  .iv-action-btn svg { width: 20px; height: 20px; }
@@ -339,8 +348,10 @@
339
  .empty-placeholder { height: 250px; }
340
  .text-overlay { font-size: 16px; }
341
  .history-item img { height: 140px; }
342
- .image-view-toolbar { bottom: 20px; width: 90%; justify-content: center; padding: 10px; }
343
- .iv-action-btn { padding: 8px 12px; font-size: 0.85rem; flex: 1; justify-content: center;}
 
 
344
  }
345
  </style>
346
  </head>
@@ -398,9 +409,12 @@
398
  <div class="ratio-icon-box icon-9-16"></div>
399
  <span>۹:۱۶ استوری</span>
400
  </button>
401
- <button class="ratio-btn" data-ratio="4:3" data-name="۴:۳ کلاسیک">
402
- <div class="ratio-icon-box icon-4-3"></div>
403
- <span>۴:۳ کلاسیک</span>
 
 
 
404
  </button>
405
  </div>
406
  </div>
@@ -462,7 +476,7 @@
462
  </div>
463
 
464
  <script>
465
- // --- توابع پاپ‌آپ سفارشی (تاییدیه حذف) ---
466
  function showCustomConfirm(title, message, onConfirm) {
467
  const backdrop = document.createElement('div');
468
  backdrop.className = 'confirm-modal-backdrop';
@@ -500,6 +514,74 @@
500
  }
501
  }
502
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
503
  // --- مدیریت دیتابیس تصاویر (IndexedDB) ---
504
  const dbName = 'ImageStudioDB';
505
  const storeName = 'ImageHistory';
@@ -603,7 +685,7 @@
603
  <div class="history-prompt" dir="auto" title="${safeTitle}">${item.prompt}</div>
604
  <div class="history-meta">
605
  <span>${item.model}</span>
606
- <span>${item.ratio}</span>
607
  </div>
608
  <button class="history-delete-btn">حذف تصویر</button>
609
  </div>
@@ -651,21 +733,24 @@
651
  });
652
  });
653
 
 
654
  window.viewHistoryImage = function(url, promptText) {
655
  const modal = document.createElement('div');
656
  modal.className = 'image-view-modal';
657
  modal.innerHTML = `
658
  <button class="image-view-close" onclick="this.parentElement.remove()">×</button>
659
- <img src="${url}" alt="Full Image" class="full-view-img">
660
- <div class="image-view-toolbar" onclick="event.stopPropagation()">
661
- <button class="iv-action-btn iv-btn-copy" id="btn-copy-prompt">
662
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
663
- کپی پرامپت
664
- </button>
665
- <button class="iv-action-btn" id="btn-download-img">
666
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>
667
- دانلود تصویر
668
- </button>
 
 
669
  </div>
670
  `;
671
 
@@ -696,7 +781,7 @@
696
  };
697
 
698
  modal.onclick = (e) => {
699
- if(e.target === modal || e.target.classList.contains('full-view-img')) modal.remove();
700
  };
701
  document.body.appendChild(modal);
702
  };
@@ -801,10 +886,6 @@
801
  }
802
  });
803
 
804
- document.getElementById('upgrade-button').addEventListener('click', () => {
805
- parent.postMessage({ type: 'NAVIGATE_TO_PREMIUM' }, '*');
806
- });
807
-
808
  document.addEventListener('DOMContentLoaded', async () => {
809
  userFingerprint = await getBrowserFingerprint();
810
  parent.postMessage({ type: 'REQUEST_USER_DATA' }, '*');
@@ -822,7 +903,6 @@
822
  let selectedModelName = 'Flux Pro';
823
  let selectedRatio = '1:1';
824
  let selectedRatioName = '۱:۱ مربع';
825
- let selectedRatioClass = 'ratio-1-1';
826
 
827
  modelSelector.addEventListener('click', (e) => {
828
  const card = e.target.closest('.model-card');
@@ -836,18 +916,33 @@
836
  ratioSelector.addEventListener('click', (e) => {
837
  const btn = e.target.closest('.ratio-btn');
838
  if (!btn) return;
839
- ratioSelector.querySelectorAll('.ratio-btn').forEach(c => c.classList.remove('active'));
840
- btn.classList.add('active');
841
- selectedRatio = btn.dataset.ratio;
842
- selectedRatioName = btn.dataset.name;
843
- selectedRatioClass = 'ratio-' + btn.dataset.ratio.replace(':', '-');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
844
  });
845
 
846
  const getDimensions = (ratio) => {
847
  switch (ratio) {
848
  case '9:16': return { width: 768, height: 1344 };
849
  case '16:9': return { width: 1344, height: 768 };
850
- case '4:3': return { width: 1152, height: 864 };
851
  case '1:1': default: return { width: 1024, height: 1024 };
852
  }
853
  };
@@ -986,7 +1081,7 @@
986
  ${currentModelName}
987
  </span>
988
  <span>|</span>
989
- <span>
990
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>
991
  ${currentRatioName}
992
  </span>
 
115
  .ratio-btn:hover { border-color: var(--accent-primary); transform: translateY(-3px); }
116
  .ratio-btn.active { background: #fff; border-color: var(--accent-primary); color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-primary-glow); }
117
 
118
+ .ratio-icon-box { background-color: var(--panel-bg); border: 2px solid var(--text-tertiary); border-radius: 4px; transition: var(--transition-smooth); display:flex; align-items:center; justify-content:center;}
119
+ .ratio-btn.active .ratio-icon-box { border-color: var(--accent-primary); background-color: var(--accent-primary-glow); color: var(--accent-primary); }
120
  .icon-1-1 { width: 28px; height: 28px; }
121
  .icon-16-9 { width: 40px; height: 22px; }
122
  .icon-9-16 { width: 22px; height: 40px; }
123
+ .icon-custom { width: 34px; height: 25px; border-style: dashed !important; color: var(--text-tertiary); }
124
 
125
  /* Model Selector Grid (Square) */
126
  .model-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
 
219
  @keyframes fadeInBackdrop { from { opacity: 0; } to { opacity: 1; } }
220
  @keyframes fadeInModal { from { opacity: 0; transform: translateY(-20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
221
 
222
+ /* --- Custom Dialogs (Confirm & Input) --- */
223
  .confirm-modal-backdrop {
224
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
225
  background-color: rgba(26, 32, 44, 0.7); z-index: 3000;
 
245
  .btn-cancel:hover { background: #e2e8f0; color: var(--text-primary); }
246
  .btn-danger { background: var(--danger-color); color: white; box-shadow: 0 4px 10px rgba(229,62,62,0.3); }
247
  .btn-danger:hover { background: #C53030; transform: translateY(-2px); box-shadow: 0 6px 15px rgba(229,62,62,0.4); }
248
+ .btn-primary-action { background: var(--accent-primary); color: white; box-shadow: 0 4px 10px rgba(74, 108, 250, 0.3); }
249
+ .btn-primary-action:hover { background: var(--accent-primary-hover); transform: translateY(-2px); box-shadow: 0 6px 15px rgba(74, 108, 250, 0.4); }
250
 
251
  /* --- History Section Styles --- */
252
  .history-section {
 
270
  .danger-btn:hover { background: var(--danger-color); color: #fff; }
271
 
272
  .history-grid {
273
+ display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px;
274
  }
275
  .history-item {
276
  background: var(--input-bg); border: 1px solid var(--input-border); border-radius: var(--radius-sm);
 
303
  /* --- Image View Modal & Toolbar --- */
304
  .image-view-modal {
305
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
306
+ background-color: rgba(26, 32, 44, 0.95); z-index: 2000;
307
+ display: flex; flex-direction: column; align-items: center;
308
  opacity: 0; animation: fadeInBackdrop 0.3s forwards;
309
+ overflow-y: auto; /* امکان اسکرول برای موبایل */
310
+ padding: 40px 20px;
311
+ }
312
+ .image-view-wrapper {
313
+ margin: auto; /* قرارگیری در مرکز عمودی اگر فضا بود */
314
+ display: flex; flex-direction: column; align-items: center; gap: 12px;
315
+ width: 100%; max-width: 800px; position: relative;
316
  }
317
  .image-view-modal img {
318
+ max-width: 100%; border-radius: var(--radius-card); box-shadow: 0 0 30px rgba(0,0,0,0.5); object-fit: contain;
319
  }
320
  .image-view-close {
321
+ position: fixed; top: 20px; right: 20px; background: rgba(255,255,255,0.15); border: 2px solid rgba(255,255,255,0.3);
322
  color: white; font-size: 1.5rem; cursor: pointer; width: 45px; height: 45px; border-radius: 50%;
323
  display: flex; align-items: center; justify-content: center; transition: all 0.3s; z-index: 2002;
324
+ backdrop-filter: blur(5px);
325
  }
326
  .image-view-close:hover {
327
+ background: rgba(255,255,255,0.3); border-color: white; transform: scale(1.1);
328
  }
329
 
330
  .image-view-toolbar {
331
+ width: 100%; display: flex; gap: 15px; justify-content: center;
332
+ background: rgba(0,0,0,0.7); padding: 12px 20px; border-radius: 20px; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1);
333
  }
334
  .iv-action-btn {
335
  background: var(--accent-primary); color: white; border: none; padding: 10px 18px; border-radius: var(--radius-btn);
336
+ font-family: inherit; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s; font-size: 0.95rem; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
337
  }
338
  .iv-action-btn:hover { background: var(--accent-primary-hover); transform: translateY(-3px); box-shadow: 0 6px 15px rgba(0,0,0,0.4); }
339
  .iv-action-btn svg { width: 20px; height: 20px; }
 
348
  .empty-placeholder { height: 250px; }
349
  .text-overlay { font-size: 16px; }
350
  .history-item img { height: 140px; }
351
+
352
+ .image-view-modal { padding: 60px 15px 30px; } /* فضای بالا برای دکمه خروج */
353
+ .image-view-toolbar { flex-direction: row; flex-wrap: wrap; padding: 10px; border-radius: 15px; gap: 10px;}
354
+ .iv-action-btn { flex: 1; min-width: 130px; font-size: 0.85rem; padding: 10px 12px;}
355
  }
356
  </style>
357
  </head>
 
409
  <div class="ratio-icon-box icon-9-16"></div>
410
  <span>۹:۱۶ استوری</span>
411
  </button>
412
+ <!-- Custom Size Button -->
413
+ <button class="ratio-btn" data-ratio="custom" data-name="اندازه دلخواه">
414
+ <div class="ratio-icon-box icon-custom">
415
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/></svg>
416
+ </div>
417
+ <span>اندازه دلخواه</span>
418
  </button>
419
  </div>
420
  </div>
 
476
  </div>
477
 
478
  <script>
479
+ // --- توابع پاپ‌آپ سفارشی (تاییدیه حذف و اندازه دلخواه) ---
480
  function showCustomConfirm(title, message, onConfirm) {
481
  const backdrop = document.createElement('div');
482
  backdrop.className = 'confirm-modal-backdrop';
 
514
  }
515
  }
516
 
517
+ // متغیرهای ذخیره ابعاد دلخواه
518
+ let userCustomWidth = 1024;
519
+ let userCustomHeight = 1024;
520
+
521
+ function showCustomSizeModal(onConfirm) {
522
+ const backdrop = document.createElement('div');
523
+ backdrop.className = 'confirm-modal-backdrop';
524
+
525
+ const content = document.createElement('div');
526
+ content.className = 'confirm-modal-content';
527
+
528
+ content.innerHTML = `
529
+ <div class="confirm-icon" style="color: var(--accent-primary); background: var(--accent-primary-glow);">
530
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:32px;height:32px;"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><path d="M3 9h18"></path><path d="M9 21V9"></path></svg>
531
+ </div>
532
+ <div class="confirm-title">اندازه دلخواه تصویر</div>
533
+ <div class="confirm-message">ابعاد مورد نظر خود را وارد کنید (بین ۲۵۶ تا ۲۰۴۸)</div>
534
+ <div style="display:flex; gap:10px; margin-bottom: 20px; flex-direction:row-reverse;">
535
+ <div style="flex:1;">
536
+ <label style="display:block; font-size:0.85rem; margin-bottom:5px; color:var(--text-secondary); font-weight:bold;">عرض (Width)</label>
537
+ <input type="number" id="inp-width" value="${userCustomWidth}" min="256" max="2048" style="width:100%; padding:10px; border-radius:10px; border:2px solid var(--input-border); font-family:inherit; text-align:center; font-weight:bold; font-size:1.1rem; outline:none;">
538
+ </div>
539
+ <div style="flex:1;">
540
+ <label style="display:block; font-size:0.85rem; margin-bottom:5px; color:var(--text-secondary); font-weight:bold;">ارتفاع (Height)</label>
541
+ <input type="number" id="inp-height" value="${userCustomHeight}" min="256" max="2048" style="width:100%; padding:10px; border-radius:10px; border:2px solid var(--input-border); font-family:inherit; text-align:center; font-weight:bold; font-size:1.1rem; outline:none;">
542
+ </div>
543
+ </div>
544
+ <div class="confirm-actions">
545
+ <button class="confirm-btn btn-cancel" id="size-cancel">انصراف</button>
546
+ <button class="confirm-btn btn-primary-action" id="size-ok">تایید اندازه</button>
547
+ </div>
548
+ `;
549
+
550
+ backdrop.appendChild(content);
551
+ document.body.appendChild(backdrop);
552
+
553
+ // Focus styling
554
+ const inputs = backdrop.querySelectorAll('input');
555
+ inputs.forEach(inp => {
556
+ inp.addEventListener('focus', () => inp.style.borderColor = 'var(--accent-primary)');
557
+ inp.addEventListener('blur', () => inp.style.borderColor = 'var(--input-border)');
558
+ });
559
+
560
+ const close = () => {
561
+ backdrop.style.opacity = '0';
562
+ setTimeout(() => backdrop.remove(), 300);
563
+ };
564
+
565
+ backdrop.querySelector('#size-cancel').onclick = close;
566
+
567
+ backdrop.querySelector('#size-ok').onclick = () => {
568
+ const w = parseInt(backdrop.querySelector('#inp-width').value);
569
+ const h = parseInt(backdrop.querySelector('#inp-height').value);
570
+ if(w >= 256 && w <= 2048 && h >= 256 && h <= 2048) {
571
+ userCustomWidth = w;
572
+ userCustomHeight = h;
573
+ onConfirm(w, h);
574
+ close();
575
+ } else {
576
+ alert('لطفا مقادیری بین ۲۵۶ تا ۲۰۴۸ وارد کنید.');
577
+ }
578
+ };
579
+
580
+ backdrop.onclick = (e) => {
581
+ if(e.target === backdrop) close();
582
+ }
583
+ }
584
+
585
  // --- مدیریت دیتابیس تصاویر (IndexedDB) ---
586
  const dbName = 'ImageStudioDB';
587
  const storeName = 'ImageHistory';
 
685
  <div class="history-prompt" dir="auto" title="${safeTitle}">${item.prompt}</div>
686
  <div class="history-meta">
687
  <span>${item.model}</span>
688
+ <span dir="ltr">${item.ratio}</span>
689
  </div>
690
  <button class="history-delete-btn">حذف تصویر</button>
691
  </div>
 
733
  });
734
  });
735
 
736
+ // نمایش عکس بزرگ همراه با نوار ابزار در زیر آن (با قابلیت اسکرول)
737
  window.viewHistoryImage = function(url, promptText) {
738
  const modal = document.createElement('div');
739
  modal.className = 'image-view-modal';
740
  modal.innerHTML = `
741
  <button class="image-view-close" onclick="this.parentElement.remove()">×</button>
742
+ <div class="image-view-wrapper" onclick="event.stopPropagation()">
743
+ <img src="${url}" alt="Full Image" class="full-view-img">
744
+ <div class="image-view-toolbar">
745
+ <button class="iv-action-btn iv-btn-copy" id="btn-copy-prompt">
746
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
747
+ کپی پرامپت
748
+ </button>
749
+ <button class="iv-action-btn" id="btn-download-img">
750
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>
751
+ دانلود تصویر
752
+ </button>
753
+ </div>
754
  </div>
755
  `;
756
 
 
781
  };
782
 
783
  modal.onclick = (e) => {
784
+ if(e.target === modal) modal.remove();
785
  };
786
  document.body.appendChild(modal);
787
  };
 
886
  }
887
  });
888
 
 
 
 
 
889
  document.addEventListener('DOMContentLoaded', async () => {
890
  userFingerprint = await getBrowserFingerprint();
891
  parent.postMessage({ type: 'REQUEST_USER_DATA' }, '*');
 
903
  let selectedModelName = 'Flux Pro';
904
  let selectedRatio = '1:1';
905
  let selectedRatioName = '۱:۱ مربع';
 
906
 
907
  modelSelector.addEventListener('click', (e) => {
908
  const card = e.target.closest('.model-card');
 
916
  ratioSelector.addEventListener('click', (e) => {
917
  const btn = e.target.closest('.ratio-btn');
918
  if (!btn) return;
919
+
920
+ if (btn.dataset.ratio === 'custom') {
921
+ showCustomSizeModal((w, h) => {
922
+ // Update UI after confirm
923
+ ratioSelector.querySelectorAll('.ratio-btn').forEach(c => c.classList.remove('active'));
924
+ btn.classList.add('active');
925
+ selectedRatio = 'custom';
926
+ selectedRatioName = `${w}x${h} دلخواه`;
927
+ btn.querySelector('span').textContent = `${w}x${h} دلخواه`;
928
+ });
929
+ } else {
930
+ ratioSelector.querySelectorAll('.ratio-btn').forEach(c => c.classList.remove('active'));
931
+ btn.classList.add('active');
932
+ selectedRatio = btn.dataset.ratio;
933
+ selectedRatioName = btn.dataset.name;
934
+
935
+ // Reset custom button text
936
+ const customBtn = ratioSelector.querySelector('[data-ratio="custom"]');
937
+ if(customBtn) customBtn.querySelector('span').textContent = 'اندازه دلخواه';
938
+ }
939
  });
940
 
941
  const getDimensions = (ratio) => {
942
  switch (ratio) {
943
  case '9:16': return { width: 768, height: 1344 };
944
  case '16:9': return { width: 1344, height: 768 };
945
+ case 'custom': return { width: userCustomWidth, height: userCustomHeight };
946
  case '1:1': default: return { width: 1024, height: 1024 };
947
  }
948
  };
 
1081
  ${currentModelName}
1082
  </span>
1083
  <span>|</span>
1084
+ <span dir="ltr">
1085
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>
1086
  ${currentRatioName}
1087
  </span>