Skip to content

Commit

Permalink
CLDR-16844 Remember whether the user wants the Info Panel
Browse files Browse the repository at this point in the history
-New boolean panelWanted records user preference

-New boolean parameter for closePanel distinguishes manually clicking close box from automatically closing when switching to special view where panel does not belong

-Revise panelShouldBeShown to check panelWanted and getCurrentSpecial
  • Loading branch information
btangmu committed Jul 12, 2024
1 parent eadd482 commit bde302a
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions tools/cldr-apps/js/src/esm/cldrInfo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,21 @@ let neighborId = null;
let buttonClass = null;

let panelInitialized = false;

/**
* Is the Info Panel currently displayed?
*/
let panelVisible = false;

/**
* Does the user want the Info Panel to be displayed when appropriate?
* The panel is hidden automatically when there is a "special" view for which
* the panel is inappropriate. When returning to the non-special vetting view,
* the panel should be displayed again, unless the user has indicated, by clicking
* its close box, that they don't want to see it.
*/
let panelWanted = true;

let unShow = null;

let selectedItemWrapper = null;
Expand Down Expand Up @@ -113,16 +126,26 @@ function appendDiv(el, id) {
el.appendChild(div);
}

/**
* Open the Info Panel
*/
function openPanel() {
if (!panelVisible) {
panelVisible = true;
panelVisible = panelWanted = true;
openOrClosePanel();
}
}

function closePanel() {
/**
* Close the Info Panel
*
* @param {Boolean} userWantsHidden true if closing because user clicked close box (or equivalent),
* false if closing because switching to a "special" view where the Info Panel doesn't belong
*/
function closePanel(userWantsHidden) {
if (panelVisible) {
panelVisible = false;
panelWanted = !userWantsHidden;
openOrClosePanel();
}
}
Expand Down Expand Up @@ -192,7 +215,7 @@ function panelShouldBeShown() {
// Leave panelVisible = false until openPanel makes it true.
return true;
}
return panelVisible;
return panelWanted && !cldrStatus.getCurrentSpecial();
}

/**
Expand Down

0 comments on commit bde302a

Please sign in to comment.