Skip to content

Commit

Permalink
Fixing JS exceptions on profiles page (#9904)
Browse files Browse the repository at this point in the history
  • Loading branch information
advay26 committed Apr 29, 2024
1 parent 8033d34 commit a3c390c
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions src/NuGetGallery/Scripts/gallery/page-list-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,42 +48,49 @@ $(function() {
collapsible.addEventListener('click', toggleCollapsible);
}

const advancedSearchToggleButton = document.getElementById('advancedSearchToggleButton');
advancedSearchToggleButton.addEventListener('click', toggleAdvancedSearchPanel);
var resized = false;
var initialScreenSize = window.innerWidth;
const chevronIcon = document.getElementById('advancedSearchToggleChevron');

const advancedSearchToggleButton = document.getElementById('advancedSearchToggleButton');

if (advancedSearchToggleButton) {
advancedSearchToggleButton.addEventListener('click', toggleAdvancedSearchPanel);
}

window.addEventListener('resize', () => {
resized = true;
toggleAdvancedSearchPanel();
});

/* For narrow screens only */
function toggleAdvancedSearchPanel() {

const filtersContent = document.getElementById('advancedSearchPanel');
var computedStyle = window.getComputedStyle(filtersContent);

if (window.innerWidth <= 992 && !resized) {
filtersContent.style.display = (computedStyle.display === 'none') ? 'block' : 'none';
chevronIcon.classList.toggle('ms-Icon--ChevronDown');
chevronIcon.classList.toggle('ms-Icon--ChevronUp');
}
else if (window.innerWidth <= 992 && initialScreenSize > 992 && resized) {
filtersContent.style.display = 'none';
chevronIcon.classList.add('ms-Icon--ChevronDown');
chevronIcon.classList.remove('ms-Icon--ChevronUp');
if (filtersContent) {
var computedStyle = window.getComputedStyle(filtersContent);

}
else if (window.innerWidth > 992) {
filtersContent.style.display = 'block';
if (window.innerWidth <= 992 && !resized) {
filtersContent.style.display = (computedStyle.display === 'none') ? 'block' : 'none';
chevronIcon.classList.toggle('ms-Icon--ChevronDown');
chevronIcon.classList.toggle('ms-Icon--ChevronUp');
}
else if (window.innerWidth <= 992 && initialScreenSize > 992 && resized) {
filtersContent.style.display = 'none';
chevronIcon.classList.add('ms-Icon--ChevronDown');
chevronIcon.classList.remove('ms-Icon--ChevronUp');

}
else if (window.innerWidth > 992) {
filtersContent.style.display = 'block';
}
}

initialScreenSize = window.innerWidth;
resized = false;
}

window.addEventListener('resize', () => {
resized = true;
toggleAdvancedSearchPanel();
});

function toggleCollapsible() {
var dataTab = document.getElementById(this.getAttribute('tab') + 'tab');
var expandButton = document.getElementById(this.getAttribute('tab') + 'button');
Expand Down

0 comments on commit a3c390c

Please sign in to comment.