Need menu to dropdown using keyboard
First let me say, I'm new to jQuery and its been a while since I've done anything with Javascript. Second, this isn't my code, I came into the project a couple of months ago and trying to figure out what goes with what.
What do I need to do so that when someone tabs into the menu it will drop down just like it does when you mouseover it? Is this even possible?
- if(ie === "1") {
- if($(window).width() > 949) {
- $.fn.pause = function (a) {
- $(this).stop().animate({
- dummy: 1
- }, a);
- return this
- };
- function mouseleft() {
- $("#buttonbar").triggerHandler("mouseleave")
- }
- $(document).ready(function () {
- $("#buttonbar").mouseenter(function () {
- $(this).stop().pause(160).animate({
- height: "12.7em"
- }, 400, "easeOutQuart")
- }).mouseleave(function () {
- $(this).stop().pause(160).animate({
- height: "2.2em"
- }, 400, "easeOutQuart")
- });
- });
- $(function () {
- $("#accordion").accordion({
- fillSpace: !0,
- icons: {
- header: "accordion-header",
- headerSelected: "accordion-headerselected"
- }
- })
- });
- if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
- $("#buttonbar li").bind('touchstart', function () {
- console.log("touch started");
- });
- $("#buttonbar li").bind('touchend', function () {
- console.log("touch ended");
- });
- } else {
- $("#accordion").accordion({
- active: false
- });
- }
- }
- function showElement(d) {
- var s = document.getElementById(d).style;
- if($(window).width() < 950) {
- if(s.display != "block") {
- s.display = "block";
- } else {
- s.display = "none";
- }
- if($(window).width() > 949) {
- if(s.display != "block") {
- s.display = "block";
- }
- }
- }
- }
- function showHide() {
- var s = document.getElementById("buttonbar").style;
- if($(window).width() > 949) {
- s.display = "block";
- document.getElementById("prospective-links").style.display = "block";
- document.getElementById("current-links").style.display = "block";
- document.getElementById("academic-links").style.display = "block";
- document.getElementById("facstaff-links").style.display = "block";
- document.getElementById("parent-links").style.display = "block";
- document.getElementById("alumni-links").style.display = "block";
- document.getElementById("visitor-links").style.display = "block";
- $("#accordion").accordion('destroy');
- $("#buttonbar").unbind('mouseenter');
- $("#buttonbar").unbind('mouseleave');
- $.fn.pause = function (a) {
- $(this).stop().animate({
- dummy: 1
- }, a);
- return this
- };
- function mouseleft() {
- $("#buttonbar").triggerHandler("mouseleave")
- }
- $(document).ready(function () {
- $("#buttonbar").mouseenter(function () {
- $(this).stop().pause(160).animate({
- height: "12.7em"
- }, 400, "easeOutQuart")
- }).mouseleave(function () {
- $(this).stop().pause(160).animate({
- height: "2.2em"
- }, 400, "easeOutQuart")
- });
- });
- $(function () {
- $("#accordion").accordion({
- fillSpace: !0,
- icons: {
- header: "accordion-header",
- headerSelected: "accordion-headerselected"
- }
- })
- });
- if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
- $("#buttonbar li").bind('touchstart', function () {
- console.log("touch started");
- });
- $("#buttonbar li").bind('touchend', function () {
- console.log("touch ended");
- });
- }
- } else { /*$("#accordion").accordion({active:false});*/
- $("#accordion").accordion('destroy');
- $("#buttonbar").unbind('mouseenter');
- $("#buttonbar").unbind('mouseleave');
- $("#buttonbar li").unbind('touchstart');
- $("#buttonbar li").unbind('touchend');
- s.display = "none";
- document.getElementById("prospective-links").style.display = "none";
- document.getElementById("current-links").style.display = "none";
- document.getElementById("academic-links").style.display = "none";
- document.getElementById("facstaff-links").style.display = "none";
- document.getElementById("parent-links").style.display = "none";
- document.getElementById("alumni-links").style.display = "none";
- document.getElementById("visitor-links").style.display = "none"; /*$("#buttonbar").accordion('destroy');*/
- }
- }
- $(window).resize(showHide);
- //Run when resized
- jQuery(function ($) {
- var path = location.pathname.substring(1);
- $('#nav a[href$="' + path + '"]').addClass('active');
- }); // This section makes the skip to anchor links such as the skip to content link work in webkit browsers like Chrome and Safari
- (function (linkList, i, URI) {
- if( !! (URI = document.documentURI)) {
- URI = URI.split('#')[0];
- document.addEventListener("DOMContentLoaded", function () {
- document.removeEventListener("DOMContentLoaded", arguments.callee, false);
- linkList = document.links;
- for(i in linkList) {
- if( !! linkList[i].hash) {
- if(linkList[i].hash.match(/^#./)) {
- if((URI + linkList[i].hash) == linkList[i].href) {
- linkList[i].addEventListener("click", function (e, f, g) {
- f = document.getElementById(this.hash.slice(1));
- if(!(g = f.getAttribute('tabIndex'))) f.setAttribute('tabIndex', - 1);
- f.focus();
- if(!g) f.removeAttribute('tabIndex');
- }, false);
- }
- }
- }
- }
- }, false);
- }
- return true;
- })();
- } else {
- function showElement(d) {
- var s = document.getElementById(d).style;
- if(s.display != "block") {
- s.display = "block";
- } else {
- s.display = "none";
- }
- };
- };
- <div id="buttonbar">
<ul id="bar">
<li id="prospective" class="rightborder"><a href="#">Top Menu Item 1</a>
<ul id="prospective-links">
<li><a href="#">Sub Menu Item 1</a></li>
<li><a href="#">Sub Menu Item 2</a></li>
</ul>
</li>
<li id="students" class="rightborder"><a href="#">Top Menu Item 2</a>
<ul id="current-links" id="prospective-links">
<li><a href="#">Sub Menu Item 1</a></li>
<li><a href="#">Sub Menu Item 2</a></li>
</ul>
</li>
............
</ul>
</div>
I can provide the css if needed.
[moderator reformatted]