Advertisement
Guest User

main.js

a guest
Oct 25th, 2017
537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. init();
  2.  
  3. function init() {
  4. hideMobileNavOnClick();
  5. }
  6.  
  7. function hideMobileNavOnClick() {
  8. var $ = jQuery,
  9. menu = $('.main-navigation'),
  10. inlineLinks = menu.find('a[href*="#"]');
  11.  
  12. if (inlineLinks.length !== 0) {
  13. inlineLinks.each(function() {
  14. var link = $(this),
  15. linkHref = link.attr('href'),
  16. linkHash = linkHref.substr(linkHref.indexOf("#")),
  17. // Search ID or Name attributes
  18. target = $(linkHash).add('[name="' + linkHash.substr(1) + '"]');
  19.  
  20. if (target.length !== 0) {
  21. // Enable keyboard support
  22. target.attr('tabindex', '-1');
  23.  
  24. link.on('click', function(event) {
  25. var menuBtn = menu.find('.menu-toggle');
  26.  
  27. // If mobile
  28. if (!menuBtn.is(':hidden')) {
  29. // Hide the menu
  30. menuBtn.click();
  31. }
  32.  
  33. });
  34. }
  35. });
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement