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,33 +61,54 @@ $(document).ready(function()
} }
}); });
$("body").keyup(function(event) { $("body").keyup(function(event) {
var x = event.keyCode;
if(find) if(find)
{ {
if(found != null) if(x == 13)
{ {
last = found[0]; if(found != "" && $("#findform-input").val() != "")
if(!(typeof last === "undefined"))
$(".lresult").removeClass("fullbrightness");
}
found = $("#wrapper").find(".lresult:contains('"+$("#findform-input").val()+"')");
if(found != "" && $("#findform-input").val() != "")
{
elems.length = 0;
bright.length = 0;
for(i = 0; i < found.length; i++)
{ {
found[i].className = found[i].className + " fullbrightness"; znum+=1;
bright.push(found[i].className.split(" ")[0]); if(znum >= elems.length) znum = 1;
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(elems[znum-1], 10, 0, 0);
} }
myScroll.scrollToElement(found[0], 10, 0, 0);
}else }else
{ {
$(".lresult").removeClass("fullbrightness"); if(found != null)
bright.length = 0; {
elems.length = 0; last = found[0];
znum = 1; if(!(typeof last === "undefined"))
} $(".lresult").removeClass("fullbrightness");
}
found = $("#wrapper").find(".lresult:contains('"+$("#findform-input").val()+"')");
if(found != "" && $("#findform-input").val() != "")
{
elems.length = 0;
bright.length = 0;
znum = 1;
for(i = 0; i < found.length; i++)
{
found[i].className = found[i].className + " fullbrightness";
bright.push(found[i].className.split(" ")[0]);
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);
}else
{
$(".lresult").removeClass("fullbrightness");
bright.length = 0;
elems.length = 0;
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;