Forum Replies Created

Viewing 15 replies - 1 through 15 (of 79 total)
  • Thread Starter shaibustephen

    (@shaibustephen)

    How do i create a custom walker class. and where can i get the a walker class. for customization?

    Thread Starter shaibustephen

    (@shaibustephen)

    What is the best approach to have div wrap all ul of sub-menu?

    Thread Starter shaibustephen

    (@shaibustephen)

    I was able to get it done but my challenge now is how to add div class of dropdown before ul sub-menu in wordpress? View the sample below

    <li class="item"><a href="#">Home</a></li>
    <li class="item"><a href="#">About Us</a></li>
    <li class="item dropdownitem">
    <a href="#" class="nav-dropdown">Services</a>
    <div class="dropdown">
    <ul>
    <li class="item"><a href="#">Software</a></li>
    <li class="item"><a href="#">Server Maintenance</a></li>
    <li class="item dropdownitem">
    <a href="#" class="nav-dropdown">Web Hosting</a>
    <div class="dropdown">
    Thread Starter shaibustephen

    (@shaibustephen)

    I was able to resolve the challenges after an intensive work. It triggers up downdown in mobile device within the @media (max-width: 991px) {} but doesnt show up in @media (min-width: 991px) {}. What do you suggest on how to get it work.

    .main-navigation li.clicked > ul {
    display: block;
    }
    .main-navigation li ul {
    display: none;
    position: absolute;
    min-width: 200px;
    max-width: 300px;
    padding: 0;
    margin: 0;
    }
    .main-navigation li ul a {
    background-color: #dfdfdf;
    font-size: 0.8125em;
    }
    .main-navigation li ul li {
    float: none;
    display: block;
    margin: 0;
    }
    .main-navigation li ul ul {
    left: 100%;
    margin-top: -40px;
    }


    @media (max-width: 991px) {
    .navbar .main-navigation ul {
    display: none;
    max-width: none !important;
    }
    .navbar .main-navigation li {
    float: none;
    display: block;
    margin: 0;
    padding: 0;
    }
    .navbar .main-navigation.kaculat > ul {
    display: block;
    position: absolute;
    margin: 0;
    background-color: #FFF;
    right: 0;
    left: 0;
    z-index: 100;
    padding: 0;
    }
    .navbar .main-navigation.kaculat > ul ul {
    display: none;
    width: 100%;
    z-index: 200;
    border: none;
    margin-left: 0;
    padding: 0;
    position: relative !important;
    }

    }

    My jquery


    jQuery(document).ready(function( $ ) {
    // show/hide the mobile menu based on class added to container
    $('.toogle-icon').click(function () {
    $(this).parent().toggleClass('kaculat');
    $('#hamburger').toggleClass('open');
    });

    // handle touch device events on drop down, first tap adds class, second navigates
    $('.touch .main-navigation li.nav-dropdown > a').on('touchend',
    function (e) {
    if ($('.toogle-icon').is(':hidden')) {
    var parent = $(this).parent();
    $(this).find('.clicked').removeClass('clicked');
    if (parent.hasClass('clicked')) {
    window.location.href = $(this).attr('href');
    } else {
    $(this).addClass('linkclicked');

    // close other open menus at this level
    $(this).parent().parent().find('.clicked').removeClass('clicked');

    parent.addClass('clicked');
    e.preventDefault();
    }
    }
    });

    // handle the expansion of mobile menu drop down nesting
    $('.main-navigation li.nav-dropdown').click(
    function (event) {
    if (event.stopPropagation) {
    event.stopPropagation();
    } else {
    event.cancelBubble = true;
    }

    if ($('.toogle-icon').is(':visible')) {
    $(this).find('> ul').toggle();
    $(this).toggleClass('expanded');
    }
    });


    // prevent links for propagating click/tap events that may trigger hiding/unhiding
    $('.main-navigation a.nav-dropdown, .main-navigation li.nav-dropdown a').click(
    function (event) {
    if (event.stopPropagation) {
    event.stopPropagation();
    } else {
    event.cancelBubble = true;
    }
    });


    // javascript fade in and out of dropdown menu
    $('.no-touch .main-navigation li').hover(
    function () {
    if (!$('.toogle-icon').is(':visible')) {
    $(this).find('> ul').fadeIn(100);
    }
    },
    function () {
    if (!$('.toogle-icon').is(':visible')) {
    $(this).find('> ul').fadeOut(100);
    }
    });

    });
    Thread Starter shaibustephen

    (@shaibustephen)

    I was able to little work on the jquery. The issue now is that the jquery is not looking display none and block style on the ul ul. Kindly help me look at the jquery in my wordpress code and let me know what i have done wrong? I am equally seeking error message in my browser console

    Here is how i integrated the jquery

    wp_enqueue_script( 'kaculat-jquery-min', get_template_directory_uri() . '/assets/js/jquery.min.js', array('jquery'),  '2.1.3', true );




    (function( $ ) {

    "use strict";

    // javascript code here. i.e.: $(document).ready( function(){} );

    // on document ready
    $(document).ready(function () {

    // show/hide the mobile menu based on class added to container
    $('.menu-icon').click(function () {
    $(this).parent().toggleClass('is-tapped');
    $('#hamburger').toggleClass('open');
    });

    // handle touch device events on drop down, first tap adds class, second navigates
    $('.touch .sitenavigation li.nav-dropdown > a').on('touchend',
    function (e) {
    if ($('.menu-icon').is(':hidden')) {
    var parent = $(this).parent();
    $(this).find('.clicked').removeClass('clicked');
    if (parent.hasClass('clicked')) {
    window.location.href = $(this).attr('href');
    } else {
    $(this).addClass('linkclicked');

    // close other open menus at this level
    $(this).parent().parent().find('.clicked').removeClass('clicked');

    parent.addClass('clicked');
    e.preventDefault();
    }
    }
    });

    // handle the expansion of mobile menu drop down nesting
    $('.sitenavigation li.nav-dropdown').click(
    function (event) {
    if (event.stopPropagation) {
    event.stopPropagation();
    } else {
    event.cancelBubble = true;
    }

    if ($('.menu-icon').is(':visible')) {
    $(this).find('> ul').toggle();
    $(this).toggleClass('expanded');
    }
    });


    // prevent links for propagating click/tap events that may trigger hiding/unhiding
    $('.sitenavigation a.nav-dropdown, .sitenavigation li.nav-dropdown a').click(
    function (event) {
    if (event.stopPropagation) {
    event.stopPropagation();
    } else {
    event.cancelBubble = true;
    }
    });


    // javascript fade in and out of dropdown menu
    $('.no-touch .sitenavigation li').hover(
    function () {
    if (!$('.menu-icon').is(':visible')) {
    $(this).find('> ul').fadeIn(100);
    }
    },
    function () {
    if (!$('.menu-icon').is(':visible')) {
    $(this).find('> ul').fadeOut(100);
    }
    });

    });
    //# sourceURL=pen.js

    })(jQuery);

    Thread Starter shaibustephen

    (@shaibustephen)

        I used 'items_wrap'     => '<ul>%3$s/ul>', to remove default class associated with ul. How do i equally remove default class with <li></li> as seen below?
    	<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-2 current_page_item menu-item-6"><a href="http://localhost/kaculat/sample-page/" aria-current="page">Sample Page</a>after</li>
    Thread Starter shaibustephen

    (@shaibustephen)

    The issue is not HTML. I got it perfectly right but wordpress is providing wrong class. How do I remove current class associated with ul, ul ul, ul ul ul, li a etc in nav output in wordpress?

    Thread Starter shaibustephen

    (@shaibustephen)

    before your recommendation, I use it like below and work fine only that it does not drop-down

    .navigation > .div > ul > li

    Thread Starter shaibustephen

    (@shaibustephen)

    is there anyway I can send an zipped copy of my work to you here. It is currently not online but on my local host

    Thread Starter shaibustephen

    (@shaibustephen)

    I applied your solution and it messes up everything.

    complete css

    .navigation {
    width: 100%;
    background:#5d9fef
    }

    .navigation > .container > ul a.logo {
    display: inline-block;
    padding: 1.0em 1.7em;
    width: 19%;
    float: left;
    text-transform: capitalize
    }

    .navigation > .container > ul a.logo {
    text-decoration: none;
    color: #122f48;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 20px;
    }

    .navigation > .container > ul .mobile {
    display: none;
    padding: 20px;
    }

    .navigation > .container > ul .mobile:after {
    content: "\f394";
    font-family: "Ionicons";
    font-size: 2.5rem;
    padding: 0;
    float: right;
    position: relative;
    top: 50%;
    -webkit-transform: translateY(-25%);
    transform: translateY(-25%);
    }
    .navigation > .container > ul .sub-icon:before {
    content: "\f489";
    font-family: "Ionicons";
    display: none;
    cursor: pointer;
    float: right;
    padding: 1.0em 2em;
    background: #fff;
    color: #333;
    }

    .navigation > .container > ul > ul {
    margin: auto;
    width:auto;
    list-style: none;
    padding: 0;
    position: relative;
    box-sizing: border-box;
    }

    .navigation > .container > ul > ul:before,
    .navigation > .container > ul > ul:after {
    content: "";
    display: table;
    }
    .navigation > .container > ul > ul:after {
    clear: both;
    }
    .navigation > .container > ul > ul > li {
    float: left;
    background-color: transparent;
    padding: 0;
    margin: 0;
    }
    .navigation > .container > ul > ul > li a {
    text-decoration: none;
    padding: 1.0em 3em;
    display: block;
    color: #fff
    }
    .navigation > .container > ul > ul > li:hover {
    background: #f0f0f0;
    }
    .navigation > .container > ul > ul > li > ul {
    display: none;
    width: 100%;
    background: #f0f0f0;
    padding: 20px;
    position: absolute;
    z-index: 99;
    left: 0;
    margin: 0;
    list-style: none;
    box-sizing: border-box;
    }
    .navigation > .container > ul > ul > li > ul:before,
    .navigation > .container > ul > ul > li > ul:after {
    content: "";
    display: table;
    }
    .navigation > .container > ul > ul > li > ul:after {
    clear: both;
    }
    .navigation > .container > ul > ul > li > ul > li {
    margin: 0;
    padding-bottom: 0;
    list-style: none;
    width: 25%;
    background: none;
    float: left;
    }
    .navigation > .container > ul > ul > li > ul > li a {
    color: #777;
    padding: .2em 0;
    width: 95%;
    display: block;
    border-bottom: 1px solid #ccc;
    }
    .navigation > .container > ul > ul > li > ul > li a:hover{
    color:#03a9f4;
    }
    .navigation > .container > ul > ul > li > ul > li > ul {
    display: block;
    padding: 0;
    margin: 10px 0 0;
    list-style: none;
    box-sizing: border-box;
    }
    .navigation > .container > ul > ul > li > ul > li > ul:before,
    .navigation > .container > ul > ul > li > ul > li > ul:after {
    content: "";
    display: table;
    }
    .navigation > .container > ul > ul > li > ul > li > ul:after {
    clear: both;
    }
    .navigation > .container > ul > ul > li > ul > li > ul > li {
    float: left;
    width: 100%;
    padding: 10px 0;
    margin: 0;
    font-size: .8em;
    }
    .navigation > .container > ul > ul > li > ul > li > ul > li a {
    border: 0;
    font-size: 14px;
    }
    .navigation > .container > ul > ul > li > ul.normal-sub {
    width: 300px;
    left: auto;
    padding: 10px 20px;
    }
    .navigation > .container > ul > ul > li > ul.normal-sub > li {
    width: 100%;
    }
    .navigation > .container > ul > ul > li > ul.normal-sub > li a {
    border: 0;
    padding: 1em 0;
    }
    /* ––––––––––––––––––––––––––––––––––––––––––––––––––
    Mobile style's
    –––––––––––––––––––––––––––––––––––––––––––––––––– */
    .navigation .container {
    max-width: 1100px;
    }

    .site-header {
    position: relative;
    background: #fff;
    border-bottom: solid 1px #e9e9e9
    }

    @media only screen and (max-width: 959px) {
    .site-header {
    width: 100%;
    }

    .site-header .navigation > .container > ul {
    display:inline-block;
    }

    .navigation .container {
    max-width:100%;
    }

    .navigation > .container > ul .mobile {
    display: block;
    float: right;
    padding: 20px 20px 0;
    }
    .navigation > .container > ul .sub-icon:before {
    display: block;
    }
    .navigation > .container > ul > ul {
    display: none;
    width:100%;
    }
    .navigation > .container > ul > ul > li {
    width: 100%;
    float: none;
    display: block;
    }
    .navigation > .container > ul > ul > li a {
    padding: 1.0em;
    width: 100%;
    display: block;
    }
    .navigation > .container > ul > ul > li > ul {
    position: relative;
    padding: 0 40px;
    }
    .navigation > .container > ul > ul > li > ul.normal-sub {
    width: 100%;
    }
    .navigation > .container > ul > ul > li > ul > li {
    float: none;
    width: 100%;
    margin-top: 20px;
    }
    .navigation > .container > ul > ul > li > ul > li:first-child {
    margin: 0;
    }
    .navigation > .container > ul > ul > li > ul > li > ul {
    position: relative;
    }
    .navigation > .container > ul > ul > li > ul > li > ul > li {
    float: none;
    }

    .navigation > .container > ul > ul {
    clear: right;
    }

    .navigation > .container > ul .show-on-mobile {
    display: block;
    }
    }

    jquery

    /* global wp, jQuery / /*

    • File customizer.js.
      *
    • Theme Customizer enhancements for a better user experience.
      *
    • Contains handlers to make Theme Customizer preview reload changes asynchronously.
      */
      (function($) {
      $(document).ready(function () {
      “use strict”;
      $(‘.navigation > .container > ul > li:has( > ul)’).addClass(‘sub-icon’);
      $(‘.navigation > .container > ul > li > ul:not(:has(ul))’).addClass(‘normal-sub’);
      $(“.navigation > .container > ul”).before(“ “);
      $(“.navigation > .container > ul > li”).hover(function (e) {
      if ($(window).width() > 943) {
      $(this).children(“ul”).stop(true, false).fadeToggle(150);
      e.preventDefault();
      }
      });
      $(“.navigation > .container > ul > li”).click(function () {
      if ($(window).width() <= 943) { $(this).children(“ul”).fadeToggle(150); } }); $(“.mobile”).click(function (e) { $(“.navigation > .container > ul”).toggleClass(‘show-on-mobile’);
      e.preventDefault();
      });
      });
      $(window).resize(function () {
      $(“.navigation > .container > ul > li”).children(“ul”).hide();
      $(“.navigation > .container > ul”).removeClass(‘show-on-mobile’);
      });// JavaScript Document

    })( jQuery );

    Thread Starter shaibustephen

    (@shaibustephen)

    I appreciate your prompt response. I no more see any error message in browser console. But my challenge is that it does not trigger dropdown menu. Kindly view what i have done.. The dropdown work properly on the html but after integrating it to wordpress, it does not show. What am i getting wrong? What changes should i make?

    html

    <nav class="navigation">
    <div class="container">
    <a href="#" class="logo">Logo</a>
    <a href="#" class="mobile">&nbsp;</a><ul class="justify-content-end">
    <li><a href="#">Home</a></li>
    <li class="sub-icon"><a href="#">About</a>
    <ul style="opacity: 1; display: none;">
    <li><a href="#">School</a>
    <ul>
    <li><a href="#">Lidership</a></li>
    <li><a href="#">History</a></li>
    <li><a href="#">Locations</a></li>
    <li><a href="#">Careers</a></li>
    </ul>
    </li>
    <li><a href="#">Study</a>
    <ul>
    <li><a href="#">Undergraduate</a></li>
    <li><a href="#">Masters</a></li>
    <li><a href="#">International</a></li>
    <li><a href="#">Online</a></li>
    </ul>
    </li>
    <li><a href="#">Research</a>
    <ul>
    <li><a href="#">Undergraduate research</a></li>
    <li><a href="#">Masters research</a></li>
    <li><a href="#">Funding</a></li>
    </ul>
    </li>
    <li><a href="#">Something</a>
    <ul>
    <li><img src="https://placeimg.com/300/200/nature"></li>
    </ul>
    </li>
    </ul>
    </li>
    <li class="sub-icon"><a href="#">News</a>
    <ul class="normal-sub" style="opacity: 1; display: none;">
    <li><a href="#">Today</a></li>
    <li><a href="#">Calendar</a></li>
    <li><a href="#">Sport</a></li>
    </ul>
    </li>
    <li class="sub-icon"><a href="#">Contact</a>
    <ul style="opacity: 1; display: none;">
    <li><a href="#">School</a>
    <ul>
    <li><a href="#">Lidership</a></li>
    <li><a href="#">History</a></li>
    <li><a href="#">Locations</a></li>
    <li><a href="#">Careers</a></li>
    </ul>
    </li>
    <li><a href="#">Study</a>
    <ul>
    <li><a href="#">Undergraduate</a></li>
    <li><a href="#">Masters</a></li>
    <li><a href="#">International</a></li>
    <li><a href="#">Online</a></li>
    </ul>
    </li>
    <li><a href="#">Study</a>
    <ul>
    <li><a href="#">Undergraduate</a></li>
    <li><a href="#">Masters</a></li>
    <li><a href="#">International</a></li>
    <li><a href="#">Online</a></li>
    </ul>
    </li>
    <li><a href="#">Empty sub</a>
    <ul>
    <li><img src="https://placeimg.com/300/200/people"></li>
    </ul>
    </li>
    </ul>
    </li>
    </ul>
    </div><!--container-->
    </nav>

    WordPress

    <nav class="navigation">
    <div class="container">
    <a class="logo" href="#">Navbar</a>
    <ul id="menu-primary" class=" "><li id="menu-item-6" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-6"><a href="http://localhost/kaculat/sample-page/">Sample Page</a></li>
    <li id="menu-item-7" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-7"><a href="http://localhost/kaculat/sample-page/">Sample Page</a>
    <ul class="sub-menu">
    <li id="menu-item-8" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-8"><a href="http://localhost/kaculat/sample-page/">Sample Page</a></li>
    </ul>
    </li>
    <li id="menu-item-17" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-17"><a href="http://localhost/kaculat/sample-page/">Sample Page</a></li>
    </ul> </div>
    </nav>

    My Jquery

    (function($) {
    $(document).ready(function () {
    “use strict”;
    $(‘.navigation > ul > li:has( > ul)’).addClass(‘sub-icon’);
    $(‘.navigation > ul > li > ul:not(:has(ul))’).addClass(‘normal-sub’);
    $(“.navigation > ul”).before(“ “);
    $(“.navigation > ul > li”).hover(function (e) {
    if ($(window).width() > 943) {
    $(this).children(“ul”).stop(true, false).fadeToggle(150);
    e.preventDefault();
    }
    });
    $(“.navigation > ul > li”).click(function () {
    if ($(window).width() <= 943) { $(this).children(“ul”).fadeToggle(150); } }); $(“.mobile”).click(function (e) { $(“.navigation > ul”).toggleClass(‘show-on-mobile’);
    e.preventDefault();
    });
    });
    $(window).resize(function () {
    $(“.navigation > ul > li”).children(“ul”).hide();
    $(“.navigation > ul”).removeClass(‘show-on-mobile’);
    });// JavaScript Document

    })( jQuery );

    Thread Starter shaibustephen

    (@shaibustephen)

    The button of the underscore was within the opening and closing of nav class. To customise it, I move the button outside the opening and closing of nav. The issue now is that it does not toggle anymore. That was why I copied and pasted the complete code, the css and jQuery for guidance on what to apply to get toggle on mobile device size

    Thread Starter shaibustephen

    (@shaibustephen)

    > Previous Next

    Thread Starter shaibustephen

    (@shaibustephen)

    what do you mean by upper/lower case? Help me as i am new in wordpress development

    Thread Starter shaibustephen

    (@shaibustephen)

    I later observed when i typed ”localhost” on the browser, i get the below error message
    Unable to connect

    An error occurred during a connection to localhost.

    The site could be temporarily unavailable or too busy. Try again in a few moments.
    If you are unable to load any pages, check your computer’s network connection.
    If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

Viewing 15 replies - 1 through 15 (of 79 total)