FILTER-FINDER-FUNCTION (Sonstige Elemente )
src/app/shared/components/filter-finder-function/templates
Demo Section
Each variation will be presented in the following section.
Readme
filterFinderFunction (component
)
Description
This blueprint is based on the blueprint of Veams.
Requirements
Veams#5.0.0
Installation
Installation with Veams from local machine
veams install bp absolute/filepath/to/filter-finder-function
Fields
filter-finder-function.hbs
The partial is a wrapWith
partial. This means that you can access all properties and hashes via props
.
See Mangony Handlebars Helper - wrapWith for detailed instructions.
Settings
Parameter | Type | Default | Description |
---|---|---|---|
settings.filterFinderFunctionClasses | String | '' |
Modifier classes for component |
settings.filterFinderFunctionContextClass | String | 'default' |
Context class of component |
Content
Parameter | Type | Description |
---|---|---|
content.filterFinderFunctionField | String | Please add a description! |
SASS
Variables
There are multiple variables which you can change:
Variable | Value | Description |
---|---|---|
$filter-finder-function-my-custom-var | 0px |
Please add a description! |
Modifier Classes
There are modifier classes you can add to c-filter-finder-function
:
Modifier | Description |
---|---|
is-modifier | Please add a description! |
Templates
filter-finder-function.hbs
<div class="c-filter-finder-function{{#if settings.filterFinderFunctionContextClass}}--{{settings.filterFinderFunctionContextClass}}{{else}}--default{{/if}}{{#if settings.filterFinderFunctionClasses}} {{settings.filterFinderFunctionClasses}}{{/if}}"
data-css="c-filter-finder-function" data-js-module="filter-finder-function">
<form class="c-form--default"
action="{{#if @root.servermode}}{{props.settings.formAction}}{{else}}{{props.settings.formActionQA}}{{/if}}"
method="{{props.settings.formMethod}}"
data-css="c-form"
{{#if options.settings.formAjax}}
data-js-module="filter-course-finder"
{{#if props.settings.formJsOptions}}
data-js-options='{{stringify props.settings.formJsOptions}}'{{/if}}{{/if}}{{#if settings.formJsItem}} data-js-item="{{settings.formJsItem}}"{{/if}}>
<div class="filter-finder-function__row">
{{#each content.filterinput}}
<div class="filter-finder-function__col{{#if settings.colClasses}} {{settings.colClasses}}{{/if}}">
{{> form__input}}
</div>
{{/each}}
{{#each content.filterselect}}
<div class="filter-finder-function__col{{#if settings.colClasses}} {{settings.colClasses}}{{/if}}">
{{> form__select}}
</div>
{{/each}}
{{#each content.filtercheckbox}}
<div class="filter-finder-function__col{{#if settings.colClasses}} {{settings.colClasses}}{{/if}}">
{{> form__checkbox}}
</div>
{{/each}}
{{#each content.filterradio}}
<div class="filter-finder-function__col{{#if settings.colClasses}} {{settings.colClasses}}{{/if}}">
{{> form__radio}}
</div>
{{/each}}
{{#each content.filterselectmultiple}}
<div class="filter-finder-function__col{{#if settings.colClasses}} {{settings.colClasses}}{{/if}}">
{{> form__select-multiple}}
</div>
{{/each}}
{{#each content.filtersubmit}}
<div class="filter-finder-function__col{{#if settings.colClasses}} {{settings.colClasses}}{{/if}}">
{{> form__submit}}
</div>
{{/each}}
<div class="filter-finder-function__col is-grid-col is-col-tablet-p-12" style="display: none">
<div class="filter-finder-function__filter-list" data-js-item="js-filter-finder-function-filter-list">
</div>
</div>
<div class="filter-finder-function__col is-grid-col is-col-tablet-p-12" style="display: none">
<div class="filter-finder-function__filter-reset" data-js-item="js-filter-finder-function-filter-reset">
<span>Filter zurücksetzen</span>
</div>
</div>
</div>
{{> filter-finder-function__list}}
</form>
</div>
filter-finder-function__list.hbs
<div class="filter-finder-function__result-container">
<div class="filter-finder-function__result-loader">
<span class="filter-finder-function__result-loader-box is-one"></span>
<span class="filter-finder-function__result-loader-box is-two"></span>
<span class="filter-finder-function__result-loader-box is-three"></span>
</div>
<div class="filter-finder-function__result-area" data-js-item="js-filter-finder-function-result-area">
<div class="filter-finder-function__result-wrapper">
<div class="filter-finder-function__result-info" data-js-item="js-filter-course-finder-results-info">
<p><span class="filter-finder-function__total-item-count">0</span> <strong>Ergebnisse</strong> zum Thema <strong>Forschen</strong></p>
</div>
<div class="filter-finder-function__result-order">
<div class="filter-finder-function__result-per-page" data-js-item="js-filter-finder-function-results-per-page">
<p>Ergebnisse pro Seite <a href="javascript:void(0);" class="results-per-page__1 is-selected">1</a> | <a href="javascript:void(0);" class="results-per-page__2">2</a> | <a href="javascript:void(0);" class="results-per-page__50">50</a></p>
</div>
<div class="filter-finder-function__result-sorting" data-css="c-form">
{{#each content.sorting}}
<div class="filter-finder-function__col{{#if settings.colClasses}} {{settings.colClasses}}{{/if}}">
{{> form__select}}
</div>
{{/each}}
</div>
</div>
</div>
<div class="filter-finder-function__result-wrapper-inner">
<div class="filter-finder-function__result-item" data-js-item="js-filter-finder-function-result-template">
<p><a class="filter-finder-function__results-item-link" href="">This is a Title</a></p>
<p class="filter-finder-function__results-item-description">This is a Description about the Result Item</p>
</div>
<div class="filter-finder-function__result" data-js-item="js-filter-finder-function-result-list">
</div>
<div class="filter-finder-function__pagination-wrapper">
<div class="filter-finder-function__pagination-list" data-js-item="js-filter-finder-function-pagination-area">
<a id="pagination__firs-page">«</a>
<a id="pagination__prev-page">‹</a>
<div id="pagination__numbers-of-page"></div>
<a id="pagination__next-page">›</a>
<a id="pagination__last-page">»</a>
</div>
</div>
</div>
</div>
<div class="filter-finder-function__result-error">
<p>We're sorry, but <strong>nothing fits</strong> your search term. <strong>Please try again</strong> with other keywords.</p>
</div>
</div>
Data File
filter-finder-function.hjson
{
"variations": {
"default": {
"docs": {
"variationName": "Default"
},
"settings": {
"formClasses": "c-filter-course-finder",
"formContextClass": "",
"yzContextClass": "default",
"filterCourseFinderClasses": "",
"formJsItem": "js-filter-finder-function-filter-form"
},
"content": {
"filterselect": [
{
"id": "sel_Type_value",
"settings": {
"colClasses": "is-grid-col is-col-mobile-s-12 is-col-tablet-p-6 is-col-tablet-l-3",
"inputClasses": "is-submit",
"id": "sel_Type_value",
"typeOf": "select",
"disabled": true,
"jsModule": true,
"attributes" : [
{
"attrKey": "class",
"attrValue": "form__select-input"
}
]
},
"content": {
"label": "Type",
"formSubmit": "Default Option",
"placeholder": "Select Option...",
"options": [
{
"settings": {
"selected": true,
"disabled": false
},
"content": {
"name": "Please choose..."
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"val": "Hauptfach",
"name": "Hauptfach"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"val": "Didaktikfach",
"name": "Didaktikfach"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"val": "Erweiterungsfach",
"name": "Erweiterungsfach"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"val": "Unterrichtsfach",
"name": "Unterrichtsfach"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"val": "Nebenfach",
"name": "Nebenfach"
}
}
]
}
},
{
"id": "sel_schooltyp",
"settings": {
"colClasses": "is-grid-col is-col-mobile-s-12 is-col-tablet-p-6 is-col-tablet-l-3",
"inputClasses": "is-submit",
"id": "sel_schooltyp",
"typeOf": "select",
"disabled": true,
"jsModule": true,
"attributes" : [
{
"attrKey": "class",
"attrValue": "form__select-input"
}
]
},
"content": {
"label": "Select Label",
"formSubmit": "Default Option",
"placeholder": "Select Option...",
"options": [
{
"settings": {
"selected": true,
"disabled": false
},
"content": {
"name": "Please choose..."
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"val": "option_1",
"name": "Option-1"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"val": "option_2",
"name": "Option-2"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"val": "option_3",
"name": "Option-3"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"val": "option_4",
"name": "Option-4"
}
}
]
}
}
],
"filterselectmultiple": [
{
"id": "mul_Type_value",
"settings": {
"colClasses": "is-grid-col is-col-mobile-s-12 is-col-tablet-p-6",
"inputClasses": "is-submit",
"id": "mul_Type_value",
"required": false,
"typeOf": "select-multiple",
"disabled": true,
"jsModule": true
},
"content": {
"label": "Type",
"formSubmit": "Default Option",
"placeholder": "Select Option...",
"options": [
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"id": "mul_Type_value→all",
"val": "all",
"name": "Select All",
"data": "select-multiple__all"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"id": "mul_Type_value→Hauptfach",
"val": "Hauptfach",
"name": "Hauptfach"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"id": "mul_Type_value→Didaktikfach",
"val": "Didaktikfach",
"name": "Didaktikfach"
}
},
{
"settings": {
"selected": false,
"disabled": true
},
"content": {
"id": "mul_Type_value→Erweiterungsfach",
"val": "Erweiterungsfach",
"name": "Erweiterungsfach"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"id": "mul_Type_value→Unterrichtsfach",
"val": "Unterrichtsfach",
"name": "Unterrichtsfach"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"id": "mul_Type_value→Nebenfach",
"val": "Nebenfach",
"name": "Nebenfach"
}
}
]
}
},
{
"id": "mul_Name_value",
"settings": {
"colClasses": "is-grid-col is-col-mobile-s-12 is-col-tablet-p-6",
"inputClasses": "is-submit",
"id": "mul_Name_value",
"required": false,
"typeOf": "select-multiple",
"disabled": true,
"jsModule": true
},
"content": {
"label": "Dropdown 100%",
"formSubmit": "Default Option",
"placeholder": "Select Option...",
"options": [
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"id": "mul_Name_value→all",
"val": "all",
"name": "Select All",
"data": "select-multiple__all"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"id": "mul_Name_value→Option1",
"val": "Option1",
"name": "Option name 1"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"id": "mul_Name_value→Option2",
"val": "Option2",
"name": "Option name 2"
}
},
{
"settings": {
"selected": false,
"disabled": true
},
"content": {
"id": "mul_Name_value→Option3",
"val": "Option3",
"name": "Option name 3"
}
}
]
}
}
],
"sorting": [
{
"id": "sorting",
"settings": {
"colClasses": "is-grid-col is-col-mobile-s-12",
"inputClasses": "is-submit",
"id": "sorting",
"typeOf": "select",
"disabled": true,
"jsModule": true,
"attributes" : [
{
"attrKey": "data-js-item",
"attrValue": "js-filter-course-finder-results-sorting"
}
]
},
"content": {
"label": "Sortierung",
"formSubmit": "Default Option",
"placeholder": "Select Option...",
"options": [
{
"settings": {
"selected": true,
"disabled": false
},
"content": {
"val": "sorting→asc",
"name": "A bis Z"
}
},
{
"settings": {
"selected": false,
"disabled": false
},
"content": {
"val": "sorting→desc",
"name": "Z bis A"
}
}
]
}
}
],
"filterinput": [
{
"settings": {
"colClasses": "is-grid-col is-col-mobile-s-12 is-col-tablet-p-6 is-col-tablet-l-3",
"id": "query",
"type": "text",
"typeOf": "input"
},
"content": {
"label": "Query",
"placeholder": "Enter a search term..."
}
}
],
"filtercheckbox": [
{
"settings": {
"colClasses": "is-grid-col is-col-mobile-s-12 is-col-tablet-p-6 is-col-tablet-l-3",
"typeOf": "checkbox",
"required": false,
"inputClasses": "is-checkboxes"
},
"content": {
"label": "Status",
"checkboxes": [
{
"settings": {
"wrapperClass": "is-wrapper",
"inputClass": false,
"required": false,
"dataAttr": true,
"id": "cbx_enrol_for_the_first_time",
"labelClasses": "is-label",
"attributes" : [
{
"attrKey": "value",
"attrValue": "enrol_for_the_first_time"
}
]
},
"content": {
"label": "Enrol for the first time"
}
}
],
"placeholder": "Suchbegriff eingeben"
}
},
{
"settings": {
"colClasses": "is-grid-col is-col-mobile-s-12 is-col-tablet-p-5",
"typeOf": "checkbox",
"required": true,
"inputClasses": "is-checkboxes"
},
"content": {
"label": "Start of Studies",
"checkboxes": [
{
"settings": {
"wrapperClass": "is-wrapper",
"inputClass": false,
"required": false,
"dataAttr": true,
"id": "cbx_Start_of_studies_value→auch_im_Sommersemester",
"labelClasses": "is-label",
"attributes" : [
{
"attrKey": "value",
"attrValue": "auch im Sommersemester"
}
]
},
"content": {
"label": "Auch im Sommersemester"
}
},
{
"settings": {
"wrapperClass": "is-wrapper",
"inputClass": false,
"required": false,
"dataAttr": true,
"id": "cbx_Start_of_studies_value→Studienbeginn_WiSe",
"labelClasses": "is-label",
"attributes" : [
{
"attrKey": "value",
"attrValue": "Studienbeginn WiSe"
}
]
},
"content": {
"label": "Studienbeginn WiSe"
}
}
]
}
}
],
"filterradio": [
{
"settings": {
"colClasses": "is-grid-col is-col-mobile-s-12 is-col-tablet-p-7",
"inputClasses": "is-radios",
"id": "language-of-study",
"required": true,
"typeOf": "radio"
},
"content": {
"label": "Admission Modality Value",
"radios": [
{
"settings": {
"wrapperClass": "is-radio-wrapper",
"inputClass": false,
"required": true,
"dataAttr": false,
"id": "Admission_modality_value→Mit_Zulassungsbeschränkung",
"name": "rad_Admission_modality_value",
"labelClasses": "is-label",
"attributes" : [
{
"attrKey": "data-value",
"attrValue": "mit Zulassungsbeschränkung"
}
]
},
"content": {
"label": "Mit Zulassungsbeschränkung"
}
},
{
"settings": {
"wrapperClass": "is-radio-wrapper",
"inputClass": false,
"required": true,
"dataAttr": false,
"id": "Admission_modality_value→Keine_Zulassungsbeschränkung",
"name": "rad_Admission_modality_value",
"labelClasses": "is-label",
"attributes" : [
{
"attrKey": "data-value",
"attrValue": "keine Zulassungsbeschränkung"
}
]
},
"content": {
"label": "Keine Zulassungsbeschränkung"
}
}
]
}
},
{
"settings": {
"colClasses": "is-grid-col is-col-tablet-p-12",
"inputClasses": "is-radios",
"id": "rad_1",
"required": false,
"typeOf": "radio"
},
"content": {
"label": "Type of School",
"radios": [
{
"settings": {
"wrapperClass": "is-radio-wrapper",
"inputClass": false,
"required": false,
"dataAttr": false,
"id": "Type_of_school_value→",
"name": "rad_Type_of_school_value",
"labelClasses": "is-label",
"attributes" : [
{
"attrKey": "data-value",
"attrValue": "Gymnasium"
}
]
},
"content": {
"label": "Gymnasium"
}
},
{
"settings": {
"wrapperClass": "is-radio-wrapper",
"inputClass": false,
"required": false,
"dataAttr": false,
"id": "Type_of_school_value→Realschule",
"name": "rad_Type_of_school_value",
"labelClasses": "is-label",
"attributes" : [
{
"attrKey": "data-value",
"attrValue": "Realschule"
}
]
},
"content": {
"label": "Realschule"
}
},
{
"settings": {
"wrapperClass": "is-radio-wrapper",
"inputClass": false,
"required": false,
"dataAttr": false,
"id": "Type_of_school_value→Grundschule",
"name": "rad_Type_of_school_value",
"labelClasses": "is-label",
"attributes" : [
{
"attrKey": "data-value",
"attrValue": "Grundschule"
}
]
},
"content": {
"label": "Grundschule"
}
},
{
"settings": {
"wrapperClass": "is-radio-wrapper",
"inputClass": false,
"required": false,
"dataAttr": false,
"id": "Type_of_school_value→Mittelschule",
"name": "rad_Type_of_school_value",
"labelClasses": "is-label",
"attributes" : [
{
"attrKey": "data-value",
"attrValue": "Mittelschule"
}
]
},
"content": {
"label": "Mittelschule"
}
}
]
}
}
],
"filtersubmit": [
{
"settings": {
"colClasses": "is-grid-col is-col-mobile-s-12",
"inputClasses": "is-submit",
"submitClass": "filter-finder-function__submit",
"id": "submit",
"required": false,
"typeOf": "submit",
"disabled": false,
"attributes" : [
{
"attrKey": "data-js-item",
"attrValue": "js-filter-course-finder-results-sorting"
}
]
},
"content": {
"legend": "Submit",
"label": "Label for submit",
"formSubmit": "Absenden"
}
}
]
}
}
}
}
Styles
filter-finder-function.scss
/* ===================================================
component: filter-finder-function
=================================================== */
$filter-finder-function-toggle-duration: 250ms;
/* ---------------------------------------------------
Global Styles
--------------------------------------------------- */
[data-css="c-filter-finder-function"] {
[data-js-item="js-filter-finder-function-result-template"] {
display: none !important;
}
}
/* ---------------------------------------------------
Context: Default
--------------------------------------------------- */
.c-filter-finder-function--default {
h2 {
@include headline-h2-styles();
}
p {
@include content-p-styles();
}
&.is-loading {
.filter-finder-function__result-loader {
opacity: 1;
}
.filter-finder-function__result-area {
height: 0;
opacity: 0;
}
.filter-finder-function__result-error {
height: 0;
opacity: 0;
}
}
&.is-success {
.filter-finder-function__result-loader {
z-index: -1;
opacity: 0;
}
.filter-finder-function__result-area {
height: auto;
opacity: 1;
}
.filter-finder-function__result-error {
height: 0;
opacity: 0;
}
}
&.is-error {
.filter-finder-function__result-loader {
z-index: -1;
opacity: 0;
}
.filter-finder-function__result-area {
height: 0;
opacity: 0;
}
.filter-finder-function__result-error {
height: auto;
opacity: 1;
}
}
.title-description {
margin-bottom: 50px;
}
.filter-finder-function__row {
display: flex;
flex-wrap: wrap;
margin-left: -10px;
margin-right: -10px;
.filter-finder-function__col {
padding-left: 10px;
padding-right: 10px;
margin-bottom: 30px;
}
}
.form__input {
margin-left: 0;
}
.form__radio-wrapper,
.form__checkbox-wrapper {
min-height: 41px;
padding-top: 15px;
}
.form__input-label,
.form__radio-legend,
.form__checkbox-legend,
.form__select-multiple__label {
font-family: $font-bold;
color: $color-dark;
font-size: 1.2rem;
letter-spacing: .5px;
line-height: (16/12);
min-height: 22.4px;
margin-bottom: 1rem;
}
.form__radio-item,
.form__checkbox-item {
display: inline-block;
margin-bottom: 15px;
margin-right: 30px;
}
abbr[title] {
text-decoration: none;
}
.filter-finder-function__filter-list {
width: 100%;
padding: 2rem 2rem 1rem 2rem;
border: 1px solid $color-gray-border;
& > div {
display: inline-block;
position: relative;
font-family: $font-regular;
color: $color-dark;
margin: 0 1rem 1rem 0;
padding: .375em 2.375em .375em .875em;
border: 1px solid $color-light;
background-color: $color-light;
-webkit-transition: background-color 400ms ease-in-out;
transition: background-color 400ms ease-in-out;
&:hover {
background-color: transparent;
}
button {
display: block;
position: absolute;
top: .75em;
right: .875em;
height: 13px;
width: 13px;
cursor: pointer;
padding: 0;
margin: 0;
background-color: transparent;
border: none;
outline: none;
&:before {
@include sprites-icon-close-small-green();
content: '';
display: block;
position: absolute;
top: 1px;
left: 0;
opacity: 1;
width: 13px;
height: 13px;
transition: opacity 400ms ease-in-out;
}
}
}
.filter-finder-function__filter-sample {
display: none;
}
}
.filter-finder-function__filter-reset {
display: inline-block;
span {
position: relative;
z-index: 2;
border: none;
font-size: 15px;
font-family: $font-bold;
font-weight: 700;
line-height: (24/15);
color: $color-green;
transition: color $filter-finder-function-toggle-duration linear;
cursor: pointer;
&:hover {
color: $color-dark;
}
}
}
.filter-finder-function__result-area {
height: 0;
opacity: 0;
transition: opacity $animation-duration-std $animation-easing-std;
p {
color: $color-dark;
font-family: $font-regular;
font-size: 1.6rem;
line-height: (24/16);
letter-spacing: .3px;
margin-bottom: 12px;
text-decoration: none;
display: block;
position: relative;
strong {
font-family: $font-bold;
}
}
a {
color: $color-green;
font-family: $font-regular;
text-decoration: none;
display: inline-block;
transition: color $animation-duration-std/2 $animation-easing-std;
position: relative;
&:focus {
outline: none;
}
&:hover,
&:focus {
color: $color-dark;
}
}
.filter-finder-function__result-wrapper {
@include clearfix();
display: flex;
width: 100%;
flex-direction: row;
flex-wrap: wrap;
position: relative;
p {
@include headline-h4-styles();
font-family: $font-regular;
font-weight: 400;
}
}
.filter-finder-function__result-wrapper-inner {
@include grid-column(12);
@include bp($bp-tablet-l) {
@include grid-column(10);
@include grid-push-h(1);
}
@include bp($bp-desktop-l) {
@include grid-column(8);
@include grid-push-h(2);
}
}
.filter-finder-function__result {
@include grid-column(12);
@include bp($bp-tablet-l) {
@include grid-column(10);
@include grid-push-h(1);
}
@include bp($bp-desktop-l) {
@include grid-column(8);
@include grid-push-h(2);
}
margin-bottom: 50px;
}
.filter-finder-function__result-title {
color: $color-dark;
font-family: $font-regular;
.filter-finder-function__result-title-link {
font-family: $font-bold;
padding-left: 25px;
@include print() {
padding-left: 0;
}
&:hover,
&:focus {
&::before {
@include sprites-icon-arrow-black();
transform: translateX(5px);
}
}
&::before {
@include pseudo();
@include sprites-icon-arrow-green100();
position: absolute;
display: inline-block;
top: 5px;
left: 0;
margin-right: 10px;
vertical-align: unset;
transition: transform $animation-duration-std $animation-easing-std;
@include print() {
display: none;
}
}
}
}
.filter-finder-function__result-subtitle {
color: $color-green;
}
.filter-finder-function__result-detail {
margin-bottom: 0;
.filter-finder-function__result-detail-link {
text-align: right;
display: block;
}
}
.filter-finder-function__result-item {
@include clearfix();
display: block;
width: 100%;
margin-top: 10px;
padding-top: 25px;
position: relative;
opacity: 1;
transform: translate3d(0, 0, 0);
transition: opacity 2 * $animation-duration-std $animation-easing-std,
transform 2 * $animation-duration-std $animation-easing-std;
&:not(:first-child) {
border-top: 1px solid $color-gray-border;
}
}
.filter-finder-function__result-info {
margin-right: 20px;
p {
line-height: 26px;
margin-top: 0;
@include bp($bp-mobile-p) {
line-height: 56px;
margin-top: 22px;
}
}
}
.filter-finder-function__result-link {
}
.filter-finder-function__result-order {
display: block;
.filter-finder-function__result-per-page {
width: 100%;
p {
line-height: 26px;
margin-top: 0;
@include bp($bp-mobile-p) {
line-height: 56px;
margin-top: 22px;
}
}
a.is-selected {
cursor: auto;
color: $color-dark;
font-family: $font-bold;
}
}
.filter-finder-function__result-sorting {
min-width: 160px;
.form__label-wrapper {
margin-bottom: 0;
}
}
@include bp($bp-mobile-p) {
display: flex;
margin-left: auto;
.filter-finder-function__result-per-page {
p {
line-height: 56px;
margin-top: 22px;
}
}
.filter-finder-function__result-sorting {
margin-left: 20px;
}
}
}
.filter-finder-function__results-item-link {
color: $color-green;
font-family: $font-bold;
font-size: 1.6rem;
line-height: (24/16);
letter-spacing: .3px;
margin-bottom: 12px;
text-decoration: none;
display: block;
transition: color $animation-duration-std/2 $animation-easing-std;
position: relative;
padding-left: 25px;
@include print() {
padding-left: 0;
}
&:focus {
outline: none;
}
&:hover,
&:focus {
color: $color-dark;
&::before {
@include sprites-icon-arrow-black();
transform: translateX(5px);
}
}
&::before {
@include pseudo();
@include sprites-icon-arrow-green100();
position: absolute;
display: inline-block;
top: 5px;
left: 0;
margin-right: 10px;
vertical-align: unset;
transition: transform $animation-duration-std $animation-easing-std;
@include print() {
display: none;
}
}
}
.filter-finder-function__pagination-wrapper {
border: 0;
margin: 30px 0 40px 0;
outline: 0;
padding: 0;
width: 100%;
clear: both;
display: block;
text-align: center;
position: relative;
.filter-finder-function__pagination-list {
display: flex;
justify-content: center;
}
a {
display: inline-block;
width: 30px;
line-height: 24px;
color: $color-green;
cursor: pointer;
padding: 5px 0;
&:hover,
&:focus {
background-color: $color-light;
}
&.is-active {
color: $color-white;
background-color: $color-green;
}
}
span {
display: inline-block;
width: 34px;
line-height: 24px;
color: $color-gray;
padding: 5px 0;
}
#pagination__firs-page,
#pagination__prev-page,
#pagination__next-page,
#pagination__last-page {
height: 34px;
font-size: 18px;
padding: 4px 0;
&.is-disabled {
color: $color-gray-light;
cursor: auto;
&:hover {
background-color: transparent;
}
}
}
@include bp($bp-mobile-p) {
a {
width: 34px;
}
}
}
}
.filter-finder-function__result-container {
position: relative;
}
.filter-finder-function__result-loader {
@include centering(h);
position: absolute;
top: 80px;
display: flex;
width: 200px;
flex-direction: row;
background-color: $color-white;
height: 60px;
align-items: center;
justify-content: center;
pointer-events: none;
opacity: 0;
transition: opacity $animation-duration-std $animation-easing-std;
z-index: 100;
border: 1px solid $color-green;
}
.filter-finder-function__result-loader-box {
display: block;
margin: 10px;
border: 1em solid $color-green;
opacity: 0;
/*
MODIFIERS
----------------------- */
&.is-one {
animation: boxAppear 2s linear infinite;
}
&.is-two {
animation: boxAppear 2s linear .3s infinite;
}
&.is-three {
animation: boxAppear 2s linear .62s infinite;
}
}
.filter-finder-function__result-error {
height: 0;
opacity: 0;
overflow: hidden;
transition: opacity $animation-duration-std $animation-easing-std;
p {
@include headline-h4-styles();
font-family: $font-regular;
font-weight: 400;
text-align: center;
margin-top: 40px;
strong {
font-family: $font-bold;
}
}
}
}
Scripts
filter-finder-function.js
/**
* Description of FilterFinderFunction.
* Class properties and decorators are supported.
*
* @module FilterFinderFunction
* @version v1.0.0
*
* @author Ognjen Jukanovic
*/
// Imports
import $ from 'jquery';
import Component from '@veams/component';
class FilterFinderFunction extends Component {
/**
* Class Properties
*/
$el = $(this.el);
$filterForm = $(this.options.selectors.filterForm, this.el);
$filterList = $(this.options.selectors.filterList, this.el);
$fields = $('input', this.$filterForm);
$selects = $('select', this.$filterForm);
$lang = document.getElementsByTagName("HTML")[0].getAttribute("lang") ? document.getElementsByTagName("HTML")[0].getAttribute("lang") : 'de';
$query = '';
$queryHaupia = '';
$sort = 'asc';
$paginationNumberOfPage = '';
$paginationCurrentPage = '';
/**
* Constructor for our class
*
* @see module.js
*
* @param {Object} obj - Object which is passed to our class
* @param {Object} obj.el - element which will be saved in this.el
* @param {Object} obj.options - options which will be passed in as JSON object
*/
constructor(obj) {
let options = {
selectors: {
filterForm: '[data-js-item="js-filter-finder-function-filter-form"]',
filterList: '[data-js-item="js-filter-finder-function-filter-list"]',
filterReset: '[data-js-item="js-filter-finder-function-filter-reset"]',
resultArea: '[data-js-item="js-filter-finder-function-result-area"]',
resultPerPage: '[data-js-item="js-filter-finder-function__result-per-page"]',
paginationArea: '[data-js-item="js-filter-finder-function-pagination-area"]',
formSelectElement: '.form__select-element',
filterListSuffix: '__filter-list',
paginationItem: 'pagination__item-',
paginationFirsPage: 'pagination__firs-page',
paginationPrevPage: 'pagination__prev-page',
paginationNextPage: 'pagination__next-page',
paginationLastPage: 'pagination__last-page',
paginationNoOfPage: 'pagination__numbers-of-page'
},
classes: {
isSelected: 'is-selected',
activeFilterItem: 'is-active',
isSuccess: 'is-success',
isError: 'is-error',
isLoading: 'is-loading'
}
};
super(obj, options);
}
/**
* Lifecycle Hooks
*/
willMount() {
console.log('Component FilterFinderFunction will mount!');
}
didMount() {
console.log('Component FilterFinderFunction mounted!');
}
/**
* @desc Debounce a function for a specific time
*/
bindEvents() {
this.options.filterForm = document.querySelector(
this.options.selectors.filterForm
);
this.options.filterList = document.querySelector(
this.options.selectors.filterList
);
this.options.resultArea = document.querySelector(
this.options.selectors.resultArea
);
this.options.paginationArea = document.querySelector(
this.options.selectors.paginationArea
);
this.options.resultPerPage = this.options.resultArea.querySelector(
this.options.selectors.resultPerPage
);
this.options.resultsPerPage = [].slice.call(
this.options.resultArea.querySelectorAll('.filter-finder-function__result-per-page a')
);
this.options.filterReset = document.querySelector(
this.options.selectors.filterReset
);
// Fill from URL
const urlOptions = decodeURI(window.location.href.split('?')[1]).split('&');
if (urlOptions[0] !== 'undefined') {
urlOptions.forEach((o, index) => {
const option = o.split('=');
const id = `[name=${option[0]}]`;
const type = option[0].split('_')[0];
// Query
if (index === 0) {
if (option[0] === 'query') {
const element = document.querySelector(id);
element.value = option[1];
this.$queryHaupia += `?query=${option[1]}`;
} else {
this.$queryHaupia += '?query=*';
}
}
// Checkbox
if (type === 'cbx') {
const element = document.querySelector(id);
element.checked = true;
// Add item to filter list
this.addToFilterList(option[0], element.nextElementSibling.textContent);
this.$queryHaupia += `&${option[0].replace('cbx_', 'facet.filter.').split('→')[0]}=${option[1]}`;
}
// Radio
if (type === 'rad') {
const elements = document.querySelectorAll(id);
elements.forEach((element) => {
if (element.dataset.value === option[1].slice(1,-1)) {
element.checked = true;
// Add item to filter list
this.addToFilterList(element.id, element.nextElementSibling.textContent, option[0]);
this.$queryHaupia += `&${option[0].replace('rad_', 'facet.filter.').split('→')[0]}=${option[1]}`;
}
});
}
// Select
if (type === 'sel') {
const element = document.querySelector(id);
const elementWrapper = $(element).closest('.form__select-wrapper');
$(element).val(option[1].slice(1,-1));
elementWrapper.find(`[data-value="${option[1].slice(1,-1)}"]`).addClass('is-selected');
elementWrapper.find('span.form__select-placeholder').html(
elementWrapper.find(`[data-value="${option[1].slice(1,-1)}"] span`).html()
);
// Add item to filter list
this.addToFilterList(element.id, elementWrapper.find(`[data-value="${option[1].slice(1,-1)}"]`)[0].textContent);
this.$queryHaupia += `&${option[0].replace('sel_', 'facet.filter.').split('→')[0]}=${option[1]}`;
}
// Select-Multiple
if (type === 'mul') {
const element = document.querySelector(id);
const items = option[1].slice(1,-1).split('~');
element.querySelectorAll('option').forEach((item) => {
item.removeAttribute('selected');
$(element).closest('.select-multiple__overlay').find(`input#${item.id}_checkbox`).prop('checked', false);
});
if (items.toString() === 'all') {
element.querySelectorAll('option').forEach((opt, index) => {
if (opt.disabled === false) {
opt.setAttribute('selected', 'selected');
$(element).closest('.select-multiple__overlay').find(`input#${opt.id}_checkbox`).prop('checked', true);
if (index > 0) {
// Add item to filter list
this.addToFilterList(`${opt.id}_checkbox`, opt.textContent)
// Haupia query
this.$queryHaupia += `&${option[0].replace('mul_', 'facet.filter.')}="${opt.id.split('→')[1]}"`;
}
}
});
} else {
items.forEach((item) => {
item = $(element).find(`[value="${item}"]`);
item.attr('selected', 'selected');
$(element).closest('.select-multiple__overlay').find(`input#${item[0].id}_checkbox`).prop('checked', true);
// Add item to filter list
this.addToFilterList(`${item[0].id}_checkbox`, item[0].textContent);
});
// Haupia query
option[1].slice(1,-1).split('~').forEach((key) => {
this.$queryHaupia += `&${option[0].replace('mul_', 'facet.filter.')}="${key}"`;
});
}
}
// Sorting
if (option[0] === 'sorting') {
const element = document.querySelector(id);
const elementWrapper = $(element).closest('.form__select-wrapper');
$(element).val(`${option[0]}→${option[1]}`);
elementWrapper.find(`[data-value="${option[0]}→${option[1]}"]`).addClass('is-selected');
elementWrapper.find('span.form__select-placeholder').html(
elementWrapper.find(`[data-value="${option[0]}→${option[1]}"] span`).html()
);
this.$query += `&sorting=${option[1]}`;
}
// Language
if (option[0] === 'language') {
this.$query += `&language=${option[1]}`;
this.$queryHaupia += `&language=${option[1]}`;
}
// Page
if (option[0] === 'page') {
this.$query += `&page=${option[1]}`;
this.$queryHaupia += `&page=${option[1]}`;
this.$paginationCurrentPage = option[1];
}
// Number of rows
if (option[0] === 'numRows') {
this.$query += `&numRows=${option[1]}`;
this.$queryHaupia += `&numRows=${option[1]}`;
this.options.resultsPerPage.forEach(item => {
item.classList.remove(this.options.classes.isSelected);
if ($(item).hasClass(`results-per-page__${option[1]}`)) {
item.classList.add(this.options.classes.isSelected);
}
});
}
});
this.getAndFillMyResults(this.$queryHaupia);
this.toggleVisibilityFilterList();
}
let fnInputHandler = this.inputHandler.bind(this);
this.$filterForm.find('input[type="radio"]').on(this.context.EVENTS.click, fnInputHandler);
this.$filterForm.find('input[type="checkbox"]').on(this.context.EVENTS.click, fnInputHandler);
let fnSelectHandler = this.selectHandler.bind(this);
this.$filterForm.find('li.form__select-element').on(this.context.EVENTS.click, fnSelectHandler);
let fnButtonHandler = this.buttonHandler.bind(this);
this.$filterForm.find('button.form__submit').on(this.context.EVENTS.click, fnButtonHandler);
let fnRemoveFromFilterListHandler = this.removeFromFilterListHandler.bind(this);
this.$filterList.on(this.context.EVENTS.click, fnRemoveFromFilterListHandler);
let fnFilterReset = this.filterResetHandler.bind(this);
this.$filterForm.find('div.filter-finder-function__filter-reset').on(this.context.EVENTS.click, fnFilterReset);
// Click on Result Per Page
this.options.resultsPerPage.forEach(element => {
element.addEventListener('click', (ev) => {
this.options.resultsPerPage.forEach(item => {
item.classList.remove(this.options.classes.isSelected);
});
element.classList.add(this.options.classes.isSelected);
this.$paginationCurrentPage = 1;
this.toggleVisibilityFilterList();
this.writeQueryUrl(true);
this.getAndFillMyResults(this.$queryHaupia);
});
});
// Click on Pagination Area Define Style
const paginationDivs = [].slice.call(this.options.paginationArea.querySelector('div').childNodes);
paginationDivs.forEach(element => {
element.addEventListener('click', () => {
let items = [].slice.call(element.parentElement.childNodes);
items.forEach(item => {
item ? item.classList.remove(this.options.classes.activeFilterItem) : '';
});
element.classList.add(this.options.classes.activeFilterItem);
});
});
// Click on Pagination Area Filter Logic
const paginationItems = [].slice.call(this.options.paginationArea.childNodes);
paginationItems.forEach(element => {
element.addEventListener('click', (ev) => {
if (element.id === this.options.selectors.paginationFirsPage) {
this.$paginationCurrentPage = 1;
} else if (element.id === this.options.selectors.paginationPrevPage) {
this.$paginationCurrentPage = Number(this.options.paginationArea.querySelector(`.${this.options.classes.activeFilterItem}`).innerHTML) - 1;
this.$paginationCurrentPage = this.$paginationCurrentPage >= 1 ? this.$paginationCurrentPage : '1';
} else if (element.id === this.options.selectors.paginationNextPage) {
this.$paginationCurrentPage = Number(this.options.paginationArea.querySelector(`.${this.options.classes.activeFilterItem}`).innerHTML) + 1;
this.$paginationCurrentPage = this.$paginationCurrentPage <= this.$paginationNumberOfPage ? this.$paginationCurrentPage : this.$paginationNumberOfPage;
} else if (element.id === this.options.selectors.paginationLastPage) {
this.$paginationCurrentPage = Number(this.$paginationNumberOfPage);
} else if (element.id === this.options.selectors.paginationNoOfPage) {
let elementChildNodes = [].slice.call(element.childNodes);
elementChildNodes.forEach(item => {
item.classList.remove(this.options.classes.activeFilterItem);
});
ev.srcElement.classList.add(this.options.classes.activeFilterItem);
this.$paginationCurrentPage = ev.srcElement.innerHTML;
}
this.toggleVisibilityFilterList();
this.writeQueryUrl();
this.getAndFillMyResults(this.$queryHaupia);
});
});
}
/**
* @desc Get data from JSON and fill in function initializationForm
*/
getAndFillMyResults(query) {
// Haupia Credentials
let haupiaUri = [];
const haupiaUriLocalhost = {
hpLink: 'https://haupia-lmu.asiososys.com/rest/api/v1/prepared_search/',
hpUser: 'ognjen.jukanovic@asioso.com',
hpPass: 'ognjen123'
};
typeof haupiaUriFirstSpirit !== 'undefined' && haupiaUriFirstSpirit ? haupiaUri = haupiaUriFirstSpirit : haupiaUri = haupiaUriLocalhost;
//add ?query=* if there is no text input field
if(query.slice(0,7) !== '?query=') query = '?query=*' + query;
const uri = haupiaUri.hpLink + this.$sort + '/execute' + query;
let dataLogin = [{name: "Authorization", value: 'Basic ' + Buffer.from(haupiaUri.hpUser + ':' + haupiaUri.hpPass).toString('base64')}]
this.getJSON(uri, (data) => {
const results = data.results;
if (typeof results !== 'undefined') this.populateResults(data);
}, dataLogin);
}
/**
* @desc Populate results
* @param {Array} data - Results from JSON file
*/
populateResults(data) {
let settingForResults = [];
const resultConfigLH = {
resultTitle : 'Name_value',
resultDesc : 'Description_value'
}
typeof resultConfig !== 'undefined' && resultConfig ? settingForResults = resultConfig : settingForResults = resultConfigLH;
this.$paginationNumberOfPage = Math.ceil(data.numRows / data.rows);
this.$paginationCurrentPage <= 0 ? this.$paginationCurrentPage = 1 : this.$paginationCurrentPage;
this.$paginationCurrentPage >= this.$paginationNumberOfPage ? this.$paginationCurrentPage = this.$paginationNumberOfPage : this.$paginationCurrentPage;
this.paginationPrintItem(this.$paginationNumberOfPage, this.$paginationCurrentPage);
let template = this.options.resultArea.querySelector('[data-js-item="js-filter-finder-function-result-template"]');
let resultList = this.options.resultArea.querySelector('[data-js-item="js-filter-finder-function-result-list"]');
resultList.innerHTML = '';
this.options.resultArea.querySelector('.filter-finder-function__total-item-count').textContent = data.numRows;
this.objectOrArrayToArray(data.results).forEach((item) => {
const result = template.cloneNode(true);
result.removeAttribute('data-js-item');
//get variables from FS
if(resultConfig.resultTitle){
result.querySelector('.filter-finder-function__results-item-link').textContent = this.arrayToString(item[resultConfig.resultTitle]);
}
if(resultConfig.resultDesc){
result.querySelector('.filter-finder-function__results-item-description').textContent = this.arrayToString(item[resultConfig.resultDesc]);
}else{
result.querySelector('.filter-finder-function__results-item-description').textContent = '';
}
result.querySelector('.filter-finder-function__results-item-link').setAttribute('href', item.detailpage_link);
resultList.appendChild(result);
});
window.setTimeout( () => {
this.el.classList.remove(this.options.classes.isLoading);
data.numRows > 0 ? this.el.classList.add(this.options.classes.isSuccess) : this.el.classList.add(this.options.classes.isError);
}, 125);
}
/**
* @desc Remove from filter list
* @param {Array} ev - Attribute event
*/
removeFromFilterListHandler(ev) {
ev.preventDefault();
if (ev.target.tagName === 'BUTTON') {
let id = ev.target.parentElement.id.replace(this.options.selectors.filterListSuffix, '');
let element = this.options.filterForm.querySelector(`#${id}`);
let name = element.getAttribute('name');
ev.target.parentElement.remove();
// Checkbox
if (id.split('_')[0] === 'cbx') {
element.checked = false;
}
// Radio
if (name.split('_')[0] === 'rad') {
element.checked = false;
}
// Select
if (id.split('_')[0] === 'sel') {
element.selectedIndex = 0;
const items = [].slice.call(
element.nextElementSibling.querySelectorAll(this.options.selectors.formSelectElement)
);
items.forEach((item, index) => {
if (index === 0) {
item.classList.add(this.options.classes.isSelected);
element.nextElementSibling.firstElementChild.innerHTML = item.textContent;
} else {
item.classList.remove(this.options.classes.isSelected);
}
});
}
// Select-Multiple
if (id.split('_')[0] === 'mul') {
let select = $(element).closest('div.select-multiple__overlay').find('select');
if (select.find('option').length === select.find('option:checked').length + select.find('option:disabled').length) {
select.find(`option#${id.split('→')[0]}→all`)[0].removeAttribute('selected', 'selected');
$(element).closest('div.select-multiple__results').find(`input#${id.split('→')[0]}→all_checkbox`)[0].checked = false;
}
element.checked = false;
select.find(`option#${element.id.replace('_checkbox', '')}`)[0].removeAttribute('selected', 'selected');
}
this.toggleVisibilityFilterList();
this.writeQueryUrl(true);
this.getAndFillMyResults(this.$queryHaupia);
}
}
/**
* @desc Filter reset handler
*/
filterResetHandler() {
// Fields
Object.values(this.$fields).forEach((item, index) => {
if(item.tagName && item.tagName.toLowerCase() === "input") {
// Type text
if(item.type.toLowerCase() === "text" && item.classList.contains('form__input-text')) {
item.value = '';
}
// Type radio
if(item.type.toLowerCase() === "radio" && item.classList.contains('form__radio-input') && item.checked === true) {
item.checked = false;
this.removeFromFilterList(`${item.id}`);
}
// Type checkbox
if(item.type.toLowerCase() === "checkbox" && item.classList.contains('form__checkbox-input') && item.checked === true) {
item.checked = false;
this.removeFromFilterList(`${item.id}`);
}
// Type checkbox select-multiple
if(item.type.toLowerCase() === "checkbox" && item.classList.contains('select-multiple__checkbox') && item.checked) {
item.checked = false;
if (item.id.split('→')[1].replace('_checkbox', '') !== 'all') {
this.removeFromFilterList(`${item.id}`);
}
}
}
});
// Selects
Object.values(this.$selects).forEach((item, index) => {
if(item.tagName && item.tagName.toLowerCase() === "select") {
// Type select-one
if(item.type.toLowerCase() === "select-one" && item.classList.contains('form__select-input')) {
if (item.value) {
this.removeFromFilterList(`${item.id}`);
}
item.selectedIndex = 0;
let selectParentElement = [].slice.call(item.parentElement.lastChild.querySelectorAll('li'));
selectParentElement.forEach((li, index) => {
if (index === 0) {
li.classList.add(this.options.classes.isSelected);
item.nextElementSibling.firstElementChild.innerHTML = li.textContent;
} else {
li.classList.remove(this.options.classes.isSelected);
}
});
}
// Type select-multiple
if(item.type.toLowerCase() === "select-multiple" && item.classList.contains('select-multiple__filter-select')) {
item.selectedIndex = -1;
for (let i = 0; i< item.options.length; i++){
item.options[i].removeAttribute('selected', 'selected');
}
}
}
});
this.toggleVisibilityFilterList();
window.setTimeout( () => {
this.writeQueryUrl(true);
this.getAndFillMyResults(this.$queryHaupia);
}, 125);
}
/**
* @desc Input handler
* @param {Array} ev - Attribute event
*/
inputHandler(ev) {
if (ev.target.checked) {
if (ev.target.id.split('→')[1] === 'all_checkbox') {
ev.srcElement.offsetParent.querySelectorAll('div.select-multiple__checkbox-container').forEach((item, index) => {
if (index > 0 && item.firstElementChild.disabled === false) {
this.addToFilterList(item.firstElementChild.id, item.lastElementChild.textContent)
}
});
} else {
this.addToFilterList(ev.target.id, ev.target.nextElementSibling.textContent, ev.target.name);
}
} else {
if (ev.target.id.split('→')[1] === 'all_checkbox') {
ev.srcElement.offsetParent.querySelectorAll('div.select-multiple__checkbox-container').forEach((item, index) => {
if (index > 0 && item.firstElementChild.disabled === false) {
this.removeFromFilterList(item.firstElementChild.id);
}
});
} else {
this.removeFromFilterList(ev.target.id);
}
}
this.toggleVisibilityFilterList();
window.setTimeout( () => {
this.writeQueryUrl(true);
this.getAndFillMyResults(this.$queryHaupia);
}, 125);
}
/**
* @desc Select handler
* @param {Array} ev - Attribute event
*/
selectHandler(ev) {
if (ev.target.parentElement.getAttribute('data-value').split('→')[0] === 'sorting') {
this.$sort = ev.target.parentElement.getAttribute('data-value').split('→')[1];
} else {
if (ev.target.parentElement.getAttribute('data-value')) {
this.addToFilterList(ev.target.offsetParent.parentElement.previousElementSibling.id, ev.target.textContent);
} else {
this.removeFromFilterList(ev.target.offsetParent.parentElement.previousElementSibling.id);
}
}
this.toggleVisibilityFilterList();
window.setTimeout( () => {
this.writeQueryUrl(true);
this.getAndFillMyResults(this.$queryHaupia);
}, 125);
}
/**
* @desc Button handler
* @param {Array} ev - Attribute event
*/
buttonHandler(ev) {
ev.preventDefault();
ev.stopPropagation();
this.toggleVisibilityFilterList();
window.setTimeout( () => {
this.writeQueryUrl(true);
this.getAndFillMyResults(this.$queryHaupia);
}, 125);
}
/**
* @desc Write query to URL
* @param {Boolean} resetPagination - Resrt pagination yes (true) or no (false)
*/
writeQueryUrl(resetPagination) {
this.$query = '';
this.$queryHaupia = '';
Object.values(this.$fields).forEach((item, index) => {
if(item.tagName && item.tagName.toLowerCase() === "input") {
// Type text
if (item.type.toLowerCase() === "text" && item.classList.contains('form__input-text')) {
if (item.value !== '' && item.value !== item.defaultValue && item.value.length !== 0) {
this.$query += `?${item.name}=${item.value}`;
this.$queryHaupia += `?${item.name}=${item.value}`;
} else {
this.$queryHaupia += '?query=*';
}
}
// Type radio
if (item.type.toLowerCase() === "radio" && item.classList.contains('form__radio-input') && item.checked) {
this.$query += `&${item.name}="${item.dataset.value}"`;
this.$queryHaupia += `&${item.name.replace('rad_', 'facet.filter.').split('→')[0]}="${item.dataset.value}"`;
}
// Type checkbox
if (item.type.toLowerCase() === "checkbox" && item.classList.contains('form__checkbox-input') && item.checked) {
this.$query += `&${item.name}="${item.value}"`;
this.$queryHaupia += `&${item.name.replace('cbx_', 'facet.filter.').split('→')[0]}="${item.value}"`;
}
}
});
Object.values(this.$selects).forEach((item, index) => {
if(item.tagName && item.tagName.toLowerCase() === "select") {
// Type select-one
if (item.type.toLowerCase() === "select-one" && item.classList.contains('form__select-input')) {
if (item.value !== '' && item.value !== item.defaultValue && item.value.length !== 0) {
this.$query += `&${item.name}="${item.value}"`;
this.$queryHaupia += `&${item.name.replace('sel_', 'facet.filter.').split('→')[0]}="${item.value}"`;
}
}
// Type select-multiple
if (item.type.toLowerCase() === "select-multiple" && item.classList.contains('select-multiple__filter-select')) {
let selectedValues = [].map.call(item.selectedOptions, input => input.value);
if (selectedValues.length) {
if (item.value === 'all') {
this.$query += `&${item.name.split('→')[0]}="${item.value}"`;
} else {
this.$query += `&${item.name.split('→')[0]}="${selectedValues.toString().replace(/,/g, '~')}"`;
}
this.objectOrArrayToArray(selectedValues).forEach((key) => {
key !== 'all' ? this.$queryHaupia += `&${item.name.replace('mul_', 'facet.filter.').split('→')[0]}="${key}"` : '';
});
}
}
}
});
// Page
let page = resetPagination ? '1' : this.$paginationCurrentPage;
// Item per page
let itemPerPage = '';
this.options.resultsPerPage.forEach(element => {
if ($(element).hasClass(this.options.classes.isSelected)) {
itemPerPage = element.innerHTML;
}
});
this.$query += `&sorting=${this.$sort}&language=${this.$lang}&numRows=${itemPerPage}&page=${page}&numRows=${itemPerPage}`;
this.$query = this.$query.substr(1);
this.$queryHaupia += `&language=${this.$lang}&page=${page}&numRows=${itemPerPage}`;
history.pushState(this.$query, 'Search history', `${window.location.href.split('?')[0]}?${this.$query}`);
}
/**
* @desc Print pagination on the bottom page
* @param {Boolean} maxNum - Maximum number of Items
* @param {Boolean} activeNum - Active item
*/
paginationPrintItem(maxNum, activeNum) {
let maxNumOfItems = Number(maxNum);
let activeNumItem = Number(activeNum);
this.options.paginationArea.querySelector(`#${this.options.selectors.paginationFirsPage}`).classList.remove(this.options.classes.isDisabled);
this.options.paginationArea.querySelector(`#${this.options.selectors.paginationPrevPage}`).classList.remove(this.options.classes.isDisabled);
this.options.paginationArea.querySelector(`#${this.options.selectors.paginationNextPage}`).classList.remove(this.options.classes.isDisabled);
this.options.paginationArea.querySelector(`#${this.options.selectors.paginationLastPage}`).classList.remove(this.options.classes.isDisabled);
this.options.paginationArea.querySelector('div').innerHTML = '';
if (maxNumOfItems < 6) {
for (let i = 1; i <= maxNumOfItems; i++) {
this.paginationCreateItem(i);
}
} else {
activeNumItem > 2 ? this.paginationCreateItem(1) : '';
activeNumItem > 3 ? this.paginationCreateItem('...') : '';
activeNumItem > 1 ? this.paginationCreateItem(activeNumItem-1) : '';
this.paginationCreateItem(activeNumItem);
activeNumItem < maxNumOfItems ? this.paginationCreateItem(activeNumItem+1) : '';
activeNumItem < maxNumOfItems-2 ? this.paginationCreateItem('...') : '';
activeNumItem < maxNumOfItems-1 ? this.paginationCreateItem(maxNumOfItems) : '';
}
if (maxNumOfItems > 0) {
document.getElementById(`${this.options.selectors.paginationItem}${activeNumItem}`).classList.add(this.options.classes.activeFilterItem);
}
if (Number(this.$paginationCurrentPage) === 1) {
this.options.paginationArea.querySelector(`#${this.options.selectors.paginationFirsPage}`).classList.add(this.options.classes.isDisabled);
this.options.paginationArea.querySelector(`#${this.options.selectors.paginationPrevPage}`).classList.add(this.options.classes.isDisabled);
}
if (Number(this.$paginationCurrentPage) === Number(this.$paginationNumberOfPage)) {
this.options.paginationArea.querySelector(`#${this.options.selectors.paginationNextPage}`).classList.add(this.options.classes.isDisabled);
this.options.paginationArea.querySelector(`#${this.options.selectors.paginationLastPage}`).classList.add(this.options.classes.isDisabled);
}
}
/**
* @desc Create item for pagination
* @param {Boolean|String} item - Current item
*/
paginationCreateItem(item) {
let element = '';
if(isNaN(item)){
element = document.createElement("SPAN");
} else {
element = document.createElement("A");
element.setAttribute("id", `${this.options.selectors.paginationItem}${item}`);
}
element.appendChild(document.createTextNode(item));
this.options.paginationArea.querySelector('div').appendChild(element);
}
/**
* @desc Add to filter list
* @param {String} id - Attribute id
* @param {String} text - Inner text
*/
addToFilterList(id, text, name) {
const itemId = `${id}${this.options.selectors.filterListSuffix}`;
const itemName = name ? `name="${name}"` : '';
const item = `<div id="${itemId}" ${itemName}>${text} <button></button></div>`;
this.options.filterList.querySelectorAll('div').forEach((item) => {
if (item.id.replace(this.options.selectors.filterListSuffix, '') === id) {
this.removeFromFilterList(id);
} else if (item.getAttribute('name') === name) {
this.removeFromFilterList(item.id.replace(this.options.selectors.filterListSuffix, ''));
}
});
this.options.filterList.innerHTML += item;
}
/**
* @desc Remove from filter list
* @param {String} id - Attribute id
*/
removeFromFilterList(id) {
let item = `${id}${this.options.selectors.filterListSuffix}`;
let element = document.getElementById(item);
return element.parentNode.removeChild(element);
}
/**
* @desc Toggle visibility filter list
*/
toggleVisibilityFilterList() {
this.el.classList.remove(this.options.classes.isSuccess, this.options.classes.isError);
this.el.classList.add(this.options.classes.isLoading);
if (this.options.filterList.childNodes.length <= 1) {
this.options.filterList.parentElement.style.display = 'none';
this.options.filterReset.parentElement.style.display = 'none';
} else {
this.options.filterList.parentElement.style.display = 'flex';
this.options.filterReset.parentElement.style.display = 'inline-block';
}
}
/**
* @desc Convert Array to String
* @param {Array} item - Array
* @return {String} - String
*/
arrayToString = (item) => {
item = item ? item.toString() : '';
return item;
}
/**
* @desc Convert Object or Array to Array
* @param {Object} item - Object or Array
* @return {Array} - Array
*/
objectOrArrayToArray = (item) => {
if (typeof item === 'undefined' || Array.isArray(item)) {
return item;
}
return [item];
};
/**
* @desc JSON request
* @param {String} url - Link to JSON file
* @param {Object} callback - For results
* @param {Object} requestHeader - For request with Header like user, pass, type...
* @return {callback} - Return callback
*/
getJSON = (url, callback, requestHeader) => {
const xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
if (requestHeader) {
requestHeader.forEach((element) => {
xhr.setRequestHeader(element.name, element.value);
});
}
xhr.onload = () => {
if (xhr.readyState === 4 && xhr.status === 200) {
const res = xhr.responseText;
callback(JSON.parse(res));
} else {
console.error(xhr.statusText);
}
};
xhr.send(null);
};
/**
* Render class
*/
render() {
return this;
}
}
export default FilterFinderFunction;
HTML Output
Default
<div class="c-filter-finder-function--default" data-css="c-filter-finder-function" data-js-module="filter-finder-function">
<form class="c-form--default" action="" method="" data-css="c-form" data-js-item="js-filter-finder-function-filter-form">
<div class="filter-finder-function__row">
<div class="filter-finder-function__col is-grid-col is-col-mobile-s-12 is-col-tablet-p-6 is-col-tablet-l-3">
<div class="form__input">
<div class="form__label-wrapper">
<label for="query" class="form__input-label">
Query
</label>
</div>
<div class="form__input-wrapper">
<input id="query" name="query" type="text" placeholder="Enter a search term..." class="form__input-text" />
</div>
</div>
</div>
<div class="filter-finder-function__col is-grid-col is-col-mobile-s-12 is-col-tablet-p-6 is-col-tablet-l-3">
<div class="form__select">
<div class="form__label-wrapper">
<label for="sel_Type_value" class="form__select-label">
Type
</label>
</div>
<div class="form__select-wrapper">
<!--
data-placeholder="Bitte Wählen"
data-reset-text=" - "
data-has-reset-option="true|false"
-->
<select id="sel_Type_value" data-placeholder="Bitte Wählen" data-js-module="form-dropdown" name="sel_Type_value" class="form__select-input">
<option value="" selected>Please choose...</option>
<option value="Hauptfach">Hauptfach</option>
<option value="Didaktikfach">Didaktikfach</option>
<option value="Erweiterungsfach">Erweiterungsfach</option>
<option value="Unterrichtsfach">Unterrichtsfach</option>
<option value="Nebenfach">Nebenfach</option>
</select>
</div>
</div>
</div>
<div class="filter-finder-function__col is-grid-col is-col-mobile-s-12 is-col-tablet-p-6 is-col-tablet-l-3">
<div class="form__select">
<div class="form__label-wrapper">
<label for="sel_schooltyp" class="form__select-label">
Select Label
</label>
</div>
<div class="form__select-wrapper">
<!--
data-placeholder="Bitte Wählen"
data-reset-text=" - "
data-has-reset-option="true|false"
-->
<select id="sel_schooltyp" data-placeholder="Bitte Wählen" data-js-module="form-dropdown" name="sel_schooltyp" class="form__select-input">
<option value="" selected>Please choose...</option>
<option value="option_1">Option-1</option>
<option value="option_2">Option-2</option>
<option value="option_3">Option-3</option>
<option value="option_4">Option-4</option>
</select>
</div>
</div>
</div>
<div class="filter-finder-function__col is-grid-col is-col-mobile-s-12 is-col-tablet-p-6 is-col-tablet-l-3">
<div class="form__checkbox">
<div class="form__label-wrapper">
<strong class="form__checkbox-legend">Status</strong>
</div>
<div class="form__checkbox-wrapper">
<div class="form__checkbox-item is-wrapper">
<input id="cbx_enrol_for_the_first_time" name="cbx_enrol_for_the_first_time" type="checkbox" value="enrol_for_the_first_time" class="form__checkbox-input" />
<label for="cbx_enrol_for_the_first_time" class="form__checkbox-label is-label">
Enrol for the first time
</label>
</div>
</div>
</div>
</div>
<div class="filter-finder-function__col is-grid-col is-col-mobile-s-12 is-col-tablet-p-5">
<div class="form__checkbox">
<div class="form__label-wrapper">
<strong class="form__checkbox-legend">Start of Studies</strong>
</div>
<div class="form__checkbox-wrapper">
<div class="form__checkbox-item is-wrapper">
<input id="cbx_Start_of_studies_value→auch_im_Sommersemester" name="cbx_Start_of_studies_value→auch_im_Sommersemester" type="checkbox" value="auch im Sommersemester" class="form__checkbox-input" />
<label for="cbx_Start_of_studies_value→auch_im_Sommersemester" class="form__checkbox-label is-label">
Auch im Sommersemester
</label>
</div>
<div class="form__checkbox-item is-wrapper">
<input id="cbx_Start_of_studies_value→Studienbeginn_WiSe" name="cbx_Start_of_studies_value→Studienbeginn_WiSe" type="checkbox" value="Studienbeginn WiSe" class="form__checkbox-input" />
<label for="cbx_Start_of_studies_value→Studienbeginn_WiSe" class="form__checkbox-label is-label">
Studienbeginn WiSe
</label>
</div>
</div>
</div>
</div>
<div class="filter-finder-function__col is-grid-col is-col-mobile-s-12 is-col-tablet-p-7">
<div class="form__radio">
<div class="form__label-wrapper">
<strong class="form__radio-legend">Admission Modality Value <abbr title="Required">*</abbr></strong>
</div>
<div class="form__radio-wrapper">
<ul class="form__radio-list">
<li class="form__radio-item">
<input id="Admission_modality_value→Mit_Zulassungsbeschränkung" name="rad_Admission_modality_value" type="radio" value="Admission_modality_value→Mit_Zulassungsbeschränkung" data-value="mit Zulassungsbeschränkung" required="required" class="form__radio-input" />
<label role="button" for="Admission_modality_value→Mit_Zulassungsbeschränkung" class="form__radio-label">
Mit Zulassungsbeschränkung
</label>
</li>
<li class="form__radio-item">
<input id="Admission_modality_value→Keine_Zulassungsbeschränkung" name="rad_Admission_modality_value" type="radio" value="Admission_modality_value→Keine_Zulassungsbeschränkung" data-value="keine Zulassungsbeschränkung" required="required" class="form__radio-input" />
<label role="button" for="Admission_modality_value→Keine_Zulassungsbeschränkung" class="form__radio-label">
Keine Zulassungsbeschränkung
</label>
</li>
</ul>
</div>
</div>
</div>
<div class="filter-finder-function__col is-grid-col is-col-tablet-p-12">
<div class="form__radio">
<div class="form__label-wrapper">
<strong class="form__radio-legend">Type of School</strong>
</div>
<div class="form__radio-wrapper">
<ul class="form__radio-list">
<li class="form__radio-item">
<input id="Type_of_school_value→" name="rad_Type_of_school_value" type="radio" value="Type_of_school_value→" data-value="Gymnasium" class="form__radio-input" />
<label role="button" for="Type_of_school_value→" class="form__radio-label">
Gymnasium
</label>
</li>
<li class="form__radio-item">
<input id="Type_of_school_value→Realschule" name="rad_Type_of_school_value" type="radio" value="Type_of_school_value→Realschule" data-value="Realschule" class="form__radio-input" />
<label role="button" for="Type_of_school_value→Realschule" class="form__radio-label">
Realschule
</label>
</li>
<li class="form__radio-item">
<input id="Type_of_school_value→Grundschule" name="rad_Type_of_school_value" type="radio" value="Type_of_school_value→Grundschule" data-value="Grundschule" class="form__radio-input" />
<label role="button" for="Type_of_school_value→Grundschule" class="form__radio-label">
Grundschule
</label>
</li>
<li class="form__radio-item">
<input id="Type_of_school_value→Mittelschule" name="rad_Type_of_school_value" type="radio" value="Type_of_school_value→Mittelschule" data-value="Mittelschule" class="form__radio-input" />
<label role="button" for="Type_of_school_value→Mittelschule" class="form__radio-label">
Mittelschule
</label>
</li>
</ul>
</div>
</div>
</div>
<div class="filter-finder-function__col is-grid-col is-col-mobile-s-12 is-col-tablet-p-6">
<div class="select-multiple">
<div class="select-multiple__label-wrapper">
<label for="mul_Type_value" class="form__select-multiple__label">
Type
</label>
</div>
<div class="select-multiple__dropdown-wrapper select-multiple__dropdown--close">
<div class="select-multiple__dropdown-headline">Select Multiple</div>
<div class="select-multiple__overlay">
<select id="mul_Type_value" class="select-multiple__filter-select" data-js-module="form-select-multiple" name="mul_Type_value" multiple>
<option id="mul_Type_value→all" value="all" name="mul_Type_value→all" data-js-type="select-multiple__all">Select All</option>
<option id="mul_Type_value→Hauptfach" value="Hauptfach" name="mul_Type_value→Hauptfach">Hauptfach</option>
<option id="mul_Type_value→Didaktikfach" value="Didaktikfach" name="mul_Type_value→Didaktikfach">Didaktikfach</option>
<option id="mul_Type_value→Erweiterungsfach" value="Erweiterungsfach" name="mul_Type_value→Erweiterungsfach" disabled="disabled">Erweiterungsfach</option>
<option id="mul_Type_value→Unterrichtsfach" value="Unterrichtsfach" name="mul_Type_value→Unterrichtsfach">Unterrichtsfach</option>
<option id="mul_Type_value→Nebenfach" value="Nebenfach" name="mul_Type_value→Nebenfach">Nebenfach</option>
</select>
<div class="select-multiple__results"></div>
<div class="select-multiple__apply">
<a href="javascript:void(0);">Anwenden</a>
</div>
</div>
</div>
</div>
<div class="select-multiple__checkbox-container select-multiple__checkbox-container--sample">
<input type="checkbox" id="select-multiple__sample" class="select-multiple__checkbox">
<label for="select-multiple__sample">
<span class="select-multiple__label-inner">Lorem ipsum</span>
</label>
</div>
</div>
<div class="filter-finder-function__col is-grid-col is-col-mobile-s-12 is-col-tablet-p-6">
<div class="select-multiple">
<div class="select-multiple__label-wrapper">
<label for="mul_Name_value" class="form__select-multiple__label">
Dropdown 100%
</label>
</div>
<div class="select-multiple__dropdown-wrapper select-multiple__dropdown--close">
<div class="select-multiple__dropdown-headline">Select Multiple</div>
<div class="select-multiple__overlay">
<select id="mul_Name_value" class="select-multiple__filter-select" data-js-module="form-select-multiple" name="mul_Name_value" multiple>
<option id="mul_Name_value→all" value="all" name="mul_Name_value→all" data-js-type="select-multiple__all">Select All</option>
<option id="mul_Name_value→Option1" value="Option1" name="mul_Name_value→Option1">Option name 1</option>
<option id="mul_Name_value→Option2" value="Option2" name="mul_Name_value→Option2">Option name 2</option>
<option id="mul_Name_value→Option3" value="Option3" name="mul_Name_value→Option3" disabled="disabled">Option name 3</option>
</select>
<div class="select-multiple__results"></div>
<div class="select-multiple__apply">
<a href="javascript:void(0);">Anwenden</a>
</div>
</div>
</div>
</div>
<div class="select-multiple__checkbox-container select-multiple__checkbox-container--sample">
<input type="checkbox" id="select-multiple__sample" class="select-multiple__checkbox">
<label for="select-multiple__sample">
<span class="select-multiple__label-inner">Lorem ipsum</span>
</label>
</div>
</div>
<div class="filter-finder-function__col is-grid-col is-col-mobile-s-12">
<button type="submit" class="form__submit filter-finder-function__submit">
<span class="from_submit-arrow"></span>
<span class="form__submit-text">Absenden</span>
</button> </div>
<div class="filter-finder-function__col is-grid-col is-col-tablet-p-12" style="display: none">
<div class="filter-finder-function__filter-list" data-js-item="js-filter-finder-function-filter-list">
</div>
</div>
<div class="filter-finder-function__col is-grid-col is-col-tablet-p-12" style="display: none">
<div class="filter-finder-function__filter-reset" data-js-item="js-filter-finder-function-filter-reset">
<span>Filter zurücksetzen</span>
</div>
</div>
</div>
<div class="filter-finder-function__result-container">
<div class="filter-finder-function__result-loader">
<span class="filter-finder-function__result-loader-box is-one"></span>
<span class="filter-finder-function__result-loader-box is-two"></span>
<span class="filter-finder-function__result-loader-box is-three"></span>
</div>
<div class="filter-finder-function__result-area" data-js-item="js-filter-finder-function-result-area">
<div class="filter-finder-function__result-wrapper">
<div class="filter-finder-function__result-info" data-js-item="js-filter-course-finder-results-info">
<p><span class="filter-finder-function__total-item-count">0</span> <strong>Ergebnisse</strong> zum Thema <strong>Forschen</strong></p>
</div>
<div class="filter-finder-function__result-order">
<div class="filter-finder-function__result-per-page" data-js-item="js-filter-finder-function-results-per-page">
<p>Ergebnisse pro Seite <a href="javascript:void(0);" class="results-per-page__1 is-selected">1</a> | <a href="javascript:void(0);" class="results-per-page__2">2</a> | <a href="javascript:void(0);" class="results-per-page__50">50</a></p>
</div>
<div class="filter-finder-function__result-sorting" data-css="c-form">
<div class="filter-finder-function__col is-grid-col is-col-mobile-s-12">
<div class="form__select">
<div class="form__label-wrapper">
<label for="sorting" class="form__select-label">
Sortierung
</label>
</div>
<div class="form__select-wrapper">
<!--
data-placeholder="Bitte Wählen"
data-reset-text=" - "
data-has-reset-option="true|false"
-->
<select id="sorting" data-placeholder="Bitte Wählen" data-js-module="form-dropdown" name="sorting" data-js-item="js-filter-course-finder-results-sorting">
<option value="sorting→asc" selected>A bis Z</option>
<option value="sorting→desc">Z bis A</option>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="filter-finder-function__result-wrapper-inner">
<div class="filter-finder-function__result-item" data-js-item="js-filter-finder-function-result-template">
<p><a class="filter-finder-function__results-item-link" href="">This is a Title</a></p>
<p class="filter-finder-function__results-item-description">This is a Description about the Result Item</p>
</div>
<div class="filter-finder-function__result" data-js-item="js-filter-finder-function-result-list">
</div>
<div class="filter-finder-function__pagination-wrapper">
<div class="filter-finder-function__pagination-list" data-js-item="js-filter-finder-function-pagination-area">
<a id="pagination__firs-page">«</a>
<a id="pagination__prev-page">‹</a>
<div id="pagination__numbers-of-page"></div>
<a id="pagination__next-page">›</a>
<a id="pagination__last-page">»</a>
</div>
</div>
</div>
</div>
<div class="filter-finder-function__result-error">
<p>We're sorry, but <strong>nothing fits</strong> your search term. <strong>Please try again</strong> with other keywords.</p>
</div>
</div>
</form>
</div>