Skip to content

Commit 9cad807

Browse files
committed
More timing issues with the language menu... make sure the menu gets the initial languages, even if CreateLanguageMenu is called too soon.
1 parent 531d5ee commit 9cad807

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

unpacked/extensions/MathMenu.js

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,34 @@
962962

963963
/*************************************************************/
964964

965+
//
966+
// Creates the locale menu from the list of locales in MathJax.Localization.strings
967+
//
968+
MENU.CreateLocaleMenu = function () {
969+
if (!MENU.menu) return;
970+
var menu = MENU.menu.Find("Language").menu, items = menu.items;
971+
//
972+
// Get the names of the languages and sort them
973+
//
974+
var locales = [], LOCALE = MathJax.Localization.strings;
975+
for (var id in LOCALE) {if (LOCALE.hasOwnProperty(id)) {locales.push(id)}}
976+
locales = locales.sort(); menu.items = [];
977+
//
978+
// Add a menu item for each
979+
//
980+
for (var i = 0, m = locales.length; i < m; i++) {
981+
var title = LOCALE[locales[i]].menuTitle;
982+
if (title) {title += " ("+locales[i]+")"} else {title = locales[i]}
983+
menu.items.push(ITEM.RADIO([locales[i],title],"locale",{action:MENU.Locale}));
984+
}
985+
//
986+
// Add the rule and "Load from URL" items
987+
//
988+
menu.items.push(items[items.length-2],items[items.length-1]);
989+
};
990+
991+
/*************************************************************/
992+
965993
HUB.Register.StartupHook("End Config",function () {
966994

967995
/*
@@ -1065,35 +1093,9 @@
10651093
})();
10661094
}
10671095

1096+
MENU.CreateLocaleMenu();
10681097
});
10691098

1070-
//
1071-
// Creates the locale menu from the list of locales in MathJax.Localization.strings
1072-
//
1073-
MENU.CreateLocaleMenu = function () {
1074-
if (!MENU.menu) return;
1075-
var menu = MENU.menu.Find("Language").menu, items = menu.items;
1076-
//
1077-
// Get the names of the languages and sort them
1078-
//
1079-
var locales = [], LOCALE = MathJax.Localization.strings;
1080-
for (var id in LOCALE) {if (LOCALE.hasOwnProperty(id)) {locales.push(id)}}
1081-
locales = locales.sort(); menu.items = [];
1082-
//
1083-
// Add a menu item for each
1084-
//
1085-
for (var i = 0, m = locales.length; i < m; i++) {
1086-
var title = LOCALE[locales[i]].menuTitle;
1087-
if (title) {title += " ("+locales[i]+")"} else {title = locales[i]}
1088-
menu.items.push(ITEM.RADIO([locales[i],title],"locale",{action:MENU.Locale}));
1089-
}
1090-
//
1091-
// Add the rule and "Load from URL" items
1092-
//
1093-
menu.items.push(items[items.length-2],items[items.length-1]);
1094-
};
1095-
MENU.CreateLocaleMenu();
1096-
10971099
MENU.showRenderer = function (show) {
10981100
MENU.cookie.showRenderer = CONFIG.showRenderer = show; MENU.saveCookie();
10991101
MENU.menu.Find("Math Settings","Math Renderer").hidden = !show;

0 commit comments

Comments
 (0)