Commit 9f86aeea14e02b88d85c6d2183fcdab02a42d864
Committed by
hitier
1 parent
a30b11ff
Exists in
master
and in
4 other branches
Change navbar activation menu
Activated menu is done with ul opening and li color Activation used to be triggered on menu item click. It is now triggered on page load thank to a specific span syntax.
Showing
9 changed files
with
41 additions
and
37 deletions
Show diff stats
app/main/templates/agent.html
@@ -5,6 +5,10 @@ | @@ -5,6 +5,10 @@ | ||
5 | {% endblock %} | 5 | {% endblock %} |
6 | 6 | ||
7 | {% block content %} | 7 | {% block content %} |
8 | + | ||
9 | +<!-- Invisible span to definte wich ul and a in the navbar are actived --> | ||
10 | +<span id="nav_actived" style="display: none">agent,agents</span> | ||
11 | + | ||
8 | <div id="projects_chart" class="charge_chart"></div> | 12 | <div id="projects_chart" class="charge_chart"></div> |
9 | <table id="charge_table"> | 13 | <table id="charge_table"> |
10 | <thead> | 14 | <thead> |
app/main/templates/agents.html
1 | {% extends "base_page.html" %} | 1 | {% extends "base_page.html" %} |
2 | {% block content %} | 2 | {% block content %} |
3 | + | ||
4 | +<!-- Invisible span to definte wich ul and a in the navbar are actived --> | ||
5 | +<span id="nav_actived" style="display: none">agent,agents</span> | ||
6 | + | ||
3 | <table class="table table-hover"> | 7 | <table class="table table-hover"> |
4 | <thead> | 8 | <thead> |
5 | <tr> | 9 | <tr> |
app/main/templates/capacities.html
1 | {% extends "base_page.html" %} | 1 | {% extends "base_page.html" %} |
2 | {% block content %} | 2 | {% block content %} |
3 | + | ||
4 | +<!-- Invisible span to definte wich ul and a in the navbar are actived --> | ||
5 | +<span id="nav_actived" style="display: none">agent,capacities</span> | ||
6 | + | ||
3 | <table class="table table-hover"> | 7 | <table class="table table-hover"> |
4 | <thead> | 8 | <thead> |
5 | <tr> | 9 | <tr> |
app/main/templates/charge.html
1 | {% extends "base_page.html" %} | 1 | {% extends "base_page.html" %} |
2 | {% block content %} | 2 | {% block content %} |
3 | + | ||
4 | +<!-- Invisible span to definte wich ul and a in the navbar are actived --> | ||
5 | +<span id="nav_actived" style="display: none">cds,charge/add</span> | ||
6 | + | ||
3 | <form class="form-horizontal" id="new_affectation" action="#" method="post"> | 7 | <form class="form-horizontal" id="new_affectation" action="#" method="post"> |
4 | <input name="utf8" type="hidden" value="✓"> | 8 | <input name="utf8" type="hidden" value="✓"> |
5 | <input type="hidden" name="authenticity_token" value="NPVU9shCwiRt07EXMAroxTdsP61Et00VQjkBiit3MWeqQt3Eez9UdGK68RzZ6npLCFyg0gL+M1MR6VjK9WOCYw=="> | 9 | <input type="hidden" name="authenticity_token" value="NPVU9shCwiRt07EXMAroxTdsP61Et00VQjkBiit3MWeqQt3Eez9UdGK68RzZ6npLCFyg0gL+M1MR6VjK9WOCYw=="> |
app/main/templates/periods.html
1 | {% extends "base_page.html" %} | 1 | {% extends "base_page.html" %} |
2 | {% block content %} | 2 | {% block content %} |
3 | + | ||
4 | +<!-- Invisible span to definte wich ul and a in the navbar are actived --> | ||
5 | +<span id="nav_actived" style="display: none">admin,periods</span> | ||
6 | + | ||
3 | <table class="table table-hover"> | 7 | <table class="table table-hover"> |
4 | <thead> | 8 | <thead> |
5 | <tr> | 9 | <tr> |
app/main/templates/project.html
@@ -5,6 +5,9 @@ | @@ -5,6 +5,9 @@ | ||
5 | {% endblock %} | 5 | {% endblock %} |
6 | 6 | ||
7 | {% block content %} | 7 | {% block content %} |
8 | +<!-- Invisible span to definte wich ul and a in the navbar are actived --> | ||
9 | +<span id="nav_actived" style="display: none">projet,projects</span> | ||
10 | + | ||
8 | <div class="charge_chart" id="project_services_chart"></div> | 11 | <div class="charge_chart" id="project_services_chart"></div> |
9 | <hr/> | 12 | <hr/> |
10 | <div class="charge_chart" id="project_capacities_chart"></div> | 13 | <div class="charge_chart" id="project_capacities_chart"></div> |
app/main/templates/projects.html
1 | {% extends "base_page.html" %} | 1 | {% extends "base_page.html" %} |
2 | {% block content %} | 2 | {% block content %} |
3 | + | ||
4 | +<!-- Invisible span to definte wich ul and a in the navbar are actived --> | ||
5 | +<span id="nav_actived" style="display: none">projet,projects</span> | ||
6 | + | ||
3 | <table class="table table-hover"> | 7 | <table class="table table-hover"> |
4 | <thead> | 8 | <thead> |
5 | <tr> | 9 | <tr> |
app/main/templates/services.html
1 | {% extends "base_page.html" %} | 1 | {% extends "base_page.html" %} |
2 | {% block content %} | 2 | {% block content %} |
3 | + | ||
4 | +<!-- Invisible span to definte wich ul and a in the navbar are actived --> | ||
5 | +<span id="nav_actived" style="display: none">service,services</span> | ||
6 | + | ||
3 | <table class="table table-hover"> | 7 | <table class="table table-hover"> |
4 | <thead> | 8 | <thead> |
5 | <tr> | 9 | <tr> |
app/static/js/navbar.js
1 | -// Script used with the navbar to color the menu items and leave them visible | 1 | +/* Read the <span> with information about ul and li to active */ |
2 | +const navbar_active = $("#nav_actived").html(); | ||
3 | +const navbar_active_split = navbar_active.split(','); | ||
2 | 4 | ||
5 | +const ul_active = navbar_active_split[0]; | ||
6 | +const a_active = navbar_active_split[1]; | ||
3 | 7 | ||
4 | -// Check if an element of the navbar is stored in the local storage or not | ||
5 | -var collapseItem_ul = localStorage.getItem('collapseItem_ul'); | ||
6 | -var collapseItem_a = localStorage.getItem('collapseItem_a'); | ||
7 | - | ||
8 | -// | ||
9 | -var sublink_activate = $("a[href='" + collapseItem_a + "']"); | ||
10 | -sublink_activate.addClass("sublink_activate"); | ||
11 | - | ||
12 | -$("#" + collapseItem_ul).addClass("show"); | ||
13 | - | ||
14 | - | ||
15 | -//store the id of the collapsible element | ||
16 | -$('.main-nav').click(function () { | ||
17 | - localStorage.setItem('collapseItem_ul', $(this).next().attr("id")); | ||
18 | -}); | ||
19 | -$('.sub_link').click(function (e) { | ||
20 | - localStorage.setItem('collapseItem_a', $(this).attr("href")); | ||
21 | -}) | ||
22 | - | ||
23 | - | ||
24 | -// a click to the connection bar or 'accueil' button desactivate the localstorage | ||
25 | -$('.link_connect').click(function() { | ||
26 | - $("#" + collapseItem_ul).removeClass("show"); | ||
27 | - $("#" + collapseItem_ul).addClass("hide"); | ||
28 | - sublink_activate.removeClass("sublink_activate"); | ||
29 | - localStorage.removeItem('collapseItem_ul'); | ||
30 | - localStorage.removeItem('collapseItem_a'); | ||
31 | - | ||
32 | -}); | ||
33 | -$("#accueil").click(function (){ | ||
34 | - $("#" + collapseItem_ul).removeClass("show"); | ||
35 | - $("#" + collapseItem_ul).addClass("hide"); | ||
36 | - sublink_activate.removeClass("sublink_activate"); | ||
37 | - localStorage.removeItem('collapseItem_ul'); | ||
38 | - localStorage.removeItem('collapseItem_a'); | ||
39 | -}); | 8 | +/* Open the ul */ |
9 | +$("#" + ul_active).addClass("show"); | ||
40 | 10 | ||
11 | +/* Active the li */ | ||
12 | +var sublink_activate = $("a[href='/" + a_active + "']"); | ||
13 | +sublink_activate.addClass("sublink_activate"); | ||
41 | \ No newline at end of file | 14 | \ No newline at end of file |