forked from server/soundboard
Simplify tag form
This commit is contained in:
parent
102dd681a0
commit
e9f4f29a87
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,8 @@ ready(function() {
|
||||
var sections = document.querySelectorAll("section");
|
||||
var nav = document.querySelectorAll("nav > a");
|
||||
|
||||
sections[0].style.display = "block";
|
||||
if (sections.length > 0)
|
||||
sections[0].style.display = "block";
|
||||
|
||||
nav.forEach(function(item) {
|
||||
item.onclick = function(e) {
|
||||
@ -29,35 +30,54 @@ ready(function() {
|
||||
|
||||
var searchfield = document.querySelector("#search");
|
||||
|
||||
searchfield.addEventListener("keyup", function() {
|
||||
console.log("Search!");
|
||||
if (searchfield !== null) {
|
||||
searchfield.addEventListener("keyup", function() {
|
||||
console.log("Search!");
|
||||
|
||||
var buttons = document.querySelectorAll(".sound");
|
||||
var buttons = document.querySelectorAll(".sound");
|
||||
|
||||
buttons.forEach(function(item) {
|
||||
item.style.display = "inline-block";
|
||||
buttons.forEach(function(item) {
|
||||
item.style.display = "inline-block";
|
||||
});
|
||||
|
||||
buttons.forEach(function(item) {
|
||||
var name = item.firstChild.innerHTML;
|
||||
|
||||
if (name.toLowerCase().indexOf(searchfield.value.toLowerCase()) === -1) {
|
||||
item.style.display = "none";
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
buttons.forEach(function(item) {
|
||||
var name = item.firstChild.innerHTML;
|
||||
var reset = document.querySelector("#sounds .reset");
|
||||
|
||||
if (name.toLowerCase().indexOf(searchfield.value.toLowerCase()) === -1) {
|
||||
item.style.display = "none";
|
||||
}
|
||||
if (reset !== null) {
|
||||
reset.addEventListener("click", function() {
|
||||
var buttons = document.querySelectorAll(".sound");
|
||||
|
||||
buttons.forEach(function(item) {
|
||||
item.style.display = "inline-block";
|
||||
});
|
||||
|
||||
searchfield.value = "";
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var reset = document.querySelector("#reset");
|
||||
var taginputs = document.querySelectorAll(".taginput");
|
||||
|
||||
reset.addEventListener("click", function() {
|
||||
var buttons = document.querySelectorAll(".sound");
|
||||
|
||||
buttons.forEach(function(item) {
|
||||
item.style.display = "inline-block";
|
||||
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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
searchfield.value = "";
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function hideSections() {
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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 %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user