Commit 1dc4cd2ba27811082c9a2338c68b994f28779c80
1 parent
1fb914b9
[+] choose_lang_dropdown()
[~] update choose_lang_dialod() to add the list of excluded language to not to be shown on the list [+] add random number to div id into the language line. This allows to have multiples languages selector in same page
Showing
1 changed file
with
139 additions
and
8 deletions
Show diff stats
web_controllers/language/language_management.anubis
| @@ -170,9 +170,9 @@ define HTML_Off_Form | @@ -170,9 +170,9 @@ define HTML_Off_Form | ||
| 170 | String language, | 170 | String language, |
| 171 | String -> String action | 171 | String -> String action |
| 172 | )= | 172 | )= |
| 173 | - div([class("clickable"), event(onclick, action(language_code))],[ | ||
| 174 | - img("/xlib/flags/24x24/"+language_code+".png"), | ||
| 175 | - text(language) | 173 | + div(id(generate_random_string(15)+"_"+language_code), [ |
| 174 | + img([class("clickable"), event(onclick, action(language_code))],"/xlib/flags/24x24/"+language_code+".png"), | ||
| 175 | + text([class("clickable"), event(onclick, action(language_code))],language) | ||
| 176 | ]) | 176 | ]) |
| 177 | . | 177 | . |
| 178 | 178 | ||
| @@ -228,17 +228,23 @@ public define HTML_Partial_Content | @@ -228,17 +228,23 @@ public define HTML_Partial_Content | ||
| 228 | flags_menu(app_dictionnary, lang, show_symbolic) | 228 | flags_menu(app_dictionnary, lang, show_symbolic) |
| 229 | . | 229 | . |
| 230 | 230 | ||
| 231 | + | ||
| 231 | public define HTML_Partial_Content | 232 | public define HTML_Partial_Content |
| 232 | choose_lang_dialog | 233 | choose_lang_dialog |
| 233 | ( | 234 | ( |
| 234 | - String dictionary_collection_name, | ||
| 235 | - String -> String action, | ||
| 236 | - Bool show_symbolic, | 235 | + String dictionary_collection_name, |
| 236 | + String -> String action, | ||
| 237 | + Bool show_symbolic, | ||
| 238 | + List(String) exclude_lang | ||
| 237 | )= | 239 | )= |
| 238 | with make_line = (L3LangDicProperty dico_prop) |-> | 240 | with make_line = (L3LangDicProperty dico_prop) |-> |
| 239 | if dico_prop is l3LangDicProperty( _, sha1, lang_code, user_def, creat, update) then | 241 | if dico_prop is l3LangDicProperty( _, sha1, lang_code, user_def, creat, update) then |
| 240 | with lang_info = l3_get_language_info(lang_code), | 242 | with lang_info = l3_get_language_info(lang_code), |
| 241 | - language_line(lang_code, self_name(lang_info), action), | 243 | + //if language belong to exclude list, return an empty line |
| 244 | + if lang_code:exclude_lang then | ||
| 245 | + empty | ||
| 246 | + else | ||
| 247 | + language_line(lang_code, self_name(lang_info), action), | ||
| 242 | 248 | ||
| 243 | partial_content([ | 249 | partial_content([ |
| 244 | css(css_file("/xlib/css/flags_menu.css")), | 250 | css(css_file("/xlib/css/flags_menu.css")), |
| @@ -266,10 +272,135 @@ public define HTML_Partial_Content | @@ -266,10 +272,135 @@ public define HTML_Partial_Content | ||
| 266 | choose_lang_dialog | 272 | choose_lang_dialog |
| 267 | ( | 273 | ( |
| 268 | WEB_Session _session, | 274 | WEB_Session _session, |
| 275 | + String -> String action, | ||
| 276 | + Bool show_symbolic | ||
| 277 | + ) = | ||
| 278 | + with lang = _session.language, | ||
| 279 | + app_dictionnary = get_dictionary(_session), | ||
| 280 | + | ||
| 281 | + choose_lang_dialog(app_dictionnary, action, show_symbolic, []) | ||
| 282 | +. | ||
| 283 | + | ||
| 284 | +public define HTML_Partial_Content | ||
| 285 | + choose_lang_dialog | ||
| 286 | + ( | ||
| 287 | + WEB_Session _session, | ||
| 288 | + String -> String action, | ||
| 289 | + List(String) exclude_lang | ||
| 290 | + ) = | ||
| 291 | + with lang = _session.language, | ||
| 292 | + app_dictionnary = get_dictionary(_session), | ||
| 293 | + | ||
| 294 | + choose_lang_dialog(app_dictionnary, action, false, exclude_lang) | ||
| 295 | +. | ||
| 296 | + | ||
| 297 | +public define HTML_Partial_Content | ||
| 298 | + choose_lang_dialog | ||
| 299 | + ( | ||
| 300 | + WEB_Session _session, | ||
| 269 | String -> String action | 301 | String -> String action |
| 270 | ) = | 302 | ) = |
| 271 | with lang = _session.language, | 303 | with lang = _session.language, |
| 272 | app_dictionnary = get_dictionary(_session), | 304 | app_dictionnary = get_dictionary(_session), |
| 273 | 305 | ||
| 274 | - choose_lang_dialog(app_dictionnary, action, false) | 306 | + choose_lang_dialog(app_dictionnary, action, false, []) |
| 307 | +. | ||
| 308 | + | ||
| 309 | + /* DROPDOWN part */ | ||
| 310 | + | ||
| 311 | +define HTML_Off_Form | ||
| 312 | + dd_language_line | ||
| 313 | + ( | ||
| 314 | + String language_code, | ||
| 315 | + String language, | ||
| 316 | + String -> String action | ||
| 317 | + )= | ||
| 318 | + li(event(onclick, action(language_code)), [ | ||
| 319 | + img("/xlib/flags/24x24/"+language_code+".png"), | ||
| 320 | + text(language) | ||
| 321 | + ]) | ||
| 322 | +. | ||
| 323 | + | ||
| 324 | +public define HTML_Partial_Content | ||
| 325 | + choose_lang_dropdown | ||
| 326 | + ( | ||
| 327 | + String dictionary_collection_name, | ||
| 328 | + String -> String action, | ||
| 329 | + String image, //Web element on which is sticked the dropdown | ||
| 330 | + Bool on_click, | ||
| 331 | + Bool show_symbolic, | ||
| 332 | + List(String) exclude_lang | ||
| 333 | + )= | ||
| 334 | + with rand_id = generate_random_string(15)+"_flag", | ||
| 335 | + with make_line = (L3LangDicProperty dico_prop) |-> | ||
| 336 | + if dico_prop is l3LangDicProperty( _, sha1, lang_code, user_def, creat, update) then | ||
| 337 | + with lang_info = l3_get_language_info(lang_code), | ||
| 338 | + //if language belong to exclude list, return an empty line | ||
| 339 | + if lang_code:exclude_lang then | ||
| 340 | + empty | ||
| 341 | + else | ||
| 342 | + dd_language_line(lang_code, self_name(lang_info), action), | ||
| 343 | + | ||
| 344 | + partial_content([ | ||
| 345 | + css(css_file("/xlib/css/flags_menu.css")), | ||
| 346 | + js(js_file("/xlib/js/xlib.js")) | ||
| 347 | + ], | ||
| 348 | + [ | ||
| 349 | + img([class("icon_in_text clickable"), event(if on_click then onclick else onmouseover, "showObject('"+rand_id+"');"), event(onmouseout, "hideObject('"+rand_id+"');")], image ), | ||
| 350 | + ul([id(rand_id), class("drop-flag-body"), event(onmouseover, "showObject('"+rand_id+"');"), event(onmouseout, "hideObject('"+rand_id+"');"), style("display: none"), ], | ||
| 351 | + map(make_line, l3_get_all_dicos(dictionary_collection_name))+ | ||
| 352 | + [ | ||
| 353 | + if show_symbolic then | ||
| 354 | + dd_language_line("symb", "symbolic", action) | ||
| 355 | + else | ||
| 356 | + empty | ||
| 357 | + ] | ||
| 358 | + ) | ||
| 359 | + ] | ||
| 360 | + ) | ||
| 361 | +. | ||
| 362 | + | ||
| 363 | +public define HTML_Partial_Content | ||
| 364 | + choose_lang_dropdown | ||
| 365 | + ( | ||
| 366 | + WEB_Session _session, | ||
| 367 | + String -> String action, | ||
| 368 | + String image, //Web element on which is sticked the dropdown | ||
| 369 | + Bool on_click, | ||
| 370 | + Bool show_symbolic | ||
| 371 | + ) = | ||
| 372 | + with lang = _session.language, | ||
| 373 | + app_dictionnary = get_dictionary(_session), | ||
| 374 | + | ||
| 375 | + choose_lang_dropdown(app_dictionnary, action, image, on_click, show_symbolic, []) | ||
| 376 | +. | ||
| 377 | + | ||
| 378 | +public define HTML_Partial_Content | ||
| 379 | + choose_lang_dropdown | ||
| 380 | + ( | ||
| 381 | + WEB_Session _session, | ||
| 382 | + String -> String action, | ||
| 383 | + String image, //Web element on which is sticked the dropdown | ||
| 384 | + Bool on_click, | ||
| 385 | + List(String) exclude_lang | ||
| 386 | + ) = | ||
| 387 | + with lang = _session.language, | ||
| 388 | + app_dictionnary = get_dictionary(_session), | ||
| 389 | + | ||
| 390 | + choose_lang_dropdown(app_dictionnary, action, image, on_click, false, exclude_lang) | ||
| 391 | +. | ||
| 392 | + | ||
| 393 | +public define HTML_Partial_Content | ||
| 394 | + choose_lang_dropdown | ||
| 395 | + ( | ||
| 396 | + WEB_Session _session, // | ||
| 397 | + String -> String action, //web action function to call when language is choosen | ||
| 398 | + String image, //Web element on which is sticked the dropdown | ||
| 399 | + Bool on_click //true if the dropdown shown on click event else it's on mouseover | ||
| 400 | + | ||
| 401 | + ) = | ||
| 402 | + with lang = _session.language, | ||
| 403 | + app_dictionnary = get_dictionary(_session), | ||
| 404 | + | ||
| 405 | + choose_lang_dropdown(app_dictionnary, action, image, on_click, false, []) | ||
| 275 | . | 406 | . |