diff --git a/yadc/assets/js/taginput.js b/yadc/assets/js/taginput.js index 601ffdd..36f0579 100644 --- a/yadc/assets/js/taginput.js +++ b/yadc/assets/js/taginput.js @@ -88,7 +88,7 @@ taginputs.forEach(function (tinput) { let newtag = create_selection_tag(tagname) newtag.addEventListener('click', (event) => { remove_selected(event.target.dataset.tagname) - // console.log(`Deselected: ${event.target.dataset.tagname}`) + event.preventDefault() setTimeout(() => suggest_input.focus(), 2) }) @@ -131,12 +131,22 @@ taginputs.forEach(function (tinput) { // add_selected(tag) // }) // } - let vals = suggest_input.value.split(' ') - // console.log(vals) - vals.forEach(tag => { - if (tag == '') return - add_selected(tag) - }); + // let vals = suggest_input.value.split(' ') + // // console.log(vals) + // vals.forEach(tag => { + // if (tag == '') return + // add_selected(tag) + // }); + // Not as clean, but well whatever + selected.querySelectorAll("a").forEach(element => { + element.addEventListener('click', (event) => { + remove_selected(event.target.dataset.tagname) + event.preventDefault() + + setTimeout(() => suggest_input.focus(), 2) + }) + hidden_addtag(element.dataset.tagname) + }) suggest_input.removeAttribute('value') // Disable prefill by browser function select_suggestion(tagelement) { diff --git a/yadc/bp/post.py b/yadc/bp/post.py index e6da54a..9607c50 100644 --- a/yadc/bp/post.py +++ b/yadc/bp/post.py @@ -53,8 +53,12 @@ def posts(page): posts = posts_query.paginate(page, current_app.config.get('POSTS_PER_PAGE')) tags = tags_prepare(posts.items) - - return render_template('post/index.html', posts=posts, tags=tags) + return render_template( + 'post/index.html', + posts=posts, + tags=tags, + sel_tags=[tag for tag in tags if tag.content in f_tags] + ) @bp.route('/show/') def post_show(id): diff --git a/yadc/static/all.js b/yadc/static/all.js index 960e118..4589a32 100644 --- a/yadc/static/all.js +++ b/yadc/static/all.js @@ -176,7 +176,7 @@ taginputs.forEach(function (tinput) { let newtag = create_selection_tag(tagname) newtag.addEventListener('click', (event) => { remove_selected(event.target.dataset.tagname) - // console.log(`Deselected: ${event.target.dataset.tagname}`) + event.preventDefault() setTimeout(() => suggest_input.focus(), 2) }) @@ -219,12 +219,22 @@ taginputs.forEach(function (tinput) { // add_selected(tag) // }) // } - let vals = suggest_input.value.split(' ') - // console.log(vals) - vals.forEach(tag => { - if (tag == '') return - add_selected(tag) - }); + // let vals = suggest_input.value.split(' ') + // // console.log(vals) + // vals.forEach(tag => { + // if (tag == '') return + // add_selected(tag) + // }); + // Not as clean, but well whatever + selected.querySelectorAll("a").forEach(element => { + element.addEventListener('click', (event) => { + remove_selected(event.target.dataset.tagname) + event.preventDefault() + + setTimeout(() => suggest_input.focus(), 2) + }) + hidden_addtag(element.dataset.tagname) + }) suggest_input.removeAttribute('value') // Disable prefill by browser function select_suggestion(tagelement) { diff --git a/yadc/templates/layout/base_sidebar_tags.html b/yadc/templates/layout/base_sidebar_tags.html index a1a49e6..7bcc80d 100644 --- a/yadc/templates/layout/base_sidebar_tags.html +++ b/yadc/templates/layout/base_sidebar_tags.html @@ -26,10 +26,24 @@ -
+
+ {% for tag in sel_tags %} + + + + + {{ tag.content_deser }} + {{ tag.count }} + + + + {#{{ tag.post_ids }}#} + + {% endfor %} +
{% for tag in tags %} - +