Skip to content

CLDR-7459 make sideways view be by-request #4793

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
35 changes: 26 additions & 9 deletions tools/cldr-apps/js/src/esm/cldrSideways.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import * as cldrLoad from "./cldrLoad.mjs";
import * as cldrStatus from "./cldrStatus.mjs";
import * as cldrSurvey from "./cldrSurvey.mjs";

const SIDEWAYS_DEBUG = false;
const SIDEWAYS_DEBUG = true;
/** If true only load when clicked */
const LOAD_ON_DEMAND = true;

const NON_BREAKING_SPACES = "\u00A0\u00A0\u00A0"; // non-breaking spaces
const UNEQUALS_SIGN = "\u2260\u00A0"; // U+2260 = "≠"
Expand Down Expand Up @@ -70,7 +72,17 @@ function loadMenu(regionalVariantsWrapper, xpstrid) {
}
}

function fetchAndLoadMenu(regionalVariantsWrapper, xpstrid, cacheKey) {
function reallyFetch(regionalVariantsWrapper, xpstrid, cacheKey) {
cldrLoad.myLoad(
getSidewaysUrl(curLocale, xpstrid),
"sidewaysView",
function (json) {
setMenuFromData(regionalVariantsWrapper, json, cacheKey);
}
);
}

function fetchAfterDelay(regionalVariantsWrapper, xpstrid, cacheKey) {
clearMyTimeout();
regionalVariantsWrapper.setLoading();
sidewaysShowTimeoutId = window.setTimeout(function () {
Expand All @@ -86,17 +98,22 @@ function fetchAndLoadMenu(regionalVariantsWrapper, xpstrid, cacheKey) {
}
return;
}
cldrLoad.myLoad(
getSidewaysUrl(curLocale, xpstrid),
"sidewaysView",
function (json) {
setMenuFromData(regionalVariantsWrapper, json, cacheKey);
}
);
reallyFetch(regionalVariantsWrapper, xpstrid, cacheKey);
}, fetchDelayMilliseconds);
fetchDelayMilliseconds = USUAL_DELAY_MILLISECONDS;
}

function fetchAndLoadMenu(regionalVariantsWrapper, xpstrid, cacheKey) {
if (!LOAD_ON_DEMAND) {
fetchAfterDelay(regionalVariantsWrapper, xpstrid, cacheKey);
} else {
regionalVariantsWrapper.setClickToLoad(() => {
regionalVariantsWrapper.setLoading();
reallyFetch(regionalVariantsWrapper, xpstrid, cacheKey);
});
}
}

function clearMyTimeout() {
if (sidewaysShowTimeoutId != -1) {
// https://www.w3schools.com/jsref/met_win_clearinterval.asp
Expand Down
25 changes: 24 additions & 1 deletion tools/cldr-apps/js/src/views/InfoRegionalVariants.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
</option>
</select>
</div>
<div v-else-if="clickToLoad">
<button @click="clickClickToLoad">Check Regional Variants…</button>
</div>
</div>
</template>

Expand All @@ -41,30 +44,50 @@ export default {
label: null,
loading: false,
loadingMessage: null,
clickToLoad: null,
};
},

methods: {
clear() {
this.label = this.items = this.chosenLocale = this.curLocale = null;
this.loading = false;
},

setLoading() {
this.clear();
this.clickToLoad = null;
if (!this.loadingMessage) {
this.loadingMessage = cldrText.get("sideways_loading1");
}
this.loading = true;
this.label = this.items = this.chosenLocale = this.curLocale = null;
},

setData(localeId, d) {
this.clickToLoad = null;
this.chosenLocale = this.curLocale = localeId;
this.label = d?.label || null;
this.items = d?.items || null;
this.loading = false;
},

goToLocale() {
this.clickToLoad = null;
if (this.chosenLocale !== this.curLocale) {
cldrSideways.goToLocale(this.chosenLocale);
}
},

setClickToLoad(fn) {
this.clear();
this.clickToLoad = fn;
},

clickClickToLoad() {
if (this.clickToLoad) {
this.clickToLoad();
}
},
},
};
</script>
Expand Down
Loading