Fix new search bar - you can now finally search again
This commit is contained in:
@@ -222,10 +222,17 @@ $(document).on('swipeleft', function () {
|
||||
}
|
||||
});
|
||||
|
||||
function closeSearch() {
|
||||
$('.navbar.search-open').removeClass('search-open')
|
||||
.find('.navbar-search input').val('');
|
||||
}
|
||||
$('#search-form').submit((e) => {
|
||||
e.preventDefault();
|
||||
|
||||
executeSearch();
|
||||
});
|
||||
|
||||
$('.navbar-search input').on('keyup', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
$('#search-form').submit();
|
||||
}
|
||||
});
|
||||
|
||||
function executeSearch() {
|
||||
const search = $('.navbar-search input').val().trim();
|
||||
@@ -250,12 +257,8 @@ function executeSearch() {
|
||||
},
|
||||
method: 'GET',
|
||||
success: data => {
|
||||
// $('html').children().remove()[0].outerHTML = data;
|
||||
document.write(data);
|
||||
document.close();
|
||||
// const newBody = $('body > *:not(header):not(footer):not(#bottom)', $(data));
|
||||
// console.log(newBody);
|
||||
// $('.loadingSpinner').after(newBody);
|
||||
},
|
||||
error: data => {
|
||||
console.log(data);
|
||||
@@ -263,57 +266,6 @@ function executeSearch() {
|
||||
});
|
||||
}
|
||||
|
||||
$('#searchButton').on('click', (e) => {
|
||||
e.preventDefault();
|
||||
const navbar = $('.navbar');
|
||||
if (navbar.hasClass('search-open')) {
|
||||
const search = $('.navbar-search input').val().trim();
|
||||
|
||||
if (search.length > 0) {
|
||||
executeSearch();
|
||||
} else {
|
||||
closeSearch();
|
||||
}
|
||||
} else {
|
||||
navbar.addClass('search-open');
|
||||
$('.navbar .navbar-search input').focus();
|
||||
}
|
||||
});
|
||||
|
||||
$('#searchResetButton').on('click', (e) => {
|
||||
e.preventDefault();
|
||||
closeSearch();
|
||||
});
|
||||
|
||||
$('body').on('keyup', (e) => {
|
||||
if ($('.navbar').hasClass('search-open') && e.key === 'Escape') {
|
||||
closeSearch();
|
||||
}
|
||||
});
|
||||
|
||||
$('.navbar-search input').on('keyup', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
executeSearch()
|
||||
}
|
||||
});
|
||||
|
||||
$('.navbar-search:not(.active) .btn-search').click(function (event) {
|
||||
event.preventDefault();
|
||||
const $form = $(this).closest('form'),
|
||||
$input = $form.find('input');
|
||||
$form.addClass('active');
|
||||
$input.focus();
|
||||
});
|
||||
|
||||
$('.navbar-search.active .btn-search').click(function (event) {
|
||||
event.preventDefault();
|
||||
const $form = $(this).closest('form'),
|
||||
$input = $form.find('input');
|
||||
//TODO: Execute search
|
||||
|
||||
closeSearch();
|
||||
});
|
||||
|
||||
$(function () {
|
||||
$.each($(".share-btn"), function () {
|
||||
$(this).on("click", function (event) {
|
||||
@@ -388,6 +340,18 @@ $('#notificationMenuButton').click(() => {
|
||||
});
|
||||
});
|
||||
|
||||
$(() => {
|
||||
$('.max-length-input').each(function () {
|
||||
console.log(this);
|
||||
$(this).after(`<span class="max-length-counter">${$(this).attr('max-length')}</span>`);
|
||||
});
|
||||
});
|
||||
|
||||
$('.max-length-input').keypress(function () {
|
||||
const val = $(this).val() || $(this).text();
|
||||
$(this).next('.max-length-counter').text($(this).attr('max-length') - val.trim().length);
|
||||
});
|
||||
|
||||
const notificationCount = 5;
|
||||
let notificationOffset = 0;
|
||||
|
||||
@@ -485,7 +449,7 @@ function openAsyncModal(url, title, data, finished, id, size = 'default') {
|
||||
success: (result) => {
|
||||
console.log(result);
|
||||
modal.find('.modal-body').empty();
|
||||
if(result.success) {
|
||||
if (result.success) {
|
||||
modal.find('.modal-title').text(result.title);
|
||||
modal.find('.modal-body').append(result.body);
|
||||
finished();
|
||||
@@ -501,7 +465,7 @@ function openAsyncModal(url, title, data, finished, id, size = 'default') {
|
||||
}
|
||||
});
|
||||
|
||||
modal.on('hidden.bs.modal', function() {
|
||||
modal.on('hidden.bs.modal', function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user