mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 19:42:38 +02:00
Updates
This commit is contained in:
parent
55d555de36
commit
5e092a67d4
4 changed files with 821 additions and 481 deletions
File diff suppressed because it is too large
Load diff
|
@ -660,6 +660,16 @@ class API extends PluginAbstract {
|
||||||
|
|
||||||
if (empty($parameters['noRelated'])) {
|
if (empty($parameters['noRelated'])) {
|
||||||
$rows[$key]['relatedVideos'] = Video::getRelatedMovies($rows[$key]['id']);
|
$rows[$key]['relatedVideos'] = Video::getRelatedMovies($rows[$key]['id']);
|
||||||
|
foreach ($rows[$key]['relatedVideos'] as $key2 => $value2) {
|
||||||
|
$rows[$key]['relatedVideos'][$key2]['tags'] = Video::getTags($value2['id']);
|
||||||
|
if (AVideoPlugin::isEnabledByName("VideoTags")) {
|
||||||
|
$rows[$key]['relatedVideos'][$key2]['videoTags'] = Tags::getAllFromVideosId($value2['id']);
|
||||||
|
$rows[$key]['relatedVideos'][$key2]['videoTagsObject'] = Tags::getObjectFromVideosId($value2['id']);
|
||||||
|
}
|
||||||
|
if ($rows[$key]['relatedVideos'][$key2]['type'] !== 'linkVideo') {
|
||||||
|
$rows[$key]['relatedVideos'][$key2]['videos'] = Video::getVideosPaths($value2['filename'], true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$rows[$key]['adsImages'] = array();
|
$rows[$key]['adsImages'] = array();
|
||||||
if (!empty($objAds)) {
|
if (!empty($objAds)) {
|
||||||
|
|
|
@ -1,71 +1,76 @@
|
||||||
|
<?php
|
||||||
|
$global['doNotSearch'] = 1;
|
||||||
|
$tags = TagsHasVideos::getAllWithVideo();
|
||||||
|
$global['doNotSearch'] = 0;
|
||||||
|
?>
|
||||||
<style>
|
<style>
|
||||||
#searchOptionsMenu {
|
#searchOptionsMenu {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
z-index: 1029;
|
z-index: 1029;
|
||||||
}
|
}
|
||||||
|
|
||||||
#searchOptionsMenu > div {
|
#searchOptionsMenu > div {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
#searchFieldsNamesBelowNavbar-dropdown , #catNameBelowNavbar-dropdown {
|
#searchFieldsNamesBelowNavbar-dropdown , #catNameBelowNavbar-dropdown , #tagNameBelowNavbar-dropdown {
|
||||||
min-width: 150px;
|
min-width: 150px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
#searchFieldsNamesBelowNavbar-dropdown {
|
#searchFieldsNamesBelowNavbar-dropdown {
|
||||||
border-right-width: 0;
|
border-right-width: 0;
|
||||||
border-top-right-radius: 0;
|
border-top-right-radius: 0;
|
||||||
border-bottom-right-radius: 0;
|
border-bottom-right-radius: 0;
|
||||||
}
|
}
|
||||||
#catNameBelowNavbar-dropdown {
|
#catNameBelowNavbar-dropdown, #tagNameBelowNavbar-dropdown{
|
||||||
border-left-width: 0;
|
border-left-width: 0;
|
||||||
border-top-left-radius: 0;
|
border-top-left-radius: 0;
|
||||||
border-bottom-left-radius: 0;
|
border-bottom-left-radius: 0;
|
||||||
border-right-width: 0;
|
border-right-width: 0;
|
||||||
border-top-right-radius: 0;
|
border-top-right-radius: 0;
|
||||||
border-bottom-right-radius: 0;
|
border-bottom-right-radius: 0;
|
||||||
}
|
}
|
||||||
#searchOptionsButton {
|
#searchOptionsButton {
|
||||||
border-left-width: 0;
|
border-left-width: 0;
|
||||||
border-top-left-radius: 0;
|
border-top-left-radius: 0;
|
||||||
border-bottom-left-radius: 0;
|
border-bottom-left-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#searchOptionsMenu .panel {
|
#searchOptionsMenu .panel {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#searchOptionsMenu .panel-body {
|
#searchOptionsMenu .panel-body {
|
||||||
max-height: 60vh;
|
max-height: 60vh;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#searchOptionsMenu .form-check {
|
#searchOptionsMenu .form-check {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
#searchOptionsMenu .form-check-input {
|
#searchOptionsMenu .form-check-input {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#searchOptionsMenu .form-check-label {
|
#searchOptionsMenu .form-check-label {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
#searchOptionsMenu .dropdown-menu-right {
|
#searchOptionsMenu .dropdown-menu-right {
|
||||||
right: 0;
|
right: 0;
|
||||||
left: auto;
|
left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<div class="container" id="searchOptionsMenu">
|
<div class="container" id="searchOptionsMenu">
|
||||||
|
@ -73,21 +78,22 @@
|
||||||
<div class="btn-group-justified">
|
<div class="btn-group-justified">
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"
|
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"
|
||||||
id="searchFieldsNamesBelowNavbar-dropdown" ><?php echo __('Search in'); ?>: <span class="badge">0</span>
|
id="searchFieldsNamesBelowNavbar-dropdown" ><?php echo __('Search in'); ?>: <span class="badge">0</span>
|
||||||
<span class="caret"></span></button>
|
<span class="caret"></span></button>
|
||||||
<div class="panel panel-default dropdown-menu dropdown-menu-right">
|
<div class="panel panel-default dropdown-menu dropdown-menu-right">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<?php
|
<?php
|
||||||
AVideoPlugin::loadPlugin('Layout');
|
AVideoPlugin::loadPlugin('Layout');
|
||||||
foreach (Layout::$searchOptions as $key => $value) {
|
foreach (Layout::$searchOptions as $key => $value) {
|
||||||
?>
|
?>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="checkbox" value="<?php echo $value['value']; ?>" id="filterCheck<?php echo $key; ?>" name="searchFieldsNamesBelowNavbar[]">
|
<input class="form-check-input" type="checkbox" value="<?php echo $value['value']; ?>"
|
||||||
|
id="filterCheck<?php echo $key; ?>" name="searchFieldsNamesBelowNavbar[]">
|
||||||
<label class="form-check-label" for="filterCheck<?php echo $key; ?>">
|
<label class="form-check-label" for="filterCheck<?php echo $key; ?>">
|
||||||
<?php echo $value['text']; ?>
|
<?php echo $value['text']; ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -95,7 +101,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" id="catNameBelowNavbar-dropdown">
|
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" id="catNameBelowNavbar-dropdown">
|
||||||
<i class="fas fa-list"></i> <?php echo __('All Categories'); ?>
|
<i class="fas fa-list"></i> <?php echo __('All Categories'); ?>
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
<div class="panel panel-default dropdown-menu dropdown-menu-right">
|
<div class="panel panel-default dropdown-menu dropdown-menu-right">
|
||||||
|
@ -111,14 +117,43 @@
|
||||||
$categories_edit = Category::getAllCategories(false, true);
|
$categories_edit = Category::getAllCategories(false, true);
|
||||||
$global['doNotSearch'] = 0;
|
$global['doNotSearch'] = 0;
|
||||||
foreach ($categories_edit as $key => $value) {
|
foreach ($categories_edit as $key => $value) {
|
||||||
?>
|
?>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" value="<?php echo $value['clean_name']; ?>" id="catNameBelowNavbar<?php echo $value['id']; ?>" name="catNameBelowNavbar">
|
<input class="form-check-input" type="radio" value="<?php echo $value['clean_name']; ?>" id="catNameBelowNavbar<?php echo $value['id']; ?>" name="catNameBelowNavbar">
|
||||||
<label class="form-check-label" for="catNameBelowNavbar<?php echo $value['id']; ?>">
|
<label class="form-check-label" for="catNameBelowNavbar<?php echo $value['id']; ?>">
|
||||||
<span class="content"><i class="<?php echo $value['iconClass']; ?>"></i> <?php echo __($value['hierarchyAndName']); ?></span>
|
<span class="content"><i class="<?php echo $value['iconClass']; ?>"></i> <?php echo __($value['hierarchyAndName']); ?></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="dropdown">
|
||||||
|
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" id="tagNameBelowNavbar-dropdown">
|
||||||
|
<i class="fas fa-tags"></i> <?php echo __('Tags'); ?>
|
||||||
|
<span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<div class="panel panel-default dropdown-menu dropdown-menu-right">
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" value="" id="filterTag0" name="tags_idBelowNavbar">
|
||||||
|
<label class="form-check-label" for="filterTag0">
|
||||||
|
<i class="fas fa-tags"></i> <?php echo __('All'); ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
foreach ($tags as $key => $value) {
|
||||||
|
?>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" value="<?php echo $value['id']; ?>"
|
||||||
|
id="filterTag<?php echo $value['id']; ?>" name="tags_idBelowNavbar">
|
||||||
|
<label class="form-check-label" for="filterTag<?php echo $value['id']; ?>">
|
||||||
|
<i class="fas fa-tag"></i> <?php echo __($value['name']); ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -132,41 +167,34 @@
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
var searchFieldsNamesBelowNavbarChecked = 'input[name="searchFieldsNamesBelowNavbar[]"]:checked';
|
var searchFieldsNamesBelowNavbarChecked = 'input[name="searchFieldsNamesBelowNavbar[]"]:checked';
|
||||||
var searchFieldsNamesBelowNavbarSearchFieldsNames = 'input[name="searchFieldsNamesBelowNavbar[]"], input[name="searchFieldsNames[]"]';
|
var searchFieldsNamesBelowNavbarSearchFieldsNames = 'input[name="searchFieldsNamesBelowNavbar[]"], input[name="searchFields[]"]';
|
||||||
var catNameBelowNavbarChecked = 'input[name="catNameBelowNavbar"]:checked';
|
var catNameBelowNavbarChecked = 'input[name="catNameBelowNavbar"]:checked';
|
||||||
var catNameBelowNavbarCatName = 'input[name="catNameBelowNavbar"], input.form-check-input[type="radio"][name="catName"]';
|
var catNameBelowNavbarCatName = 'input[name="catNameBelowNavbar"], input.form-check-input[type="radio"][name="catName"]';
|
||||||
$(document).ready(function() {
|
var tags_idBelowNavbarChecked = 'input[name="tags_idBelowNavbar"]:checked';
|
||||||
// Show the default button label for the searchFieldsNamesBelowNavbar dropdown
|
var tags_idBelowNavbar = 'input[name="tags_idBelowNavbar"]';
|
||||||
var defaultText = $('#searchFieldsNamesBelowNavbar-dropdown').text().trim();
|
$(document).ready(function () {
|
||||||
|
|
||||||
$(searchFieldsNamesBelowNavbarSearchFieldsNames).on('change', function() {
|
$(searchFieldsNamesBelowNavbarSearchFieldsNames).on('change', function () {
|
||||||
var val = $(this).val();
|
checkAllSearchFilter('#searchNavItem', $(this).val(), $(this).prop('checked'));
|
||||||
var $otherCheckbox = $('input[value="' + val + '"]').not($(this));
|
|
||||||
$otherCheckbox.prop('checked', $(this).prop('checked'));
|
|
||||||
$('#searchFieldsNamesBelowNavbar-dropdown .badge').text($(searchFieldsNamesBelowNavbarChecked).length);
|
|
||||||
saveSearchFiltersToCookie();
|
saveSearchFiltersToCookie();
|
||||||
setSearchFilterIcon();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(catNameBelowNavbarCatName).on('change', function() {
|
$(catNameBelowNavbarCatName).on('change', function () {
|
||||||
var val = $(this).val();
|
checkAllSearchFilter('#searchNavItem', $(this).val(), $(this).prop('checked'));
|
||||||
var $otherRadio = $('input[value="' + val + '"]').not($(this));
|
|
||||||
$otherRadio.prop('checked', $(this).prop('checked'));
|
|
||||||
var selectedText = $(catNameBelowNavbarChecked).parent().find('span.content').html();
|
|
||||||
$('#catNameBelowNavbar-dropdown').html(selectedText+' <span class="caret"></span>');
|
|
||||||
saveSearchCategoryToCookie();
|
saveSearchCategoryToCookie();
|
||||||
setSearchFilterIcon();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(searchFieldsNamesBelowNavbarSearchFieldsNames).on('click', function() {
|
$(tags_idBelowNavbar).on('change', function () {
|
||||||
|
checkAllSearchFilter('#searchNavItem', $(this).val(), $(this).prop('checked'));
|
||||||
|
saveSearchTagToCookie();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(searchFieldsNamesBelowNavbarSearchFieldsNames).on('click', function () {
|
||||||
$(this).trigger('change');
|
$(this).trigger('change');
|
||||||
});
|
});
|
||||||
$('#searchOptionsMenu label').click(function(e) {
|
$('#searchOptionsMenu label').click(function (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
filterCheckboxes.trigger('change');
|
|
||||||
categoryRadios.trigger('change');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function searchOptionsButton() {
|
function searchOptionsButton() {
|
||||||
|
@ -184,4 +212,5 @@
|
||||||
|
|
||||||
$('#searchForm').submit();
|
$('#searchForm').submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
|
@ -12,17 +12,17 @@ $global['doNotSearch'] = 0;
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group" id="mysearch">
|
<div class="input-group" id="mysearch">
|
||||||
<form class="navbar-form form-inline input-group" role="search" id="searchForm" method="get" action="<?php echo $global['webSiteRootURL']; ?>" >
|
<form class="navbar-form form-inline input-group" role="search" id="searchForm" method="get" action="<?php echo $global['webSiteRootURL']; ?>">
|
||||||
<span class="input-group-prepend">
|
<span class="input-group-prepend">
|
||||||
<button type="button" id="filterButton" class="btn btn-default navbar-btn dropdown-toggle faa-parent animated-hover animate__animated animate__bounceIn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<button type="button" id="filterButton" class="btn btn-default navbar-btn dropdown-toggle faa-parent animated-hover animate__animated animate__bounceIn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<i class="fas fa-sort-down"></i>
|
<i class="fas fa-sort-down"></i>
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
<input class="form-control globalsearchfield" type="text" value="<?php
|
<input class="form-control globalsearchfield" type="text" value="<?php
|
||||||
if (!empty($_GET['search'])) {
|
if (!empty($_GET['search'])) {
|
||||||
echo htmlentities($_GET['search']);
|
echo htmlentities($_GET['search']);
|
||||||
}
|
}
|
||||||
?>" name="search" placeholder="<?php echo __("Search"); ?>" id="searchFormInput">
|
?>" name="search" placeholder="<?php echo __("Search"); ?>" id="searchFormInput">
|
||||||
<span class="input-group-append">
|
<span class="input-group-append">
|
||||||
<button class="btn btn-default btn-outline-secondary border-right-0 border py-2 faa-parent animated-hover" type="submit" id="buttonSearch" data-toggle="collapse" data-target="#mysearch">
|
<button class="btn btn-default btn-outline-secondary border-right-0 border py-2 faa-parent animated-hover" type="submit" id="buttonSearch" data-toggle="collapse" data-target="#mysearch">
|
||||||
<i class="fas fa-search faa-shake"></i>
|
<i class="fas fa-search faa-shake"></i>
|
||||||
|
@ -43,14 +43,14 @@ if (!empty($_GET['search'])) {
|
||||||
<?php
|
<?php
|
||||||
AVideoPlugin::loadPlugin('Layout');
|
AVideoPlugin::loadPlugin('Layout');
|
||||||
foreach (Layout::$searchOptions as $key => $value) {
|
foreach (Layout::$searchOptions as $key => $value) {
|
||||||
?>
|
?>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="checkbox" value="<?php echo $value['value']; ?>" id="filterCheck<?php echo $key; ?>" name="searchFieldsNames[]">
|
<input class="form-check-input" type="checkbox" value="<?php echo $value['value']; ?>" id="filterCheck<?php echo $key; ?>" name="searchFieldsNames[]">
|
||||||
<label class="form-check-label" for="filterCheckTitle">
|
<label class="form-check-label" for="filterCheckTitle">
|
||||||
<?php echo $value['text']; ?>
|
<?php echo $value['text']; ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -58,7 +58,7 @@ if (!empty($_GET['search'])) {
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" id="search_category0" name="catName" checked value="">
|
<input class="form-check-input" type="radio" id="search_category0" name="catName" checked value="">
|
||||||
<label class="form-check-label" for="search_category0">
|
<label class="form-check-label" for="search_category0">
|
||||||
<i class="fas fa-list"></i> <?php echo __('All Categories'); ?>
|
<i class="fas fa-list"></i> <?php echo __('All'); ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
@ -66,28 +66,34 @@ if (!empty($_GET['search'])) {
|
||||||
$categories_edit = Category::getAllCategories(false, true);
|
$categories_edit = Category::getAllCategories(false, true);
|
||||||
$global['doNotSearch'] = 0;
|
$global['doNotSearch'] = 0;
|
||||||
foreach ($categories_edit as $key => $value) {
|
foreach ($categories_edit as $key => $value) {
|
||||||
?>
|
?>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" value="<?php echo $value['clean_name']; ?>" id="search_category<?php echo $value['id']; ?>" name="catName">
|
<input class="form-check-input" type="radio" value="<?php echo $value['clean_name']; ?>" id="search_category<?php echo $value['id']; ?>" name="catName">
|
||||||
<label class="form-check-label" for="search_category<?php echo $value['id']; ?>">
|
<label class="form-check-label" for="search_category<?php echo $value['id']; ?>">
|
||||||
<i class="<?php echo $value['iconClass']; ?>"></i> <?php echo __($value['hierarchyAndName']); ?>
|
<i class="<?php echo $value['iconClass']; ?>"></i> <?php echo __($value['hierarchyAndName']); ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<div id="filter-tags-tab" class="tab-pane fade">
|
<div id="filter-tags-tab" class="tab-pane fade">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" value="" id="search_tag0" name="tags_id">
|
||||||
|
<label class="form-check-label" for="search_tag0">
|
||||||
|
<i class="fas fa-tags"></i> <?php echo __('All'); ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<?php
|
<?php
|
||||||
foreach ($tags as $key => $value) {
|
foreach ($tags as $key => $value) {
|
||||||
?>
|
?>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" value="<?php echo $value['id']; ?>" id="search_tag<?php echo $value['id']; ?>" name="tags_id">
|
<input class="form-check-input" type="radio" value="<?php echo $value['id']; ?>" id="search_tag<?php echo $value['id']; ?>" name="tags_id">
|
||||||
<label class="form-check-label" for="search_tag<?php echo $value['id']; ?>">
|
<label class="form-check-label" for="search_tag<?php echo $value['id']; ?>">
|
||||||
<i class="fas fa-tag"></i> <?php echo __($value['name']); ?>
|
<i class="fas fa-tag"></i> <?php echo __($value['name']); ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -106,37 +112,41 @@ if (!empty($_GET['search'])) {
|
||||||
<script>
|
<script>
|
||||||
var filterCheckboxes;
|
var filterCheckboxes;
|
||||||
var categoryRadios;
|
var categoryRadios;
|
||||||
|
var tagsRadios;
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function() {
|
||||||
// get references to the checkboxes and radio buttons
|
// get references to the checkboxes and radio buttons
|
||||||
filterCheckboxes = $('input[name="searchFieldsNames[]"]');
|
filterCheckboxes = $('input[name="searchFieldsNames[]"]');
|
||||||
categoryRadios = $('input.form-check-input[type="radio"][name="catName"]');
|
categoryRadios = $('input.form-check-input[type="radio"][name="catName"]');
|
||||||
|
tagsRadios = $('input.form-check-input[type="radio"][name="tags_id"]');
|
||||||
|
|
||||||
// add event listeners to the checkboxes and radio buttons
|
// add event listeners to the checkboxes and radio buttons
|
||||||
filterCheckboxes.on('change', function () {
|
filterCheckboxes.on('change', function() {
|
||||||
console.log('filterCheckboxes.filter change');
|
checkAllSearchFilter('#searchOptionsMenu', $(this).val(), $(this).prop('checked'));
|
||||||
// save the checked values to the cookie
|
// save the checked values to the cookie
|
||||||
saveSearchFiltersToCookie();
|
saveSearchFiltersToCookie();
|
||||||
|
|
||||||
setSearchFilterIcon();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
categoryRadios.on('change', function () {
|
categoryRadios.on('change', function() {
|
||||||
// save the checked value to the cookie
|
checkAllSearchFilter('#searchOptionsMenu', $(this).val(), $(this).prop('checked'));
|
||||||
saveSearchCategoryToCookie();
|
saveSearchCategoryToCookie();
|
||||||
|
});
|
||||||
|
|
||||||
setSearchFilterIcon();
|
tagsRadios.on('change', function() {
|
||||||
|
checkAllSearchFilter('#searchOptionsMenu', $(this).val(), $(this).prop('checked'));
|
||||||
|
saveSearchTagToCookie();
|
||||||
});
|
});
|
||||||
|
|
||||||
// load the saved search filters from the cookies
|
// load the saved search filters from the cookies
|
||||||
const savedFilters = Cookies.get('searchFilters');
|
const savedFilters = Cookies.get('searchFilters');
|
||||||
const savedCategory = Cookies.get('searchCategory');
|
const savedCategory = Cookies.get('searchCategory');
|
||||||
|
const savedSearchTag = Cookies.get('searchTag');
|
||||||
|
|
||||||
if (savedFilters) {
|
if (savedFilters) {
|
||||||
// parse the saved filters from JSON and check the corresponding checkboxes
|
// parse the saved filters from JSON and check the corresponding checkboxes
|
||||||
const checkedValues = JSON.parse(savedFilters);
|
const checkedValues = JSON.parse(savedFilters);
|
||||||
|
|
||||||
filterCheckboxes.each(function () {
|
filterCheckboxes.each(function() {
|
||||||
this.checked = checkedValues.includes(this.value);
|
this.checked = checkedValues.includes(this.value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -148,17 +158,28 @@ if (!empty($_GET['search'])) {
|
||||||
// check the default radio button
|
// check the default radio button
|
||||||
categoryRadios.filter('#search_category0').prop('checked', true);
|
categoryRadios.filter('#search_category0').prop('checked', true);
|
||||||
}
|
}
|
||||||
setSearchFilterIcon();
|
|
||||||
|
|
||||||
$('#filterButton').click(function () {
|
if (savedSearchTag) {
|
||||||
|
// check the corresponding radio button
|
||||||
|
$('input[name="tags_id"][value="' + savedSearchTag + '"]').prop('checked', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$('#filterButton').click(function() {
|
||||||
$('#filterDropdown').toggleClass('show');
|
$('#filterDropdown').toggleClass('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
filterCheckboxes.trigger('change');
|
||||||
|
categoryRadios.trigger('change');
|
||||||
|
tagsRadios.trigger('change');
|
||||||
});
|
});
|
||||||
|
|
||||||
function saveSearchFiltersToCookie() {
|
function saveSearchFiltersToCookie() {
|
||||||
const checkedValues = filterCheckboxes.filter(':checked').map(function () {
|
const checkedValues = filterCheckboxes.filter(':checked').map(function() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}).get();
|
}).get();
|
||||||
|
|
||||||
|
$('#searchFieldsNamesBelowNavbar-dropdown .badge').text(checkedValues.length);
|
||||||
Cookies.set('searchFilters', JSON.stringify(checkedValues), {
|
Cookies.set('searchFilters', JSON.stringify(checkedValues), {
|
||||||
expires: 365,
|
expires: 365,
|
||||||
path: '/'
|
path: '/'
|
||||||
|
@ -167,15 +188,27 @@ if (!empty($_GET['search'])) {
|
||||||
|
|
||||||
function saveSearchCategoryToCookie() {
|
function saveSearchCategoryToCookie() {
|
||||||
const checkedValue = categoryRadios.filter(':checked').val();
|
const checkedValue = categoryRadios.filter(':checked').val();
|
||||||
|
var selectedText = categoryRadios.filter(':checked').parent().find('label').html();
|
||||||
|
$('#catNameBelowNavbar-dropdown').html(selectedText + ' <span class="caret"></span>');
|
||||||
Cookies.set('searchCategory', checkedValue, {
|
Cookies.set('searchCategory', checkedValue, {
|
||||||
expires: 365,
|
expires: 365,
|
||||||
path: '/'
|
path: '/'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveSearchTagToCookie() {
|
||||||
|
const searchTagValue = $('input[name="tags_id"]:checked').val();
|
||||||
|
var selectedText = $('input[name="tags_id"]:checked').parent().find('label').html();
|
||||||
|
$('#tagNameBelowNavbar-dropdown').html(selectedText + ' <span class="caret"></span>');
|
||||||
|
Cookies.set('searchTag', searchTagValue, {
|
||||||
|
expires: 365,
|
||||||
|
path: '/'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function setSearchFilterIcon() {
|
function setSearchFilterIcon() {
|
||||||
// check if no filter checkboxes are checked and search_category0 is checked
|
// check if no filter checkboxes are checked and search_category0 is checked and search_tag0 is checked
|
||||||
if (filterCheckboxes.filter(':checked').length === 0 && $('#search_category0').is(':checked')) {
|
if (filterCheckboxes.filter(':checked').length === 0 && $('#search_category0').is(':checked') && $('input[name="tags_id"]:checked').val() == '') {
|
||||||
// add the text-muted icon to the filterButton
|
// add the text-muted icon to the filterButton
|
||||||
$('#filterButton i').removeClass('fa-filter');
|
$('#filterButton i').removeClass('fa-filter');
|
||||||
$('#filterButton i').addClass('fa-sort-down');
|
$('#filterButton i').addClass('fa-sort-down');
|
||||||
|
@ -185,4 +218,13 @@ if (!empty($_GET['search'])) {
|
||||||
$('#filterButton i').addClass('fa-filter');
|
$('#filterButton i').addClass('fa-filter');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkAllSearchFilter(parentSelector, value, checked) {
|
||||||
|
$(parentSelector + ' input[type="checkbox"], ' + parentSelector + ' input[type="radio"]').each(function() {
|
||||||
|
if ($(this).val() === value) {
|
||||||
|
$(this).prop('checked', checked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setSearchFilterIcon();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue