|
|
|
@ -86,10 +86,11 @@ document.getElementById("user-menu").addEventListener('click', (ev) => {
|
|
|
|
|
drop.classList.remove("_drop")
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
function create_selection_tag(tagname) { // CLEAR
|
|
|
|
|
function create_selection_tag(tagname, tagcat) { // CLEAR
|
|
|
|
|
let tag = document.createElement("a")
|
|
|
|
|
tag.classList.add("tagselected")
|
|
|
|
|
tag.dataset.tagname = tagname
|
|
|
|
|
tag.dataset.tagcat = tagcat
|
|
|
|
|
|
|
|
|
|
tag.insertAdjacentHTML("beforeend", `
|
|
|
|
|
<span class="tag-icon">
|
|
|
|
@ -106,10 +107,11 @@ function create_selection_tag(tagname) { // CLEAR
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Suggestions
|
|
|
|
|
function create_suggestion_tag(tagname) { // CLEAR
|
|
|
|
|
function create_suggestion_tag(tagname, tagcat) { // CLEAR
|
|
|
|
|
let tag = document.createElement("a")
|
|
|
|
|
tag.classList.add("tagsuggestion")
|
|
|
|
|
tag.dataset.tagname = tagname
|
|
|
|
|
tag.dataset.tagcat = tagcat
|
|
|
|
|
|
|
|
|
|
tag.insertAdjacentHTML("beforeend", `
|
|
|
|
|
<span class="tag-icon">
|
|
|
|
@ -162,7 +164,7 @@ taginputs.forEach(function (tinput) {
|
|
|
|
|
hid_input.value = val.join(' ').trim()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function add_selected(tagname) { // 2 references
|
|
|
|
|
function add_selected(tagname, tagcat) { // 2 references
|
|
|
|
|
let predf = predef
|
|
|
|
|
let sel = selected
|
|
|
|
|
|
|
|
|
@ -173,7 +175,7 @@ taginputs.forEach(function (tinput) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let newtag = create_selection_tag(tagname)
|
|
|
|
|
let newtag = create_selection_tag(tagname, tagcat)
|
|
|
|
|
newtag.addEventListener('click', (event) => {
|
|
|
|
|
remove_selected(event.target.dataset.tagname)
|
|
|
|
|
event.preventDefault()
|
|
|
|
@ -204,7 +206,7 @@ taginputs.forEach(function (tinput) {
|
|
|
|
|
if (predef) {
|
|
|
|
|
predef.querySelectorAll("a").forEach(element => {
|
|
|
|
|
element.addEventListener('click', (event) => {
|
|
|
|
|
add_selected(event.target.dataset.tagname)
|
|
|
|
|
add_selected(event.target.dataset.tagname, event.target.dataset.tagcat)
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
|
|
setTimeout(() => suggest_input.focus(), 2)
|
|
|
|
@ -238,7 +240,7 @@ taginputs.forEach(function (tinput) {
|
|
|
|
|
suggest_input.removeAttribute('value') // Disable prefill by browser
|
|
|
|
|
|
|
|
|
|
function select_suggestion(tagelement) {
|
|
|
|
|
add_selected(tagelement.dataset.tagname)
|
|
|
|
|
add_selected(tagelement.dataset.tagname, tagelement.dataset.tagcat)
|
|
|
|
|
suggest_input.value = ''
|
|
|
|
|
render_suggestions([])
|
|
|
|
|
|
|
|
|
@ -259,7 +261,7 @@ taginputs.forEach(function (tinput) {
|
|
|
|
|
if (i > 5) return
|
|
|
|
|
if (tagnames.includes(el.content)) return
|
|
|
|
|
|
|
|
|
|
let sugtag = create_suggestion_tag(el.content)
|
|
|
|
|
let sugtag = create_suggestion_tag(el.content, el.category.name)
|
|
|
|
|
|
|
|
|
|
sugtag.addEventListener('click', (event) => {
|
|
|
|
|
select_suggestion(event.target)
|
|
|
|
|