Created
November 17, 2013 22:42
-
-
Save yitwail/7519239 to your computer and use it in GitHub Desktop.
changes to js/custom.js for iPad dropdown menu support
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
// apply fitvids functionality to .entry-content div | |
// https://github.com/davatron5000/FitVids.js | |
jQuery(document).ready(function($) { | |
$(".entry-content").fitVids(); | |
}); | |
// modified version of flexnav, does not have drop down functionality | |
// https://github.com/indyplanets/flexnav | |
// http://webdeveloper2.com/2011/06/trigger-javascript-on-css3-media-query-change/ | |
jQuery(document).ready(function($) { | |
detector = jQuery('.js'); | |
compareWidth = detector.width(); | |
smallScreen = '768'; | |
menuButton = $('.menu-button'); | |
menuButton.click(function() { | |
if (!$(".access-nav").is(":visible")) | |
menuButton.addClass("nav-open"); | |
$(".access-nav").slideToggle('slow', function() { | |
if (!$(".access-nav").is(":visible")) | |
menuButton.removeClass("nav-open"); | |
}); | |
}); | |
//http://stackoverflow.com/questions/15815513/hover-behavior-on-desktop-vs-ipad | |
//http://benfrain.com/beginner-and-designers-guide-to-using-modernizr-to-solve-cross-browser-challenges/ | |
if (Modernizr.touch) { | |
$('#access .sf-menu > li.has-flyout > a').on('click', function() { | |
if (menuButton.is(":visible") || $(this).hasClass('hover')) | |
return true; | |
$(this).addClass('hover').parent().siblings('.has-flyout').children('a').removeClass('hover'); | |
return false; | |
}); | |
} | |
$(window).resize(function(){ | |
if (detector.width()!=compareWidth) { | |
compareWidth = detector.width(); | |
if (compareWidth >= smallScreen) { | |
$('.access-nav').show(); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment