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

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