fix coloring ux on sidelink clicking

This commit is contained in:
Andrew Brown 2020-02-19 16:13:15 -06:00
parent dd2f03c285
commit 24dee7c97b
2 changed files with 8 additions and 6 deletions

View File

@ -2,10 +2,12 @@ $(document).ready(function () {
$('.panel').hide();
$('.panel').first().show();
$('.tab a').click(function (tab) {
$('.tab').click(function (clicked_element) {
var tab = $(clicked_element.target).closest('.tab a');
// We substring(1) here to strip the # off the beginning so we can use getElementById
// (because we want to support slashes in category/field names, and jQuery does not).
var target_panel_id = ($(tab.target).attr('href') || '#').substring(1);
var target_panel_id = ($(tab).attr('href') || '#').substring(1);
var target_panel = $(document.getElementById(target_panel_id));
$('.panel').hide();
@ -18,8 +20,8 @@ $(document).ready(function () {
window.scrollTo(0, 0);
}, 1);
$(tab.target).closest('.content-tabs').find('.tab a').removeClass('red-text');
$(tab.target).addClass('red-text');
$('.content-tabs').find('.tab a.red-text').removeClass('red-text');
$(tab).addClass('red-text');
});
$('.modal').modal();

View File

@ -42,11 +42,11 @@
end
%>
<li class="collection-item tab">
<a href="#<%= category[:name].gsub("'", '') %>_panel" class="<%= 'red-text' if category[:label] == 'Overview' %>">
<a href="#<%= category[:name].gsub("'", '') %>_panel" class="<%= 'red-text' if category[:label] == 'Overview' %> tab-label">
<i class="material-icons left"><%= category[:icon] %></i>
<%= category[:label].capitalize.presence || '(blank)' %>
<% if editing && category[:percent_complete].present? %>
<span class="badge">
<span class="badge grey-text">
<% if category[:percent_complete] == 100 %>
<i class="material-icons green-text">check</i>
<% else %>