-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FINNA-2373] Fix search filters on smaller screens for sr #3110
base: dev
Are you sure you want to change the base?
Changes from 7 commits
544f55d
c8b766e
9d8fe14
f563216
bc92c6e
36330ef
0bfbcc0
dcfb196
25007eb
111bd71
e085708
ac518d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,14 +165,61 @@ finna.layout = (function finnaLayout() { | |
} | ||
} | ||
|
||
/** | ||
* Sidebar click on mobile | ||
*/ | ||
function onSidebarBtnClick() { | ||
$('.sidebar').toggleClass('open'); | ||
$('.mobile-navigation .sidebar-navigation i').toggleClass('fa-arrow-down'); | ||
$('body').toggleClass('prevent-scroll'); | ||
} | ||
|
||
/** | ||
* Check and keep focus within the search facet list | ||
* @param {object} e Event object | ||
*/ | ||
function onFocusOut(e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nimeäisin funktion kuvaavammin. |
||
const container = document.querySelector('.side-facets-container-ajax'); | ||
if (!container.contains(e.relatedTarget)) { | ||
container.focus(); | ||
} | ||
} | ||
|
||
/** | ||
* Initialize mobile narrow search | ||
*/ | ||
function initMobileNarrowSearch() { | ||
$('.mobile-navigation .sidebar-navigation, .finna-search-filter-toggle .btn-search-filter, .sidebar .sidebar-close-btn, .sidebar .mylist-bar h1').off('click').on('click', function onClickMobileNav() { | ||
$('.sidebar').toggleClass('open'); | ||
$('.mobile-navigation .sidebar-navigation i').toggleClass('fa-arrow-down'); | ||
$('body').toggleClass('prevent-scroll'); | ||
$('.mobile-navigation .sidebar-navigation, .sidebar .mylist-bar h1').off('click').on('click', function onClickMobileNav() { | ||
onSidebarBtnClick(); | ||
}); | ||
const container = document.querySelector(".side-facets-container-ajax"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pitää tarkistaa, löytyikö container (tyyliin |
||
$('.finna-search-filter-toggle .btn-search-filter, .sidebar .sidebar-close-btn').off('click').on('click', function onClickMobileNav() { | ||
onSidebarBtnClick(); | ||
if (document.querySelector('.sidebar').classList.contains('open')) { | ||
document.activeElement.blur(); | ||
container.querySelector('h1').focus(); | ||
} else { | ||
document.activeElement.blur(); | ||
document.querySelector('.finna-search-filter-toggle .btn-search-filter').focus(); | ||
} | ||
}); | ||
container.tabIndex = '0'; | ||
container.ariaModal = true; | ||
container.querySelector('h1').tabIndex = '0'; | ||
$('.finna-search-filter-toggle .btn-search-filter, .sidebar .sidebar-close-btn').off('keydown').on('keydown', function onClickMobileNav(e) { | ||
if (e.which === 32 || e.which === 13) { | ||
e.preventDefault(); | ||
onSidebarBtnClick(); | ||
if (document.querySelector('.sidebar').classList.contains('open')) { | ||
container.addEventListener('focusout', onFocusOut); | ||
document.activeElement.blur(); | ||
container.querySelector('h1').focus(); | ||
} else { | ||
document.activeElement.blur(); | ||
document.querySelector('.finna-search-filter-toggle .btn-search-filter').focus(); | ||
container.removeEventListener('focusout', onFocusOut); | ||
} | ||
} | ||
}); | ||
$('.mobile-navigation .sidebar-navigation .active-filters').off('click').on('click', function onClickMobileActiveFilters() { | ||
$('.sidebar').scrollTop(0); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,10 @@ | |
$extraUrlFields = $results->getUrlQuery()->getParamsWithConfiguredDefaults(); | ||
?> | ||
<div class="side-facets-container-ajax" data-search-class-id="<?=$this->escapeHtmlAttr($this->searchClassId) ?>" data-location="<?=$this->escapeHtmlAttr($this->location) ?>" data-config-index="<?=$this->escapeHtmlAttr($this->configIndex)?>" data-query="<?=$this->escapeHtmlAttr($urlQuery)?>" data-query-suppressed="<?=$querySuppressed ? '1' : '0' ?>" data-extra-fields="<?=$this->escapeHtml(implode(',', $extraUrlFields))?>"> | ||
<h1><?=$this->transEsc($this->slot('side-facet-caption')->get('Narrow Search')) ?><?php if (null === $this->slot('side-facet-caption')->get() && !$this->translationEmpty('tooltip_facet_html')): ?><span class="tooltip-facet pull-right" data-toggle="tooltip" data-placement="auto" data-html="true" data-original-title="<?=$this->transEsc('tooltip_facet_html')?>"><?=$this->icon('help') ?></span><?php endif; ?><span role="button" class="visible-xs sidebar-close-btn" aria-label="<?=$this->transEsc('close')?>"><?=$this->icon('sidefacets-close', 'sidefacets-close-icon') ?></span></h1><?php endif; ?> | ||
<div class="header-container"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pitäsikö luokan nimi olla side-facets-header-container tms.? Nyt ehkä vähän liian geneerinen. |
||
<h1><?=$this->transEsc($this->slot('side-facet-caption')->get('Narrow Search')) ?><?php if (null === $this->slot('side-facet-caption')->get() && !$this->translationEmpty('tooltip_facet_html')): ?><span class="tooltip-facet pull-right" data-toggle="tooltip" data-placement="auto" data-html="true" data-original-title="<?=$this->transEsc('tooltip_facet_html')?>"><?=$this->icon('help') ?></span><?php endif; ?></h1> | ||
<button role="button" class="visible-xs sidebar-close-btn" tabindex="0" aria-label="<?=$this->transEsc('close')?>"><?=$this->icon('sidefacets-close', 'sidefacets-close-icon') ?></button><?php endif; ?> | ||
</div> | ||
<?php $checkboxFilters = $params->getCheckboxFacets(); ?> | ||
<?php $checkboxesShown = false; ?> | ||
<?php if (count($checkboxFilters) > 0): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ei ikonin luokkaa kovakoodattuna. Jos pitää JS:ssä vaihtaa ikonia, niin pitää laittaa templaatissa kaksi ikonia, joita vaihdellaan.