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

[VUFIND-1746] Drop bs3-compat.js #4224

Merged
merged 17 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public function testDefaultLimitSorting(): void
);
// Change the language:
$this->clickCss($page, '.language.dropdown');
$this->clickCss($page, '.language.dropdown li:not(.active) a');
$this->clickCss($page, '.language.dropdown li a:not(.active)');
$this->waitForPageLoad($page);
// Still sorted alphabetically, even though in a different language:
$this->assertEquals(
Expand Down Expand Up @@ -320,7 +320,7 @@ public function testLimitSortingWithOrderOverride(): void
);
// Change the language:
$this->clickCss($page, '.language.dropdown');
$this->clickCss($page, '.language.dropdown li:not(.active) a');
$this->clickCss($page, '.language.dropdown li a:not(.active)');
$this->waitForPageLoad($page);
// Still sorted alphabetically, even though in a different language:
$this->assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function testLanguage(): void
);
// Change the language:
$this->clickCss($page, '.language.dropdown');
$this->clickCss($page, '.language.dropdown li:not(.active) a');
$this->clickCss($page, '.language.dropdown li a:not(.active)');
$this->waitForPageLoad($page);
// Check footer help-link
$this->assertNotEquals(
Expand Down Expand Up @@ -132,7 +132,7 @@ public function testThemeSwitcher(): void

// Change the theme:
$this->clickCss($page, '.theme-selector.dropdown');
$this->clickCss($page, '.theme-selector.dropdown li:not(.active) a');
$this->clickCss($page, '.theme-selector.dropdown li a:not(.active)');
$this->waitForPageLoad($page);

// Check h1 again -- it should exist now
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function testSearch(array $queryParams, string $path): void
$this->waitForPageLoad($page);
$this->assertEquals(
'Blended',
$this->findCssAndGetText($page, '.searchbox li.active')
$this->findCssAndGetText($page, '.searchbox li a.active')
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ protected function addFavoriteWithTag(
?string $newListName = null,
bool $createAccount = false
): void {
$this->waitForPageLoad($page);
$this->clickCss($page, '.save-record');
if ($createAccount) {
$this->clickCss($page, '.modal-body .createAccountLink');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ protected function flipflopLanguage(Element $page): void
{
// Flip to German:
$this->clickCss($page, '.language.dropdown');
$this->clickCss($page, '.language.dropdown li:not(.active) a');
$this->clickCss($page, '.language.dropdown li a:not(.active)');
$this->waitForPageLoad($page);
// Flip back to English:
$this->clickCss($page, '.language.dropdown');
$this->clickCss($page, '.language.dropdown li:not(.active) a');
$this->clickCss($page, '.language.dropdown li a:not(.active)');
$this->waitForPageLoad($page);
}

Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap5/css/compiled.css

Large diffs are not rendered by default.

145 changes: 0 additions & 145 deletions themes/bootstrap5/js/bs3-compat.js

This file was deleted.

4 changes: 2 additions & 2 deletions themes/bootstrap5/js/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ VuFind.register('channels', function Channels() {
}
var $cont = $(
'<div class="dropdown">' +
'<button class="btn btn-link" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" aria-label="' + VuFind.translate('toggle_dropdown') + '">' +
'<button class="btn btn-link" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="true" aria-label="' + VuFind.translate('toggle_dropdown') + '">' +
VuFind.icon("ui-dots-menu") +
'</button>' +
'</div>'
Expand All @@ -24,7 +24,7 @@ VuFind.register('channels', function Channels() {
li.append(
$('<a/> ', {
'href': links[i].url,
'class': links[i].label,
'class': 'dropdown-item ' + links[i].label,
'html': '<i class="fa ' + links[i].icon + '"></i> ' + VuFind.translate(links[i].label)
})
);
Expand Down
23 changes: 3 additions & 20 deletions themes/bootstrap5/js/common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*global bootstrap, grecaptcha, isPhoneNumberValid, loadCovers */
/*global grecaptcha, isPhoneNumberValid, loadCovers */
/*exported VuFind, bulkFormHandler, deparam, escapeHtmlAttr, extractClassParams, getFocusableNodes, getUrlRoot, htmlEncode, phoneNumberFormHandler, recaptchaOnLoad, resetCaptcha, setupMultiILSLoginFields, unwrapJQuery */

var VuFind = (function VuFind() {
Expand Down Expand Up @@ -499,23 +499,12 @@ var VuFind = (function VuFind() {
setupQRCodeLinks();
};

function getBootstrapMajorVersion() {
// Bootstrap 5 defines bootstrap global, while 3 doesn't, so we can use that as
// an easy way to determine the version:
return typeof bootstrap === 'undefined' ? 3 : 5;
}

/**
* Disable transition effects and return the previous state
*
* @param {Element} elem Element to handle (not used with Bootstrap 3)
* @param {Element} elem Element to handle
*/
function disableTransitions(elem) {
if (getBootstrapMajorVersion() === 3) {
demiankatz marked this conversation as resolved.
Show resolved Hide resolved
const oldState = $.support.transition;
$.support.transition = false;
return oldState;
}
const oldState = elem.style.transitionDuration;
elem.style.transitionDuration = '0s';
return oldState;
Expand All @@ -524,15 +513,10 @@ var VuFind = (function VuFind() {
/**
* Restore transition effects to the given state
*
* @param {Element} elem Element to handle (not used with Bootstrap 3)
* @param {Element} elem Element to handle
* @param {(string|boolean)} state State from previous call to disableTransitions
*/
function restoreTransitions(elem, state) {
if (getBootstrapMajorVersion() === 3) {
$.support.transition = state;
return;
}

elem.style.transitionDuration = state;
}

Expand Down Expand Up @@ -633,7 +617,6 @@ var VuFind = (function VuFind() {
setInnerHtml: setInnerHtml,
setOuterHtml: setOuterHtml,
setElementContents: setElementContents,
getBootstrapMajorVersion: getBootstrapMajorVersion,
disableTransitions: disableTransitions,
restoreTransitions: restoreTransitions,
inURLSearchParams: inURLSearchParams,
Expand Down
14 changes: 4 additions & 10 deletions themes/bootstrap5/js/facets.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ VuFind.register('sideFacets', function SideFacets() {
try {
if ((' ' + storedItem + ' ').indexOf(' in ') > -1) {
$(item).collapse('show');
} else if (!$(item).data('forceIn')) {
} else if (!$(item).data('forceUncollapsed')) {
$(item).collapse('hide');
}
} finally {
Expand All @@ -601,15 +601,9 @@ VuFind.register('sideFacets', function SideFacets() {
facetGroup.on('hidden.bs.collapse', (e) => facetSessionStorage(e, 'collapsed'));

// Side facets loaded with AJAX
if (VuFind.getBootstrapMajorVersion() === 3) {
$('.side-facets-container-ajax')
.find('div.collapse[data-facet]:not(.in)')
.on('shown.bs.collapse', delayLoadAjaxSideFacets);
} else {
document.querySelectorAll('.side-facets-container-ajax div[data-facet]').forEach((collapseEl) => {
collapseEl.addEventListener('shown.bs.collapse', delayLoadAjaxSideFacets);
});
}
document.querySelectorAll('.side-facets-container-ajax div[data-facet]').forEach((collapseEl) => {
collapseEl.addEventListener('shown.bs.collapse', delayLoadAjaxSideFacets);
});
delayLoadAjaxSideFacets();

// Keep filter dropdowns on screen
Expand Down
9 changes: 1 addition & 8 deletions themes/bootstrap5/js/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,10 @@ function removeCheckRouteParam() {

function recordDocReady() {
removeCheckRouteParam();
$('.record-tabs .nav-tabs a').attr('aria-selected', 'false');
$('.record-tabs .nav-tabs .initiallyActive a').attr('aria-selected', 'true');
// update aria-selected attributes after a tab has been shown
$('.record-tabs .nav-tabs a').on('shown.bs.tab', function shownTab(e) {
$('.record-tabs .nav-tabs a').attr('aria-selected', 'false');
$(e.target).attr('aria-selected', 'true');
});
$('.record-tabs .nav-tabs a').on('click', function recordTabsClick() {
var $li = $(this).parent();
// If it's an active tab, click again to follow to a shareable link.
if ($li.hasClass('active')) {
if ($(this).hasClass('active')) {
return true;
}
var tabid = $li.attr('data-tab');
Expand Down
16 changes: 4 additions & 12 deletions themes/bootstrap5/js/searchbox_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,10 @@ VuFind.register('searchbox_controls', function SearchboxControls() {
}

function _updateKeyboardLayout(layoutName) {
if (VuFind.getBootstrapMajorVersion() === 3) {
$('.keyboard-selection-item').each(function deactivateItems() {
$(this).parent().removeClass("active");
});
$(".keyboard-selection-item[data-value='" + layoutName + "']").parent().addClass("active");
} else {
$('.keyboard-selection-item').each(function deactivateItems() {
$(this).removeClass("active");
$(this).addClass("dropdown-item");
});
$(".keyboard-selection-item[data-value='" + layoutName + "']").addClass("active");
}
$('.keyboard-selection-item').each(function deactivateItems() {
$(this).removeClass("active");
});
$(".keyboard-selection-item[data-value='" + layoutName + "']").addClass("active");
if (layoutName === "none") {
VuFind.cookie.remove("keyboard");
$("#keyboard-selection-button").removeClass("activated");
Expand Down
4 changes: 0 additions & 4 deletions themes/bootstrap5/scss/bs3-compat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,6 @@ h6, .h6 {
}
}

.fade.show {
demiankatz marked this conversation as resolved.
Show resolved Hide resolved
@extend .fade, .in;
}

// See .nav > li > a in bootstrap.scss
.nav.navbar-nav button.dropdown-toggle {
color: inherit;
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap5/scss/components/search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ body.rtl {

.collapse {
display: none;
.in {
.show {
display: inline-block;
}
}
Expand Down
4 changes: 0 additions & 4 deletions themes/bootstrap5/scss/components/sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
margin-bottom: 1rem;
}

[data-toggle="collapse"] {
cursor: pointer;
}

.collapse,
.collapsing,
&.full-facet-list .facet {
Expand Down
Loading