dio-v
5/30/2016 - 8:41 AM

touch hover menu fix

touch hover menu fix

    //menu give li's class to show it has submenu
    $('.navigationMain').find('li').each(function () {
        var vT = $(this);
        if ($('ul', this)[0]) {
            vT.addClass('has-dropdown').find('ul').first().addClass('dropdown');
        }
    });

    //navigationMain
    //taphover - a solution to the lack of hover on touch devices.
    //more info: http://www.hnldesign.nl/work/code/mouseover-hover-on-touch-devices-using-jquery/
    $('.has-dropdown > a').on('touchstart', function (e) {
        'use strict'; //satisfy the code inspectors
        var link = $(this); //preselect the link
        if (link.hasClass('hover')) {
            return true;
        } else {
            link.addClass('hover');
            $('has-dropdown > a').not(this).removeClass('hover');
            e.preventDefault();
            return false; //extra, and to make sure the function has consistent return points
        }
    });