1/** 2 * [TR] Sol menü sekmelerinin tıklama iÅlevselliÄini yönetir. 3 * [EN] Manages click functionality for left sidebar tabs. 4 */ 5 6document.addEventListener('DOMContentLoaded', function() { 7 // index.html sidebar yapısında tab davranıÅı sidebar_and_forms.js tarafından yönetiliyor. 8 // Burada yalnızca global switchTab köprüsü saÄlayıp çift yönetim çakıÅmasını engelliyoruz. 9 const hasIndexSidebar = !!( 10 document.querySelector('#pp-sidebar-tab-menu li[data-tab="parsel-sorgu-tab"]') && 11 document.getElementById('parsel-sorgu-tab') 12 ); 13 14 if (hasIndexSidebar) { 15 const normalizeIndexTabName = (tabName) => { 16 const raw = String(tabName || '').trim().toLowerCase(); 17 if (!raw) return ''; 18 19 if (raw === 'parcel' || raw === 'parsel' || raw === 'parsel-sorgu-tab' || raw === 'parcel-tab' || raw === 'idari') { 20 return 'parsel-sorgu-tab'; 21 } 22 if ( 23 raw === 'sorgularim' || 24 raw === 'sorgularım' || 25 raw === 'my_queries' || 26 raw === 'my-queries' || 27 raw === 'saved_queries' || 28 raw === 'saved-queries' || 29 raw === 'sorgularim-tab' 30 ) { 31 return 'sorgularim-tab'; 32 } 33 if ( 34 raw === 'image_query' || 35 raw === 'image-query' || 36 raw === 'ocr' || 37 raw === 'ocr-tab' || 38 raw === 'ocr-image-tab' || 39 raw === 'smart_query' || 40 raw === 'smart-query' || 41 raw === 'akilli' || 42 raw === 'akilli-sorgu-tab' 43 ) { 44 return 'akilli-sorgu-tab'; 45 } 46 return raw; 47 }; 48 49 const getCurrentActiveDataTab = () => { 50 const active = document.querySelector('#pp-sidebar-tab-menu li.active[data-tab]'); 51 return active ? active.getAttribute('data-tab') : 'parsel-sorgu-tab'; 52 }; 53 54 let currentTab = getCurrentActiveDataTab(); 55 56 function switchTab(tabName) { 57 const targetTab = normalizeIndexTabName(tabName); 58 if (!targetTab) return false; 59 60 const targetButton = document.querySelector(`#pp-sidebar-tab-menu li[data-tab="${targetTab}"]`); 61 if (!targetButton) return false; 62 63 targetButton.click(); 64 currentTab = targetTab; 65 return true; 66 } 67 68 window.switchTab = switchTab; 69 window.getCurrentTab = () => currentTab; 70 return; 71 } 72 73 // Tab deÄiÅkenleri 74 let currentTab = 'parcel'; 75 76 // Tab elementlerini bul 77 const tabButtons = document.querySelectorAll('.sidebar-tabs li'); 78 const resolveEl = (ids) => { 79 for (const id of ids) { 80 const el = document.getElementById(id); 81 if (el) return el; 82 } 83 return null; 84 }; 85 const tabContents = { 86 // İdari (parcel) 87 parcel: (function(){ 88 const c = resolveEl(['idari-content', 'parcel-tab', 'info']); 89 if (c) return c; 90 const info = document.getElementById('parcel_info'); 91 return info ? (info.closest('#idari-content') || info.closest('#parcel-tab') || info.parentElement) : null; 92 })(), 93 // Metin'den Sorgu (image_query) 94 image_query: (function(){ 95 const c = resolveEl(['image-query-content', 'image_query-content', 'ocr-image-tab', 'ocr-tab']); 96 if (c) return c; 97 const input = document.getElementById('ocr-text-input'); 98 return input ? (input.closest('#image-query-content') || input.parentElement) : null; 99 })(), 100 // Parametre (analysis) 101 analysis: (function(){ 102 const c = resolveEl(['parametre-content', 'analysis-tab', 'parameters', 'parameters-tab']); 103 if (c) return c; 104 const info = document.getElementById('parameters_info'); 105 return info ? (info.closest('#parametre-content') || info.closest('#analysis-tab') || info.closest('#parameters') || info.parentElement) : null; 106 })() 107 }; 108 109 // Tab tıklama olaylarını ekle 110 tabButtons.forEach(button => { 111 const idToTabName = (id) => { 112 if (!id || typeof id !== 'string') return null; 113 const v = id.toLowerCase(); 114 if (v.includes('parcel') || v.includes('info')) return 'parcel'; 115 if (v.includes('image') || v.includes('ocr') || v.includes('resim')) return 'image_query'; 116 if (v.includes('analysis') || v.includes('parameter')) return 'analysis'; 117 return null; 118 }; 119 const resolveTargetFromButton = (el) => { 120 // 1) data-tab 121 const dt = el.getAttribute('data-tab'); 122 if (dt) return dt; 123 // 2) data-target / aria-controls 124 const dtarget = el.getAttribute('data-target') || el.getAttribute('aria-controls'); 125 const byAttr = idToTabName(dtarget); 126 if (byAttr) return byAttr; 127 // 3) child anchor href (#id) 128 const a = el.querySelector('a'); 129 if (a) { 130 const href = a.getAttribute('href'); 131 if (href && href.startsWith('#')) { 132 const byHref = idToTabName(href.slice(1)); 133 if (byHref) return byHref; 134 } 135 } 136 // 4) element id or class 137 const byId = idToTabName(el.id); 138 if (byId) return byId; 139 const cls = (el.className || '').toString(); 140 const byClass = idToTabName(cls); 141 if (byClass) return byClass; 142 // 5) fallback by index 143 const arr = Array.from(tabButtons); 144 const idx = arr.indexOf(el); 145 if (idx === 0) return 'parcel'; 146 if (idx === 1) return 'analysis'; 147 if (idx === 2) return 'image_query'; 148 return null; 149 }; 150 151 // li click 152 button.addEventListener('click', function(e) { 153 const targetTab = resolveTargetFromButton(this); 154 if (targetTab) { 155 e.preventDefault(); 156 switchTab(targetTab); 157 } 158 });
159 // anchor inside click 160 const anchor = button.querySelector('a'); 161 if (anchor) { 162 anchor.addEventListener('click', function(e) { 163 const targetTab = resolveTargetFromButton(button); 164 if (targetTab) { 165 e.preventDefault(); 166 switchTab(targetTab); 167 } 168 }); 169 } 170 }); 171 172 // Tab deÄiÅtirme fonksiyonu 173 function switchTab(tabName) { 174 // TKGM modunda Parametre kapalıysa engelle 175 // TKGM/Pro modu 2D/3D'den baÄımsız yönetiliyor 176 const inTkgmMode = typeof window.isTkgmModeActive === 'function' ? window.isTkgmModeActive() : !(window.mapManager?.is3DModeActive?.()); 177 if (inTkgmMode && tabName === 'analysis') { 178 return; 179 } 180 let targetContent = tabContents[tabName] || null; 181 182 // Hedef yoksa mevcut görünümü koru ve uyarı ver 183 if (!targetContent) { 184 return; 185 } 186 187 // Tüm tab butonlarından active sınıfını kaldır 188 tabButtons.forEach(btn => btn.classList.remove('active')); 189 190 // Var olan içerikleri gizle (yalnızca bulunanları) 191 Object.values(tabContents).forEach(content => { 192 if (content && content !== targetContent) { 193 content.style.display = 'none'; 194 } 195 }); 196 197 // Seçilen tab butonunu aktif yap 198 let activeButton = document.querySelector(`[data-tab="${tabName}"]`); 199 if (!activeButton) { 200 // data-tab yoksa index tab eÅlemesi üzerinden seç 201 const arr = Array.from(tabButtons); 202 const idx = (tabName === 'parcel') ? 0 : (tabName === 'analysis') ? 1 : (tabName === 'image_query') ? 2 : -1; 203 if (idx >= 0 && idx < arr.length) activeButton = arr[idx]; 204 } 205 if (activeButton) { activeButton.classList.add('active'); } 206 207 // Seçilen tab içeriÄini göster 208 // sidebar-content-tkgm flex kullandıÄı için display: flex olarak ayarla 209 try { 210 targetContent.style.removeProperty('display'); 211 // CSS'de tanımlı display: flex kullanılsın diye önce property'yi kaldır 212 // EÄer CSS yüklenmediyse fallback olarak flex ayarla 213 const computedDisplay = window.getComputedStyle(targetContent).display; 214 if (computedDisplay === 'none') { 215 targetContent.style.display = 'flex'; 216 } 217 } catch(_) { 218 // Fallback 219 targetContent.style.display = 'flex'; 220 } 221 currentTab = tabName; 222 } 223 224 // İlk tab'ı aktif yap (sadece sidebar açıksa) 225 // Sidebar baÅlangıçta kapalı olduÄu için burada tıklama yapmıyoruz 226 // toggleSidebar fonksiyonu açılıÅta switchTab('parcel') çaÄrıyor 227 228 // Global fonksiyon olarak tanımla 229 window.switchTab = switchTab; 230 window.getCurrentTab = () => currentTab; 231}); 232 233// Basit tab iÅlevleri 234function updateAnalysisParameters() {} 235 236// Global fonksiyonlar 237window.updateAnalysisParameters = updateAnalysisParameters;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.