Created
June 5, 2012 03:21
-
-
Save marcmartino/2872416 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getHoverElement: function(autoBox) { //should look through the autocomplete box and find which one is hovering and return {prev: previousElement, hover: elementWithHover, next: nextElement} | |
//if there are no hovers the return should be {prev: firstElement, hover: null, lastElement}, if there are no elements in the box the return should be null | |
var items = autoBox.getElementsByTagName("li"), | |
m = items.length - 1, | |
returnValues = { | |
prev: null, | |
hover: null, | |
next: items[m] | |
}; | |
if (m > -1) { | |
for (; m + 1; m--) { | |
if (items[m].getAttribute("data-faux-hover") == 1) { | |
returnValues.hover = items[m]; | |
items[m + 1] && (returnValues.next = items[m + 1]); | |
return returnValues; | |
} | |
else { | |
returnValues.prev = items[m]; | |
} | |
}; | |
returnValues.prev = items[m]; | |
return returnValues; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment