Compare commits

...
3 Commits
3 changed files with 110 additions and 96 deletions
+57 -57
View File
@@ -1404,7 +1404,10 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// 8. FULL YOUTUBE SEARCH & VOICE MODAL ENGINE (v1.3.0) // --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// 8. FULL YOUTUBE SEARCH & VOICE MODAL ENGINE (v1.3.3 - Guaranteed Close Fix)
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
var activeVoiceRec = null; var activeVoiceRec = null;
var isVoiceListening = false; var isVoiceListening = false;
@@ -1419,16 +1422,13 @@
modal.setAttribute('role', 'dialog'); modal.setAttribute('role', 'dialog');
modal.setAttribute('aria-modal', 'true'); modal.setAttribute('aria-modal', 'true');
modal.setAttribute('aria-labelledby', 'yaktube-modal-search-title'); modal.setAttribute('aria-labelledby', 'yaktube-modal-search-title');
modal.style.display = 'none';
modal.innerHTML = modal.innerHTML =
'<div class="yaktube-modal-search-card">' + '<div class="yaktube-modal-search-card">' +
'<div class="yaktube-modal-search-bar">' + '<div class="yaktube-modal-search-bar">' +
'<button id="yaktube-modal-back-btn" class="yaktube-modal-back-btn" aria-label="Aramadan Çık (Escape)" title="Aramadan Çık (Escape)">←</button>' + '<button id="yaktube-modal-back-btn" class="yaktube-modal-back-btn" aria-label="Aramadan Çık (Escape)" title="Aramadan Çık (Escape)">←</button>' +
'<div class="yaktube-modal-input-wrap">' + '<div class="yaktube-modal-input-wrap">' +
'<input id="yaktube-modal-input" type="search" placeholder="' + '<input id="yaktube-modal-input" type="search" placeholder="Video veya kanal ara..." aria-label="Arama Metni">' +
getInstanceName() +
' ve YouTube\'da arayın..." aria-label="Arama Metni">' +
'<button id="yaktube-modal-clear-btn" class="yaktube-modal-clear-btn" aria-label="Metni Temizle">✕</button>' + '<button id="yaktube-modal-clear-btn" class="yaktube-modal-clear-btn" aria-label="Metni Temizle">✕</button>' +
'</div>' + '</div>' +
'<button id="yaktube-modal-submit-btn" class="yaktube-modal-search-action-btn" aria-label="Ara">🔍 Ara</button>' + '<button id="yaktube-modal-submit-btn" class="yaktube-modal-search-action-btn" aria-label="Ara">🔍 Ara</button>' +
@@ -1484,7 +1484,9 @@
}); });
// Close on Back button or Escape // Close on Back button or Escape
backBtn.addEventListener('click', function () { backBtn.addEventListener('click', function (e) {
e.preventDefault();
e.stopPropagation();
closeFullSearchModal(); closeFullSearchModal();
}); });
@@ -1540,6 +1542,7 @@
function openFullSearchModal(initialQuery, autoStartVoice) { function openFullSearchModal(initialQuery, autoStartVoice) {
var modal = createFullSearchModal(); var modal = createFullSearchModal();
modal.classList.add('yaktube-modal-open');
modal.style.display = 'flex'; modal.style.display = 'flex';
var inp = modal.querySelector('#yaktube-modal-input'); var inp = modal.querySelector('#yaktube-modal-input');
@@ -1547,8 +1550,10 @@
if (inp) { if (inp) {
inp.value = initialQuery || ''; inp.value = initialQuery || '';
if (inp.value) clearBtn.style.display = 'inline-flex'; if (inp.value) clearBtn.style.display = 'inline-flex';
inp.focus(); setTimeout(function () {
inp.select(); inp.focus();
inp.select();
}, 50);
} }
announce('Arama penceresi açıldı. Arayacağınız konuyu yazın veya sesle arayın.', true); announce('Arama penceresi açıldı. Arayacağınız konuyu yazın veya sesle arayın.', true);
@@ -1560,9 +1565,19 @@
function closeFullSearchModal() { function closeFullSearchModal() {
var modal = document.getElementById('yaktube-full-search-modal'); var modal = document.getElementById('yaktube-full-search-modal');
if (modal) modal.style.display = 'none'; if (modal) {
modal.classList.remove('yaktube-modal-open');
modal.style.display = 'none';
}
stopVoiceInsideModal(); stopVoiceInsideModal();
announce('Arama penceresi kapatıldı.'); announce('Arama penceresi kapatıldı.');
var trigger = document.querySelector('.yaktube-search-trigger-pill');
if (trigger) {
try {
trigger.focus();
} catch (e) {}
}
} }
function toggleVoiceInsideModal() { function toggleVoiceInsideModal() {
@@ -1653,52 +1668,50 @@
} }
function transformToYouTubeSearchBar(searchInp, searchContainer) { function transformToYouTubeSearchBar(searchInp, searchContainer) {
if (searchInp.hasAttribute('data-yaktube-yt-styled')) return; if (searchContainer.hasAttribute('data-yaktube-trigger-styled')) return;
searchInp.setAttribute('data-yaktube-yt-styled', 'true'); searchContainer.setAttribute('data-yaktube-trigger-styled', 'true');
searchInp.setAttribute('aria-label', getInstanceName() + ' Video Arama (Açmak için tıklayın)');
searchInp.setAttribute('title', 'Arama Penceresini Aç'); // Hide original native inputs
searchInp.style.display = 'none';
searchInp.setAttribute('tabindex', '-1');
searchInp.setAttribute('aria-hidden', 'true');
var nativeInputs = searchContainer.querySelectorAll('input, button');
nativeInputs.forEach(function (el) {
if (!el.classList.contains('yaktube-search-trigger-pill') && !el.classList.contains('yaktube-voice-search-btn')) {
el.style.display = 'none';
el.setAttribute('tabindex', '-1');
el.setAttribute('aria-hidden', 'true');
}
});
// 1. Create Outer Wrapper // 1. Create Outer Wrapper
var outerWrap = searchContainer.querySelector('.yaktube-search-outer-wrap'); var outerWrap = searchContainer.querySelector('.yaktube-search-outer-wrap');
if (!outerWrap) { if (!outerWrap) {
outerWrap = document.createElement('div'); outerWrap = document.createElement('div');
outerWrap.className = 'yaktube-search-outer-wrap'; outerWrap.className = 'yaktube-search-outer-wrap';
searchInp.parentNode.insertBefore(outerWrap, searchInp); searchContainer.appendChild(outerWrap);
} }
// 2. Create Pill Box // 2. Create Single Sleek Pill Trigger
var pillWrapper = outerWrap.querySelector('.yaktube-search-pill-wrapper'); var triggerPill = outerWrap.querySelector('.yaktube-search-trigger-pill');
if (!pillWrapper) { if (!triggerPill) {
pillWrapper = document.createElement('div'); triggerPill = document.createElement('button');
pillWrapper.className = 'yaktube-search-pill-wrapper'; triggerPill.type = 'button';
outerWrap.appendChild(pillWrapper); triggerPill.className = 'yaktube-search-trigger-pill';
triggerPill.setAttribute('aria-label', 'Ara');
triggerPill.setAttribute('title', 'Arama Yap (/)');
// Move Input Inside Pill triggerPill.innerHTML =
pillWrapper.appendChild(searchInp); '<span class="yaktube-search-trigger-icon">🔍</span>' +
'<span class="yaktube-search-trigger-text">Ara...</span>' +
'<span class="yaktube-search-trigger-shortcut">/</span>';
// Add Search Submit Button (🔍) outerWrap.appendChild(triggerPill);
var submitBtn = document.createElement('button');
submitBtn.type = 'button';
submitBtn.className = 'yaktube-search-submit-btn';
submitBtn.setAttribute('aria-label', 'Arama Penceresini Aç');
submitBtn.setAttribute('title', 'Ara');
submitBtn.innerHTML = '🔍';
pillWrapper.appendChild(submitBtn);
// Click on search pill opens full YouTube search modal! triggerPill.addEventListener('click', function (e) {
searchInp.addEventListener('click', function (e) {
e.preventDefault(); e.preventDefault();
openFullSearchModal(searchInp.value, false); openFullSearchModal('', false);
});
searchInp.addEventListener('focus', function (e) {
e.preventDefault();
openFullSearchModal(searchInp.value, false);
});
submitBtn.addEventListener('click', function (e) {
e.preventDefault();
openFullSearchModal(searchInp.value, false);
}); });
} }
@@ -1733,19 +1746,6 @@
} }
}); });
var headerInputs = document.querySelectorAll('my-header input');
headerInputs.forEach(function (inp) {
var parent = inp.closest('my-search-typeahead') || inp.parentElement;
if (
parent &&
(inp.type === 'search' ||
inp.type === 'text' ||
(inp.placeholder && inp.placeholder.toLowerCase().includes('ara')))
) {
transformToYouTubeSearchBar(inp, parent);
}
});
// Clean up repetitive card titles and strange relative date buttons // Clean up repetitive card titles and strange relative date buttons
document.querySelectorAll('my-video-miniature, .video-miniature').forEach(function (card) { document.querySelectorAll('my-video-miniature, .video-miniature').forEach(function (card) {
var thumbLink = card.querySelector('a.thumbnail-link, .video-thumbnail a, a.thumbnail'); var thumbLink = card.querySelector('a.thumbnail-link, .video-thumbnail a, a.thumbnail');
@@ -1776,7 +1776,7 @@
// Escape: Close Full Search Modal // Escape: Close Full Search Modal
else if (e.key === 'Escape' || e.keyCode === 27) { else if (e.key === 'Escape' || e.keyCode === 27) {
var modal = document.getElementById('yaktube-full-search-modal'); var modal = document.getElementById('yaktube-full-search-modal');
if (modal && modal.style.display === 'flex') { if (modal && modal.classList.contains('yaktube-modal-open')) {
e.preventDefault(); e.preventDefault();
closeFullSearchModal(); closeFullSearchModal();
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "peertube-plugin-yaktube-ondemand", "name": "peertube-plugin-yaktube-ondemand",
"version": "1.3.0", "version": "1.3.3",
"description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations and A11y Engine for PeerTube", "description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations and A11y Engine for PeerTube",
"main": "main.js", "main": "main.js",
"clientScripts": [ "clientScripts": [
+52 -38
View File
@@ -411,10 +411,12 @@ my-header .action-buttons {
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* YOUTUBE FULL SEARCH & VOICE MODAL (v1.3.0) */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* YOUTUBE FULL SEARCH & VOICE MODAL (v1.3.3 - Display Fix) */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* Header Search Bar Trigger (Pill Shape) */ /* Header Search Trigger Container */
my-search-typeahead, my-search-typeahead,
.search-container, .search-container,
.header-search { .header-search {
@@ -422,7 +424,7 @@ my-search-typeahead,
align-items: center !important; align-items: center !important;
position: relative !important; position: relative !important;
width: 100% !important; width: 100% !important;
max-width: 580px !important; max-width: 540px !important;
margin: 0 auto !important; margin: 0 auto !important;
} }
@@ -432,50 +434,56 @@ my-search-typeahead,
width: 100% !important; width: 100% !important;
} }
.yaktube-search-pill-wrapper { /* Clickable Pill Button in Header */
.yaktube-search-trigger-pill {
display: flex !important; display: flex !important;
align-items: center !important; align-items: center !important;
background: #121212 !important; background: #121212 !important;
border: 1px solid #303030 !important; border: 1px solid #303030 !important;
border-radius: 40px !important; border-radius: 40px !important;
padding: 0 0 0 14px !important; padding: 8px 18px !important;
transition: all 0.2s ease !important; transition: all 0.2s ease !important;
width: 100% !important; width: 100% !important;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4) !important; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4) !important;
overflow: hidden !important;
cursor: text !important;
}
.yaktube-search-pill-wrapper:hover {
border-color: #555 !important;
}
.yaktube-search-pill-wrapper input {
background: transparent !important;
border: none !important;
color: #f1f1f1 !important;
font-size: 15px !important;
padding: 8px 6px !important;
width: 100% !important;
outline: none !important;
box-shadow: none !important;
}
.yaktube-search-submit-btn {
background: #222222 !important;
color: #f1f1f1 !important;
border: none !important;
border-left: 1px solid #303030 !important;
padding: 8px 18px !important;
cursor: pointer !important; cursor: pointer !important;
display: inline-flex !important; color: #888 !important;
align-items: center !important; font-size: 15px !important;
justify-content: center !important; user-select: none !important;
font-size: 14px !important; gap: 10px !important;
transition: all 0.2s ease !important;
flex-shrink: 0 !important;
} }
.yaktube-search-trigger-pill:hover,
.yaktube-search-trigger-pill:focus {
border-color: #ff8f37 !important;
background: #18181c !important;
color: #f1f1f1 !important;
box-shadow: 0 0 12px rgba(255, 143, 55, 0.25) !important;
outline: none !important;
}
.yaktube-search-trigger-icon {
font-size: 15px !important;
color: #ff8f37 !important;
}
.yaktube-search-trigger-text {
flex: 1 !important;
white-space: nowrap !important;
overflow: hidden !important;
text-overflow: ellipsis !important;
text-align: left !important;
}
.yaktube-search-trigger-shortcut {
font-size: 11px !important;
background: #252530 !important;
color: #aaa !important;
padding: 2px 6px !important;
border-radius: 6px !important;
border: 1px solid rgba(255, 255, 255, 0.1) !important;
}
/* Circular Voice Button in Header */
.yaktube-voice-search-btn { .yaktube-voice-search-btn {
background: #1f1f1f !important; background: #1f1f1f !important;
color: #f1f1f1 !important; color: #f1f1f1 !important;
@@ -494,11 +502,13 @@ my-search-typeahead,
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
} }
.yaktube-voice-search-btn:hover { .yaktube-voice-search-btn:hover,
.yaktube-voice-search-btn:focus {
background: #2a2a2a !important; background: #2a2a2a !important;
border-color: #ff8f37 !important; border-color: #ff8f37 !important;
color: #ff8f37 !important; color: #ff8f37 !important;
transform: scale(1.06) !important; transform: scale(1.06) !important;
outline: none !important;
} }
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
@@ -513,11 +523,15 @@ my-search-typeahead,
background: rgba(0, 0, 0, 0.82) !important; background: rgba(0, 0, 0, 0.82) !important;
backdrop-filter: blur(12px) !important; backdrop-filter: blur(12px) !important;
z-index: 999999 !important; z-index: 999999 !important;
display: flex !important; display: none;
flex-direction: column !important; flex-direction: column !important;
align-items: center !important; align-items: center !important;
justify-content: flex-start !important; justify-content: flex-start !important;
padding-top: 40px !important; padding-top: 40px !important;
}
.yaktube-full-search-modal.yaktube-modal-open {
display: flex !important;
animation: yaktube-fade-in 0.2s ease-out !important; animation: yaktube-fade-in 0.2s ease-out !important;
} }