Skip to content
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

Switch to Bootstrap 5 as the base theme. #3135

Merged
merged 170 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 144 commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
25789bb
Switch to Bootstrap 5 as the base theme.
EreMaijala Dec 11, 2024
0110643
Misc fixes.
EreMaijala Dec 11, 2024
bf30eed
improvements
EreMaijala Dec 11, 2024
94e9150
navbar working etc.
EreMaijala Dec 11, 2024
57c4a25
Fix modal, tabs.
EreMaijala Dec 12, 2024
b01b08e
Fix tabs, tooltips and truncate.
EreMaijala Dec 16, 2024
c25200e
Fix finna-panel, order of bootstrap variable overrides.
EreMaijala Dec 20, 2024
2a377b4
Disable link hover decoration by default.
EreMaijala Dec 20, 2024
f4d3f6c
Add bs3 compat rules.
EreMaijala Dec 20, 2024
2bb2c85
Update custom theme finna.scss
EreMaijala Jan 7, 2025
fd336cd
Fix input border color.
EreMaijala Jan 7, 2025
102e827
Fix account tooltip with Bootstrap 5. (#4163)
EreMaijala Dec 16, 2024
f84cd5e
Fix lagnuage menu width.
EreMaijala Jan 8, 2025
6c296e0
Fix language menu URL creation.
EreMaijala Jan 8, 2025
4db43c3
Fix tab tooltip buttons.
EreMaijala Jan 8, 2025
d54259e
Enable shadows.
EreMaijala Jan 8, 2025
f4b27b1
Disable button shadows.
EreMaijala Jan 8, 2025
3aed8c6
Move all BS3 compat JS to Finna version.
EreMaijala Jan 9, 2025
8aedafb
Fix browsebar.
EreMaijala Jan 9, 2025
9dae275
Improve navibar back-compatibility.
EreMaijala Jan 9, 2025
085b94e
Fix search tip and tabs background.
EreMaijala Jan 9, 2025
349fc26
Add FA brand icons.
EreMaijala Jan 9, 2025
23d6193
Fix JS docs and issues.
EreMaijala Jan 9, 2025
b144787
Fix code style.
EreMaijala Jan 9, 2025
f474ad0
Fix header-navibar example
EreMaijala Jan 10, 2025
dc131c6
Tweak iconlabel, list-group-item, search type
EreMaijala Jan 10, 2025
52b71da
Fix organisation info buttons.
EreMaijala Jan 10, 2025
57d2471
Fix navbar font size.
EreMaijala Jan 13, 2025
297aa5c
Don't use btn class in language menu toggle.
EreMaijala Jan 13, 2025
1a5227b
Misc fixes.
EreMaijala Jan 13, 2025
04653e9
Fix active tab bottom border.
EreMaijala Jan 14, 2025
3f02f90
Remove strong from example footer.
EreMaijala Jan 14, 2025
940d794
Fix col-xs-*
EreMaijala Jan 14, 2025
a9a016f
Add bootstrap-map-overrides.
EreMaijala Jan 14, 2025
05a071b
Fix xs cols.
EreMaijala Jan 14, 2025
ba33bfa
Fix text-right.
EreMaijala Jan 14, 2025
2f461b5
Fix multi-level navigation thingy.
EreMaijala Jan 15, 2025
7ccdb26
Add .text-left.
EreMaijala Jan 15, 2025
e45b5f2
Fix blockquote
EreMaijala Jan 15, 2025
af4a28f
Fix panels.
EreMaijala Jan 15, 2025
d68064d
Fix profile page labels.
EreMaijala Jan 15, 2025
df1a408
Fix dropdown menus.
EreMaijala Jan 15, 2025
9954231
Fix table caption position.
EreMaijala Jan 15, 2025
d4267dd
Fix textarea sizing.
EreMaijala Jan 15, 2025
0da9545
Fix table border spacing.
EreMaijala Jan 15, 2025
236d4a5
Fix myresearch tables.
EreMaijala Jan 15, 2025
ff70847
Fix search history table.
EreMaijala Jan 15, 2025
5262a39
Fix hierarchy tree search form.
EreMaijala Jan 15, 2025
a637a86
Fix narrow tabs.
EreMaijala Jan 15, 2025
e636b59
Fix mobile toolbar.
EreMaijala Jan 15, 2025
5cec9c1
Fix input-group and input-group buttons
EreMaijala Jan 16, 2025
4bddcd5
Fix input-year appearance.
EreMaijala Jan 16, 2025
354f48c
Fix navbar top margin calculation.
EreMaijala Jan 16, 2025
2aef34c
Fix finna-main-tabs bottom padding.
EreMaijala Jan 16, 2025
1fa490e
Fix facet sort buttons.
EreMaijala Jan 16, 2025
820db49
Fix focus rings.
EreMaijala Jan 16, 2025
f32e3e9
Fix tooltip event listener setup.
EreMaijala Jan 17, 2025
56f5a59
Add table-condenced for BC.
EreMaijala Jan 17, 2025
05cb5e1
Fix more/less link color in access rights.
EreMaijala Jan 17, 2025
e628de1
Load bs3-compat early to fix facet timeline init.
EreMaijala Jan 17, 2025
1df44d1
Fix dropdown-header x padding.
EreMaijala Jan 17, 2025
d83ccf8
Fix borrowing block message display in holdings.
EreMaijala Jan 17, 2025
4f404fb
Add .hide
EreMaijala Jan 17, 2025
1577056
Fix datatables pagination, align pagination better.
EreMaijala Jan 17, 2025
e40487b
Fix tooltip hide-on-click and tooltips in tabs.
EreMaijala Jan 17, 2025
5ec8c65
Fix code style.
EreMaijala Jan 20, 2025
483ed75
Fix bottom margin of .label
EreMaijala Jan 20, 2025
fe5b36c
Merge compat scss files, fix badges and labels.
EreMaijala Jan 20, 2025
58df4d6
Fix focus rings in search bar and facets.
EreMaijala Jan 20, 2025
ea9eecf
Fix focus ring in hierarchy tree and tab content.
EreMaijala Jan 20, 2025
8e6f81e
List organisation list focus rings.
EreMaijala Jan 20, 2025
3304ce3
Limit navbar-brand width to 150px.
EreMaijala Jan 20, 2025
0af5db3
Fix focus rings in image popup and record provider.
EreMaijala Jan 21, 2025
264fb03
Improve image-popup close button focus ring.
EreMaijala Jan 21, 2025
6089402
Fix tab tooltips, hopefully.
EreMaijala Jan 21, 2025
6653f16
Fix keyboard navigation and focus ring in finna-panel.
EreMaijala Jan 21, 2025
b370e3e
Fix image pagination visible focus.
EreMaijala Jan 21, 2025
8fc4a0e
Improve look of tabs.
EreMaijala Jan 22, 2025
b159695
Fix image popup arrow button focus rings.
EreMaijala Jan 22, 2025
b643e94
Add aria-expanded="false" to dropdown toggles.
EreMaijala Jan 23, 2025
55e5b6e
Switch to dual-color focus ring for improved visibility.
EreMaijala Jan 23, 2025
9e8f7fb
Fix collapsed navbar shadow.
EreMaijala Jan 23, 2025
d020332
Fix record page tabs, tab colors. Convert data attributes.
EreMaijala Jan 23, 2025
b8eb8c5
Tweal staff view icon.
EreMaijala Jan 23, 2025
ef3a6f3
Fix focus rings in truncated fields and holdings.
EreMaijala Jan 24, 2025
a808597
Fix browsebar focus rings.
EreMaijala Jan 24, 2025
ae65be3
Fix toggler outlines on webkit.
EreMaijala Jan 24, 2025
acfe6ee
Unify record toolbar buttons.
EreMaijala Jan 24, 2025
16cfd18
Restore font size and weight of finna-main-tabs.
EreMaijala Jan 24, 2025
f10c30f
Add a bit of top margin to organisation list on record page.
EreMaijala Jan 24, 2025
f3b31c7
Fix positioning of share buttons.
EreMaijala Jan 24, 2025
98d5f05
Fix invalid and self-closing br's.
EreMaijala Jan 24, 2025
b423589
Fix finna-main-tabs padding more.
EreMaijala Jan 24, 2025
8505d33
Fix active class and aria-current in navibar.
EreMaijala Jan 24, 2025
dc49535
Fix mobile navibar look and scrolling.
EreMaijala Jan 24, 2025
135fd18
Fix custom search tab.
EreMaijala Jan 24, 2025
8dfb735
Fix more/less button colors on mobile Safari.
EreMaijala Jan 24, 2025
2453449
Fix facet expand/collapse button color on mobile Safari, focus ring, …
EreMaijala Jan 24, 2025
8000b8f
Test replacing main tabs tooltips with popovers.
EreMaijala Jan 24, 2025
ca487ca
Switch to custom implementation for search tabs tooltips.
EreMaijala Jan 27, 2025
bfc4906
Tweak navibar look on narrow screens.
EreMaijala Jan 27, 2025
af45933
Fix search history table.
EreMaijala Jan 27, 2025
7e820a2
Fix double-striped search history table.
EreMaijala Jan 27, 2025
58b0bae
Improved fix for focus rings in browsebar.
EreMaijala Jan 27, 2025
84ed585
Add support for disabling priority-nav in browsebar.
EreMaijala Jan 27, 2025
a01e9f1
Fix search tabs tooltip button aria-label.
EreMaijala Jan 27, 2025
e1fbbe3
Constrain navbar-brand height to counter over-high logos.
EreMaijala Jan 27, 2025
85e55b2
Make sure record tabs don't overlay the sidebar.
EreMaijala Jan 27, 2025
bc51834
Clean up finna-nav and fix record tabs classes and language menu clas…
EreMaijala Jan 29, 2025
86dfb16
Fix finna-navbar dropdown styles.
EreMaijala Jan 29, 2025
2b2619f
Fix cart popover heading.
EreMaijala Jan 29, 2025
30f8493
Fix collapse in=>show, add dropdown-item classes.
EreMaijala Jan 29, 2025
fda3935
Remove commented-out styles.
EreMaijala Jan 29, 2025
a5b64fb
Update data attributes.
EreMaijala Jan 29, 2025
4e0e861
Tentatively comment out an old compat style.
EreMaijala Jan 29, 2025
59bc74f
Fix cart and active dropdown item color in navibar.
EreMaijala Jan 29, 2025
aa45d93
Reduce compat JS with newest template/style changes.
EreMaijala Jan 29, 2025
0e44412
Remove unused const.
EreMaijala Jan 29, 2025
18220cd
Fix JSDoc.
EreMaijala Jan 29, 2025
32831cd
Drop navbar handling from compat JS.
EreMaijala Jan 29, 2025
d4b384b
Merge branch 'dev' into dev-finna2-bootstrap5
EreMaijala Jan 30, 2025
e5dd3d4
Use prefix variable instead of hardcoded '--bs'-
EreMaijala Jan 30, 2025
177002e
Revert "Fix xs cols."
EreMaijala Jan 30, 2025
3391618
Revert accidental changes to bootstrap5 theme.
EreMaijala Jan 30, 2025
5539bc9
Fix finna:build:scss.
EreMaijala Jan 30, 2025
fa47557
Silence current known deprecations in scss compilation.
EreMaijala Jan 30, 2025
5d19b05
Reduce use of deprecated functions.
EreMaijala Jan 30, 2025
50e2601
Fix record-holdings-table.
EreMaijala Jan 30, 2025
6a35394
Fix record display in details tab and bookbag add/remove button.
EreMaijala Jan 30, 2025
e1862fa
Revert truncate to use clip instead of hidden for proper layout in re…
EreMaijala Jan 30, 2025
e04e551
Add a workaround for lightbox focus issue.
EreMaijala Jan 31, 2025
27f3f6d
Remove obsolete focus handling code.
EreMaijala Jan 31, 2025
04f026c
Fix sort list code.
EreMaijala Jan 31, 2025
7010307
Fix facet bottom margin.
EreMaijala Jan 31, 2025
07dfcba
Fix language dropdown.
EreMaijala Jan 31, 2025
c7fa08e
Fix feed and event tabs and pills.
EreMaijala Jan 31, 2025
94da9d3
Fix page-content width.
EreMaijala Jan 31, 2025
9024fed
Add a11y fix for dropdowns.
EreMaijala Jan 31, 2025
8f9beb7
Remove extraneous aria-label from linked events tabs.
EreMaijala Jan 31, 2025
7cc0599
Change p to span in feeds to avoid styling issues in content pages
EreMaijala Jan 31, 2025
4e2ea57
Fix bad html.
EreMaijala Jan 31, 2025
3a222fe
Fix duplicate id="export-options".
EreMaijala Jan 31, 2025
4abb1f0
Fix initial focus handling in lightbox with Bootstrap 5. (#4223)
EreMaijala Jan 31, 2025
ae9e1f0
Revert "Add a workaround for lightbox focus issue."
EreMaijala Jan 31, 2025
c6780ef
Fix loading of initial active feed tab or pill.
EreMaijala Feb 3, 2025
50e5281
Fix "Powered by Finna" logo when a language variant does not exist.
EreMaijala Feb 4, 2025
08fbb74
Add gap between footer columns.
EreMaijala Feb 4, 2025
b60aea5
Try to fix duplicate .title-bottom in carousel.
EreMaijala Feb 5, 2025
729e3bb
Improve grid breakpoint map for better back-compatibility.
EreMaijala Feb 5, 2025
d8e602a
Fix .page-content width again to avoid overflow with columns
EreMaijala Feb 5, 2025
0bb44b3
Convert main color settings.
EreMaijala Feb 5, 2025
184a2f7
Update custom theme's variables.scss
EreMaijala Feb 5, 2025
62f5a92
Whitespace.
EreMaijala Feb 5, 2025
8967a66
Fix legacy help-tabs.
EreMaijala Feb 5, 2025
a3dfc0f
Fix invalid max width for xs container. Fix myresearch-row and toolba…
EreMaijala Feb 5, 2025
c9b8d0c
Fix feed pills font weight.
EreMaijala Feb 5, 2025
ff5bf9a
Fix a couple of icons and improve browsebar alignment.
EreMaijala Feb 5, 2025
b5340e8
Fix feed scroll buttons on narrow screens.
EreMaijala Feb 5, 2025
1a2b423
Stop toggletips from jumping.
EreMaijala Feb 5, 2025
be02023
Revert all page-content width changes.
EreMaijala Feb 5, 2025
b04e51c
Fix tabs in content pages.
EreMaijala Feb 5, 2025
8b49f25
Increase warning subtle background color intensity a bit.
EreMaijala Feb 5, 2025
187dfc8
Improve item status mobile layout.
EreMaijala Feb 6, 2025
449b5f0
Fix alignment issues etc. in mobile toolbar.
EreMaijala Feb 6, 2025
f633591
Stop messing with mobile toolbar in finna-bs3-compat.js
EreMaijala Feb 6, 2025
8c4c1ab
Use word-wrap instead of tab-wrap in tabs.
EreMaijala Feb 6, 2025
93f9c2e
Fix alignment of search type dropdown with older browsers.
EreMaijala Feb 6, 2025
e4daf4a
Fix language menu active item color.
EreMaijala Feb 6, 2025
36628b9
Restore a small gap between icon and text in browsebar.
EreMaijala Feb 6, 2025
b8502ab
Fix vertical padding of breadcrumbs.
EreMaijala Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Gruntfile.local.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ module.exports = function(grunt) {
grunt.registerTask("finna:scss", function finnaScssFunc() {
const config = getFinnaSassConfig({
outputStyle: style,
quietDeps: true
quietDeps: true,
silenceDeprecations: [
'import',
'color-functions',
'global-builtin',
'legacy-js-api'
]
}, false);
grunt.config.set('dart-sass', config);
grunt.task.run('dart-sass');
Expand Down Expand Up @@ -82,7 +88,8 @@ module.exports = function(grunt) {
}
config.options.includePaths = getLoadPaths('themes/' + themeList[i] + '/scss/finna.scss');
config.options.includePaths.push('vendor/');
config.options.includePaths.push(path.resolve('themes/bootstrap3/scss/vendor'));
config.options.includePaths.push(path.resolve('themes/bootstrap5/scss/vendor'));
config.options.includePaths.push(path.resolve('themes/bootstrap5/node_modules'));

sassConfig[themeList[i]] = config;
}
Expand Down
2 changes: 1 addition & 1 deletion module/Finna/src/Finna/View/Helper/Root/LayoutClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/
class LayoutClass extends \VuFind\View\Helper\Bootstrap3\LayoutClass
class LayoutClass extends \VuFind\View\Helper\Bootstrap5\LayoutClass
{
/**
* Helper to allow easily configurable page layout -- given a broad class
Expand Down
35 changes: 21 additions & 14 deletions module/Finna/src/Finna/View/Helper/Root/Navibar.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* PHP version 8
*
* Copyright (C) The National Library of Finland 2014.
* Copyright (C) The National Library of Finland 2014-2025.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
Expand All @@ -23,6 +23,7 @@
* @category VuFind
* @package View_Helpers
* @author Samuli Sillanpää <[email protected]>
* @author Ere Maijala <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*/
Expand All @@ -42,6 +43,7 @@
* @category VuFind
* @package View_Helpers
* @author Samuli Sillanpää <[email protected]>
* @author Ere Maijala <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*/
Expand Down Expand Up @@ -194,20 +196,25 @@ public function getMenuItemUrl(array $data)
*/
public function getLanguageUrl($lng)
{
$url = $this->view->serverUrl(true);
$parts = parse_url($url);

$params = [];
if (isset($parts['query'])) {
parse_str($parts['query'], $params);
$url = substr($url, 0, strpos($url, '?'));
}
$url = $this->router->getRequestUri();
$params = $url->getQueryAsArray();
$params['lng'] = $lng;
$url .= '?' . http_build_query($params);
if (isset($parts['fragment'])) {
$url .= '#' . $parts['fragment'];
}
return $url;
$url->setQuery(http_build_query($params));
return $url->toString();
}

/**
* Check if a URL points to the current page
*
* @param string $url URL
*
* @return bool
*/
public function isCurrentPage(string $url): bool
{
$requestUri = $this->router->getRequestUri();
return $url === (string)$requestUri
|| $url === $requestUri->getPath();
}

/**
Expand Down
3 changes: 1 addition & 2 deletions themes/bootstrap5/js/account_ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ VuFind.register('account', function Account() {
accountIconEl.dataset.bsToggle = 'tooltip';
accountIconEl.dataset.bsPlacement = 'bottom';
accountIconEl.title = VuFind.translate('account_has_alerts');
const tooltip = bootstrap.Tooltip.getOrCreateInstance(accountIconEl);
tooltip.show();
bootstrap.Tooltip.getOrCreateInstance(accountIconEl);
} else {
const tooltip = bootstrap.Tooltip.getOrCreateInstance(accountIconEl);
tooltip.dispose();
Expand Down
4 changes: 2 additions & 2 deletions themes/bootstrap5/js/lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ VuFind.register('lightbox', function Lightbox() {
// remove nodes on whose click, the modal closes
var nodesWhichAreNotCloseTargets = focusableNodes.filter(function nodeFilter(node) {
return !node.hasAttribute("data-lightbox-close") && (
!node.hasAttribute("data-dismiss") ||
node.getAttribute("data-dismiss") !== "modal"
!node.hasAttribute("data-bs-dismiss") ||
node.getAttribute("data-bs-dismiss") !== "modal"
);
});

Expand Down
68 changes: 59 additions & 9 deletions themes/custom/scss/finna.scss
Original file line number Diff line number Diff line change
@@ -1,27 +1,77 @@
@import "../../finna2/scss/scss-functions";
// Include Bootstrap functions first (so you can manipulate colors, SVGs, calc, etc)
@import "scss-functions";
@import "bootstrap/scss/functions";

// Custom theme variable overrides
@import "variables-custom";

// Variable overrides
@import "variables";

// Include Font Awesome
$fa-font-path: "../../bootstrap5/css/vendor/font-awesome/webfonts" !default;
@import "vendor/font-awesome/fontawesome";
@import "vendor/font-awesome/brands";
@import "vendor/font-awesome/regular";
@import "vendor/font-awesome/solid";
@import "vendor/font-awesome/v4-shims";

// Finna Bootstrap variable overrides
@import "../../finna2/scss/global/bootstrap-variable-overrides";

// Font Awesome (loaded via include path to silence warnings from dependencies)
@import "font-awesome/font-awesome";
// Include remainder of required Bootstrap stylesheets (including any separate color mode stylesheets)
@import "bootstrap/scss/variables";

// Include any map overrides here
@import "global/bootstrap-map-overrides";

// Include remainder of required parts
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/root";
@import "bootstrap/scss/reboot";

// Optionally include any other parts as needed
@import "bootstrap/scss/accordion";
@import "bootstrap/scss/alert";
@import "bootstrap/scss/badge";
@import "bootstrap/scss/breadcrumb";
@import "bootstrap/scss/buttons";
@import "bootstrap/scss/button-group";
@import "bootstrap/scss/card";
@import "bootstrap/scss/carousel";
@import "bootstrap/scss/containers";
@import "bootstrap/scss/dropdown";
@import "bootstrap/scss/forms";
@import "bootstrap/scss/grid";
@import "bootstrap/scss/helpers";
@import "bootstrap/scss/images";
@import "bootstrap/scss/list-group";
@import "bootstrap/scss/modal";
@import "bootstrap/scss/nav";
@import "bootstrap/scss/navbar";
@import "bootstrap/scss/offcanvas";
@import "bootstrap/scss/pagination";
@import "bootstrap/scss/popover";
@import "bootstrap/scss/tables";
@import "bootstrap/scss/tooltip";
@import "bootstrap/scss/transitions";
@import "bootstrap/scss/type";
@import "bootstrap/scss/utilities";

// Optionally include utilities API last to generate classes based on the Sass map in `_utilities.scss`
@import "bootstrap/scss/utilities/api";

// Bootstrap v3.4.1 (loaded via include path to silence warnings from dependencies)
@import "vendor/bootstrap/bootstrap";
// Bootstrap 3 compatibility layer
@import "global/finna-bs3-compat";

// Finna variables
@import "../../finna2/scss/global/variables";

// Bootstrap3 theme components
@import "../../bootstrap3/scss/components/cookie-consent/index";
@import "../../bootstrap3/scss/components/keyboard";
@import "../../bootstrap3/scss/components/trees";
// Bootstrap5 theme components
@import "../../bootstrap5/scss/components/cookie-consent/index";
@import "../../bootstrap5/scss/components/keyboard";
@import "../../bootstrap5/scss/components/trees";

@import "../../finna2/scss/global";
@import "../../finna2/scss/finna-other";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- START of: finna - layout/Additions/header-navibar.phtml -->
<!-- add li elements with class custom to match style if you need links after language options -->
<?php // add li elements with classes "nav-item custom" to match style if you need links after language options ?>
<!--
<li class="custom">
<li class="nav-item custom">
<a href="" target="_blank">≤?=$this->transEsc('menu_translate');?></a>
</li>....
-->
Expand Down
34 changes: 10 additions & 24 deletions themes/finna2/js/finna-a11y.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,18 @@ finna.a11y = (function a11y() {
* Initialize event listeners for bootstrap accessibility
*/
function initA11y() {

// On dropdown open
$(document).on('shown.bs.dropdown', function dropdownOpen(event) {
var dropdown = $(event.target);

// Set aria-expanded to true
dropdown.find('.dropdown-toggle').attr('aria-expanded', true);

// Set focus on the first link in the dropdown
setTimeout(function shiftFocus() {
dropdown.find('.dropdown-menu li:first-child a').trigger("focus");
}, 50);
});

// On dropdown close
$(document).on('hidden.bs.dropdown', function dropdownClose(event) {
var dropdown = $(event.target);

// Set aria-expanded to false
dropdown.find('.dropdown-toggle').attr('aria-expanded', false);

// Set focus back to dropdown toggle
dropdown.find('.dropdown-toggle').trigger("focus");
// Focus first dropdown item when a dropdown is opened
document.addEventListener('shown.bs.dropdown', (e) => {
const dropdownEl = e.target.closest('.dropdown');
if (dropdownEl) {
const firstItemEl = dropdownEl.querySelector(':scope > .dropdown-menu > li > .dropdown-item');
if (firstItemEl) {
firstItemEl.focus();
}
}
});

// Restore focus back to trigger element after lightbox is closed.
// Restore focus back to trigger element after lightbox is closed
$(document).on('show.bs.modal', function triggerFocusShift() {
let triggerElement = document.activeElement;
$(document).one('hidden.bs.modal', function restoreFocus() {
Expand Down
123 changes: 123 additions & 0 deletions themes/finna2/js/finna-bs3-compat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*global VuFind*/
VuFind.register('finnaBootstrap3CompatibilityLayer', function finnaBootstrap3CompatibilityLayer() {
/**
* Initialize nav support
*/
function initNav() {
document.querySelectorAll('.nav').forEach((navEl) => {
if (navEl.classList.contains('nav-tabs')) {
// Apply active class to tab li for back-compatibility:
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if ('attributes' !== mutation.type || mutation.attributeName !== 'class') {
return;
}
const target = mutation.target;
if (target.nodeName === 'A' && target.parentNode && target.classList.contains('active')) {
target.parentNode.classList.add('active');
} else {
target.parentNode.classList.remove('active');
}
});
});
observer.observe(navEl, { attributes: true, attributeFilter: ['class'], subtree: true });
}
navEl.querySelectorAll(':scope > li').forEach((liEl) => {
const aEl = liEl.querySelector(':scope > a');
if (liEl.classList.contains('dropdown__item')) {
if (aEl && !aEl.classList.contains('btn')) {
aEl.classList.add('dropdown-item');
if (liEl.classList.contains('active')) {
aEl.classList.add('active');
}
}
} else if (aEl) {
const oldStateA = VuFind.disableTransitions(aEl);
if (!aEl.classList.contains('btn') && !aEl.closest('.browsebar')) {
aEl.classList.add('nav-link');
}
if (liEl.classList.contains('active')) {
aEl.classList.add('active');
if (null === liEl.closest('.searchForm')) {
liEl.classList.remove('active');
}
}
// Use a timeout to allow the transition to complete before restoring the state:
setTimeout(() => { VuFind.restoreTransitions(aEl, oldStateA); }, 0);
}
});
});

// Reverse effects of record.js:
setTimeout(
() => {
$('.record-tabs .nav-tabs a').off('shown.bs.tab');
document.querySelectorAll('.record-tabs .nav-tabs li').forEach((liEl) => {
liEl.removeAttribute('aria-selected');
});
},
0
);
}

/**
* Initialize breadcrumb support
*/
function initBreadcrumbs() {
document.querySelectorAll('.breadcrumb li').forEach((el) => {
el.classList.add('breadcrumb-item');
});
}

/**
* Initialize form element support
*/
function initFormElements() {
document.querySelectorAll('select.form-control').forEach((el) => {
el.classList.add('form-select');
});
}

/**
* Initialize pagination support
*/
function initPagination() {
document.querySelectorAll('.pagination li').forEach((el) => {
el.classList.add('page-item');
const linkEl = el.querySelector('a');
if (linkEl) {
linkEl.classList.add('page-link');
} else {
el.innerHTML = '<a href="#" class="page-link">' + el.innerHTML + '</a>';
}
});
}

/**
* Initialize dropdown support
*/
function initDropdownStyles() {
document.querySelectorAll('ul.dropdown-menu > li > a').forEach((el) => {
el.classList.add('dropdown-item');
});
document.querySelectorAll('.dropdown-menu-right').forEach((el) => {
el.classList.add('dropdown-menu-end');
});
}

/**
* Initialize all back-compatibility support functions
*/
function init() {
initNav();
initFormElements();
initBreadcrumbs();
initPagination();

initDropdownStyles();
}

return {
init: init
};
});
Loading