' : '') +
'';
});
if (d.results.length > 6) {
html += '';
}
$dd.html(html).show();
}, function () {
$dd.html('
Fehler bei der Suche.
');
});
}, 320);
});
// Alle Ergebnisse anzeigen → zur Suchseite
$(document).on('click', '.wbf-search-dd-footer', function () {
var q = $(this).data('query');
window.location.href = window.location.pathname + '?forum_search=1&q=' + encodeURIComponent(q);
});
// Enter-Taste → Suchseite
$(document).on('keydown', '#wbfSearchInput', function (e) {
if (e.key === 'Enter') {
var q = $(this).val().trim();
if (q.length >= 2) {
window.location.href = window.location.pathname + '?forum_search=1&q=' + encodeURIComponent(q);
}
}
if (e.key === 'Escape') { $('#wbfSearchDropdown').hide(); }
});
// Dropdown schließen bei Klick außerhalb
$(document).on('click', function (e) {
if (!$(e.target).closest('#wbfSearchForm').length) {
$('#wbfSearchDropdown').hide();
}
});
/* ══════════════════════════════════════════════════════════
FEATURE: Benachrichtigungen
══════════════════════════════════════════════════════════ */
var wbfNotifLoaded = false;
function wbfLoadNotifications() {
wbfPost('wbf_get_notifications', {}, function (d) {
var $list = $('#wbfNotifList');
if (!d.notifications || !d.notifications.length) {
$list.html('
Keine Benachrichtigungen
');
return;
}
var html = '';
d.notifications.forEach(function (n) {
var isUnread = n.is_read == 0;
var avatar = n.actor_avatar || '';
var base = WBF.forum_url || window.location.href.split('?')[0];
var sep = base.indexOf('?') !== -1 ? '&' : '?';
var actor = '' + $('').text(n.actor_name).html() + '';
// URL + Text je nach Typ
var url, text, sub;
if (n.type === 'message') {
url = base + sep + 'forum_dm=1';
text = actor + ' hat dir eine Nachricht gesendet';
sub = '';
} else if (n.type === 'mention') {
url = base + sep + 'forum_thread=' + n.thread_id;
text = actor + ' hat dich erwähnt';
sub = n.thread_title || '';
} else if (n.type === 'like') {
url = base + sep + 'forum_thread=' + n.thread_id;
text = actor + ' hat deinen Beitrag geliket';
sub = n.thread_title || '';
} else {
// reply (default)
url = base + sep + 'forum_thread=' + n.thread_id;
text = actor + ' hat in deinem Thread geantwortet';
sub = n.thread_title || '';
}
html += '' +
'
');
$ta.closest('.wbf-reply-form__input, .wbf-form-row').append($wbfMentionDrop);
$wbfMentionDrop.show();
});
}, 200);
});
$(document).on('click', '.wbf-mention-item', function(e) {
e.stopPropagation();
var username = $(this).data('username');
var $ta = $('#wbfReplyContent:visible, #wbfThreadContent:visible').first();
if (!$ta.length) return;
var val = $ta.val(), pos = $ta[0].selectionStart;
var before = val.slice(0, pos);
var after = val.slice(pos);
var newBefore = before.replace(/@([a-zA-Z0-9_]*)$/, '@' + username + ' ');
$ta.val(newBefore + after);
$ta[0].selectionStart = $ta[0].selectionEnd = newBefore.length;
wbfCloseMention();
$ta.focus();
});
$(document).on('click', function(e) {
if (!$(e.target).closest('.wbf-mention-dropdown').length) wbfCloseMention();
});
/* ══════════════════════════════════════════════════════════
FEATURE: Private Nachrichten (DM)
══════════════════════════════════════════════════════════ */
// Helper: format messages in conversation
function wbfRenderMessages(msgs, myId) {
if (!msgs || !msgs.length) {
return '
Noch keine Nachrichten.
';
}
var html = '';
msgs.forEach(function(m) {
var isMine = parseInt(m.from_id) === parseInt(myId);
var cls = isMine ? 'wbf-dm-msg wbf-dm-msg--out' : 'wbf-dm-msg wbf-dm-msg--in';
var time = wbfTimeAgo(m.created_at);
var delBtn = '';
if (!isMine) {
html += '