Simplify tag form

This commit is contained in:
Martin Müller 2017-07-18 20:37:52 +02:00
parent 102dd681a0
commit e9f4f29a87
4 changed files with 51 additions and 49 deletions

View File

@ -39,17 +39,11 @@ input {
margin-right: auto;
}
.editform input, .tagcontainer {
.editform input {
margin: 5px;
}
.tagcontainer {
background-color: #666;
border: 1px solid #999;
border-radius: 5px;
}
.tags span {
.tags li {
background-color: #333;
border-radius: 2px;
font-size: 0.9em;
@ -57,18 +51,6 @@ input {
padding: 2px 5px 2px 5px;
}
.tags, .taginput {
display: inline-block;
}
.taginput {
background: none;
border: none;
border-radius: 0;
margin: 0 !important;
padding: 5px 5px 5px 0px;
}
.youtube label {
vertical-align: middle;
}
@ -100,12 +82,12 @@ section {
width: 100%;
}
#reset {
.reset {
font-size: 2em;
padding-left: 5px;
}
#reset:hover {
.reset:hover {
cursor: pointer;
}

View File

@ -12,6 +12,7 @@ ready(function() {
var sections = document.querySelectorAll("section");
var nav = document.querySelectorAll("nav > a");
if (sections.length > 0)
sections[0].style.display = "block";
nav.forEach(function(item) {
@ -29,6 +30,7 @@ ready(function() {
var searchfield = document.querySelector("#search");
if (searchfield !== null) {
searchfield.addEventListener("keyup", function() {
console.log("Search!");
@ -46,9 +48,11 @@ ready(function() {
}
});
});
}
var reset = document.querySelector("#reset");
var reset = document.querySelector("#sounds .reset");
if (reset !== null) {
reset.addEventListener("click", function() {
var buttons = document.querySelectorAll(".sound");
@ -58,6 +62,22 @@ ready(function() {
searchfield.value = "";
});
}
var taginputs = document.querySelectorAll(".taginput");
if (taginputs.length > 0) {
taginputs.forEach(function(taginput) {
taginput.addEventListener("keydown", function(e) {
if (e.target == taginput && (e.which == 13 || e.keyCode == 13)) {
e.preventDefault();
} else if (e.which == 32 || e.keyCode == 13) {
console.log("Space");
addTag(e.target);
}
});
});
}
});
function hideSections() {

View File

@ -10,12 +10,12 @@
<label for="tags">Tags</label>
</div>
<div class="table-cell">
<div class="tagcontainer">
<div class="tags"><span>Test</span></div>
<input class="taginput" type="input" name="tags" id="tags" />
</div>
<input type="input" name="tags" id="tags" />
</div>
</div>
<ul class="tags">
<li>Test<span class="reset"></span></li>
</ul>
<div class="table-row">
<div class="table-cell">
</div>

View File

@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block content %}
<section id="sounds">
<div><input type="text" id="search" /><span id="reset"></span></div>
<div><input type="text" id="search" /><span class="reset"></span></div>
{% for sound in sounds %}
<div class="sound{{ ' edit' if edit }}"><a href="{{ '/' + ('edit' if edit else 'play') + '/' + sound | urlencode }}">{{ sound.split('.', 1)[0] }}</a></div>
{% endfor %}