2021-01-30 17:30:28 +08:00
|
|
|
function ccn_headerNav_Insert() {
|
2021-01-24 14:38:08 +08:00
|
|
|
$('body').prepend(ccn_template_headerNav.render());
|
2021-01-16 22:15:10 +08:00
|
|
|
}
|
|
|
|
|
|
2021-01-30 17:30:28 +08:00
|
|
|
function ccn_headerNav_LoggedRefresh() {
|
|
|
|
|
if (ccn_api_common_tokenValid()) {
|
2021-01-19 22:20:11 +08:00
|
|
|
// logged, show all nav button and logout button
|
2021-01-30 17:30:28 +08:00
|
|
|
$("#ccn-header-nav-home").show();
|
|
|
|
|
$("#ccn-header-nav-calendar").show();
|
|
|
|
|
$("#ccn-header-nav-todo").show();
|
|
|
|
|
$("#ccn-header-nav-admin").show();
|
2021-01-19 22:20:11 +08:00
|
|
|
|
2021-01-30 17:30:28 +08:00
|
|
|
$("#ccn-header-user-login").hide();
|
|
|
|
|
$("#ccn-header-user-logout").show();
|
2021-01-19 22:20:11 +08:00
|
|
|
} else {
|
2021-01-30 17:30:28 +08:00
|
|
|
$("#ccn-header-nav-home").show();
|
|
|
|
|
$("#ccn-header-nav-calendar").hide();
|
|
|
|
|
$("#ccn-header-nav-todo").hide();
|
|
|
|
|
$("#ccn-header-nav-admin").hide();
|
2021-01-19 22:20:11 +08:00
|
|
|
|
2021-01-30 17:30:28 +08:00
|
|
|
$("#ccn-header-user-login").show();
|
|
|
|
|
$("#ccn-header-user-logout").hide();
|
2021-01-19 22:20:11 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// bind language process and internal process function such as logout and expand menu
|
2021-01-30 17:30:28 +08:00
|
|
|
function ccn_headerNav_BindEvents() {
|
2021-01-19 22:20:11 +08:00
|
|
|
// bind function
|
2021-01-30 17:30:28 +08:00
|
|
|
$("#ccn-header-language > *").each(function(){
|
2021-01-19 22:20:11 +08:00
|
|
|
$(this).click(function(){
|
|
|
|
|
ccn_i18n_ChangeLanguage($(this).attr("language"));
|
|
|
|
|
ccn_i18n_ApplyLanguage();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2021-01-20 22:57:41 +08:00
|
|
|
// bind logout
|
2021-01-30 17:30:28 +08:00
|
|
|
$("#ccn-header-user-logout").click(function() {
|
|
|
|
|
if (ccn_api_common_logout()) {
|
2021-01-20 22:57:41 +08:00
|
|
|
// ok, logout
|
|
|
|
|
// jump into home page again
|
|
|
|
|
window.location.href = '/web/home';
|
|
|
|
|
return;
|
|
|
|
|
|
2021-01-30 17:30:28 +08:00
|
|
|
} else ccn_messagebox_Show($.i18n.prop("ccn-js-fail-logout"));
|
2021-01-20 22:57:41 +08:00
|
|
|
});
|
2021-01-19 22:20:11 +08:00
|
|
|
|
|
|
|
|
// bind burger menu
|
|
|
|
|
// copy from bulma website
|
|
|
|
|
// Check for click events on the navbar burger icon
|
|
|
|
|
$(".navbar-burger").click(function() {
|
|
|
|
|
|
2021-01-24 14:38:08 +08:00
|
|
|
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
|
|
|
|
|
$(".navbar-burger").toggleClass("is-active");
|
|
|
|
|
$(".navbar-menu").toggleClass("is-active");
|
2021-01-19 22:20:11 +08:00
|
|
|
|
2021-01-24 14:38:08 +08:00
|
|
|
});
|
2021-01-19 22:20:11 +08:00
|
|
|
}
|
|
|
|
|
|