Fix lists not changing color when another one is selected

This commit is contained in:
Paul van Tilburg 2017-12-27 20:28:34 +01:00
parent 8f55d55388
commit bc12c285a0
1 changed files with 10 additions and 5 deletions

View File

@ -1,5 +1,9 @@
var curList;
var bgColors = ["info", "primary", "danger", "success", "warning", "secondary"];
var borderColors = ["info", "primary", "danger", "success", "warning", "secondary"];
var textColors = ["light", "light", "light", "light", "dark", "dark" ];
function getUrlListId() {
var hash = window.location.hash;
if (hash.length == 0) {
@ -34,6 +38,9 @@ function triggerSelect(listId) {
console.debug('Switch selection to list ' + listId);
if (curList) {
$('.nav-link[data-list-id="' + curList.id + '"]').removeClass('active');
$('#listHtml').removeClass("border-" + borderColors[curList.index])
.removeClass("bg-" + bgColors[curList.index])
.removeClass("text-" + textColors[curList.index])
}
$('.nav-link[data-list-id="' + listId + '"]').addClass('active');
disableEditMode();
@ -48,12 +55,10 @@ function triggerSelect(listId) {
}).done(function(list) {
curList = list;
$('#listName').text('Lijst van ' + list.name)
$('#listHtml').addClass("border-" + borderColors[list.index])
.addClass("bg-" + bgColors[list.index])
.addClass("text-" + textColors[list.index]);
$('#listData').html(list.data);
var bg_color = ["info", "primary", "danger", "success", "warning", "secondary"][list.index];
var text_color = ["light", "light", "light", "light", "dark", "dark" ][list.index];
$('#listHtml').addClass("border-" + bg_color)
.addClass("bg-" + bg_color)
.addClass("text-" + text_color);
$('#listUpdatedAt').text('Laaste aanpassing op: FIXME');
$('#editButton').show();
});