Added so you can press enter to go to the next in find

This commit is contained in:
KasperRT
2015-03-18 00:47:07 +01:00
parent cece1a9452
commit 403fefe38b
3 changed files with 48 additions and 22 deletions

View File

@@ -44,6 +44,7 @@
<div class="result hiddenAdmin" id="adminPanel"><?php include("php/panel.php");?> </div> <div class="result hiddenAdmin" id="adminPanel"><?php include("php/panel.php");?> </div>
<form id="findform" onsubmit="return false;"> <form id="findform" onsubmit="return false;">
<input id="findform-input" type="text" onsubmit="null;" placeholder="Search list.."> <input id="findform-input" type="text" onsubmit="null;" placeholder="Search list..">
<label id="numfound"></label>
</form> </form>
<div id="playlist"> <div id="playlist">
<div id="wrapper"> <div id="wrapper">

View File

@@ -61,7 +61,22 @@ $(document).ready(function()
} }
}); });
$("body").keyup(function(event) { $("body").keyup(function(event) {
var x = event.keyCode;
if(find) if(find)
{
if(x == 13)
{
if(found != "" && $("#findform-input").val() != "")
{
znum+=1;
if(znum >= elems.length) znum = 1;
document.getElementById("numfound").innerHTML = znum + " av " + bright.length;
$("#numfound").css("margin-left", "-"+($("#numfound").width()+8));
$("#numfound").css("padding-right", 4);
$("#findform-input").css("padding", "0 "+($("#numfound").width()+8)+"px 0 5px");
myScroll.scrollToElement(elems[znum-1], 10, 0, 0);
}
}else
{ {
if(found != null) if(found != null)
{ {
@@ -74,12 +89,17 @@ $(document).ready(function()
{ {
elems.length = 0; elems.length = 0;
bright.length = 0; bright.length = 0;
znum = 1;
for(i = 0; i < found.length; i++) for(i = 0; i < found.length; i++)
{ {
found[i].className = found[i].className + " fullbrightness"; found[i].className = found[i].className + " fullbrightness";
bright.push(found[i].className.split(" ")[0]); bright.push(found[i].className.split(" ")[0]);
elems.push(found[i]); elems.push(found[i]);
} }
document.getElementById("numfound").innerHTML = znum + " av " + bright.length;
$("#numfound").css("margin-left", "-"+($("#numfound").width()+8));
$("#numfound").css("padding-right", 4);
$("#findform-input").css("padding", "0 "+($("#numfound").width()+8)+"px 0 5px");
myScroll.scrollToElement(found[0], 10, 0, 0); myScroll.scrollToElement(found[0], 10, 0, 0);
}else }else
{ {
@@ -88,6 +108,7 @@ $(document).ready(function()
elems.length = 0; elems.length = 0;
znum = 1; znum = 1;
} }
}
//console.log($("#wrapper").find(".result:contains('"+$("#findform-input").val()+"')")); //console.log($("#wrapper").find(".result:contains('"+$("#findform-input").val()+"')"));
} }
}); });

View File

@@ -32,12 +32,16 @@ body {
-webkit-transition:height 0.5s; -webkit-transition:height 0.5s;
} }
#numfound {
color:white;
}
#findform-input { #findform-input {
color:#fff; color:#fff;
height:24px; height:24px;
font-size:15px; font-size:15px;
width:60%; width:60%;
padding:5px; /*padding:0 50px 0 5px;*/
margin:5px 0; margin:5px 0;
border-radius:2px; border-radius:2px;
border:none; border:none;