Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
KeziahMoselle committed Sep 29, 2018
1 parent 69eb155 commit 01573ed
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function openImageDetails (event) {
// Insert new tags
tags.forEach(tag => {
document.getElementById('TagsParent').insertAdjacentHTML('beforeend', `
<li><a class="waves-effect ${isTagInSearchBar(tag) ? 'sidenav-tags-in-searchbar' : 'sidenav-tags-not-in-searchbar'}" id="ADDCLASSTO_${tag}" onclick="handleSidenavTags('${tag}')">${tag}</a></li>
<li><a class="waves-effect ${isTagInSearchBar(tag) ? 'sidenav-tags-in-searchbar' : 'sidenav-tags-not-in-searchbar'}" id="ADDCLASSTO_${tag}">${tag}</a></li>
`)
})
})
Expand Down Expand Up @@ -402,9 +402,9 @@ document.getElementById('checkboxTheme').addEventListener('click', () => {
}
})

// REFACTOR NEEDED
function handleSidenavTags (tag) {
// Add the tag to the search bar and actualize
// Add tag dynamically via sidenav
document.getElementById('TagsParent').addEventListener('click', (event) => {
let tag = event.target.innerText
if (!isTagInSearchBar(tag)) {
searchBar.value = `${searchBar.value} ${tag}`
document.getElementById(`ADDCLASSTO_${tag}`).classList.add('sidenav-tags-in-searchbar')
Expand All @@ -417,7 +417,7 @@ function handleSidenavTags (tag) {
Refresh()
M.toast({ html: `Removed ${tag}` })
}
}
})

// Handle links
document.addEventListener('click', (event) => {
Expand Down

0 comments on commit 01573ed

Please sign in to comment.