Skip to content

Commit

Permalink
Make sure i18nManager has been initialized before compiling templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
krausvo1 committed Mar 1, 2024
1 parent dda55c1 commit 2ce2bf0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
33 changes: 18 additions & 15 deletions openam-ui/openam-ui-ria/src/main/js/main-authorize.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ require([
KEY_CODE_SPACE = 32,
dataReady = $.Deferred();

i18nManager.init({
const i18nReady = i18nManager.init({
paramLang: {
locale: data.locale || Constants.DEFAULT_LANGUAGE
},
Expand Down Expand Up @@ -133,21 +133,24 @@ require([
require(templatePaths, function (AuthorizeTemplate, LoginBaseTemplate, FooterTemplate,
LoginHeaderTemplate) {
data.theme = theme;
baseTemplate = HandleBars.compile(LoginBaseTemplate);
formTemplate = HandleBars.compile(AuthorizeTemplate);
footerTemplate = HandleBars.compile(FooterTemplate);
loginHeaderTemplate = HandleBars.compile(LoginHeaderTemplate);

$("#wrapper").html(baseTemplate(data));
$("#footer").html(footerTemplate(data));
$("#loginBaseLogo").html(loginHeaderTemplate(data));
$("#content").html(formTemplate(data)).find(".panel-heading").bind("click keyup", function (e) {
// keyup is required so that the collapsed panel can be opened with the keyboard alone,
// and without relying on a mouse click event.
if (e.type === "keyup" && e.keyCode !== KEY_CODE_ENTER && e.keyCode !== KEY_CODE_SPACE) {
return;
}
$(this).toggleClass("expanded").next(".panel-collapse").slideToggle();
i18nReady.then(() => {
baseTemplate = HandleBars.compile(LoginBaseTemplate);
formTemplate = HandleBars.compile(AuthorizeTemplate);
footerTemplate = HandleBars.compile(FooterTemplate);
loginHeaderTemplate = HandleBars.compile(LoginHeaderTemplate);

$("#wrapper").html(baseTemplate(data));
$("#footer").html(footerTemplate(data));
$("#loginBaseLogo").html(loginHeaderTemplate(data));
$("#content").html(formTemplate(data)).find(".panel-heading").bind("click keyup", function (e) {
// keyup is required so that the collapsed panel can be opened with the keyboard alone,
// and without relying on a mouse click event.
if (e.type === "keyup" && e.keyCode !== KEY_CODE_ENTER && e.keyCode !== KEY_CODE_SPACE) {
return;
}
$(this).toggleClass("expanded").next(".panel-collapse").slideToggle();
});
});
});
});
Expand Down
12 changes: 7 additions & 5 deletions openam-ui/openam-ui-ria/src/main/js/main-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ require([
var data = window.pageData,
template = data.done ? DeviceDoneTemplate : DeviceTemplate;

i18nManager.init({
const i18nReady = i18nManager.init({
paramLang: {
locale: data.locale
},
Expand All @@ -75,9 +75,11 @@ require([
ThemeManager.getTheme().always(function (theme) {
data.theme = theme;

$("#wrapper").html(HandleBars.compile(LoginBaseTemplate)(data));
$("#footer").html(HandleBars.compile(FooterTemplate)(data));
$("#loginBaseLogo").html(HandleBars.compile(LoginHeaderTemplate)(data));
$("#content").html(HandleBars.compile(template)(data));
i18nReady.then(() => {
$("#wrapper").html(HandleBars.compile(LoginBaseTemplate)(data));
$("#footer").html(HandleBars.compile(FooterTemplate)(data));
$("#loginBaseLogo").html(HandleBars.compile(LoginHeaderTemplate)(data));
$("#content").html(HandleBars.compile(template)(data));
});
});
});

0 comments on commit 2ce2bf0

Please sign in to comment.