Skip to:
Content
Pages
Categories
Search
Top
Bottom

Close Options menu on second click/tap

  • @tech55541

    Participant

    Hello,
    I have this code that I used to create a custom BBPress options menu. It works great. The only thing it does not do is close on a mobile device when the options menu is clicked again. Could you please help me add this functionality?

    functions.php code

    /* Custom BBPress admin links menu*/
    function wpmudev_bbp_admin_links_in_menu($retval, $r, $args) {
       if ( is_user_logged_in() ) {
       $menulinks = '<ul id="bbp_custom_links_menu-' . $r["id"] . '" class="bbp_custom_links_menu">';
        $menulinks .= '<li class="parent"><a href="#bbp_custom_links_menu-' . $r["id"] . '">Options</a>';
        $menulinks .= '<ul class="bbp_custom_links_submenu">';
        foreach($r['links'] as $key => $val) {
            $menulinks .= "<li>{$val}</li>";
        }
        $menulinks .= '</ul></li></ul>';
    
        echo $r['before'] . $menulinks . $r['after'];
        }
    }
    add_filter('bbp_get_topic_admin_links', 'wpmudev_bbp_admin_links_in_menu', 10, 3);
    add_filter('bbp_get_reply_admin_links', 'wpmudev_bbp_admin_links_in_menu', 10, 3);
    
    add_action( 'wp_footer', 'overflow_overriding' );
    function overflow_overriding() {
        if ( !is_user_logged_in() ) {
        }else{
        ?>
        <script type="text/javascript">
    		jQuery( document ).ready(function() {
    		   jQuery('.bbp-admin-links:even').css({"position": "absolute", "right": "380px"});
    		});
        </script>
    
         <?php
        }
    }

    Thanks for the help.

Viewing 9 replies - 1 through 9 (of 9 total)
  • @robin-w

    Moderator

    without even looking in detail, I’d suggest that ‘380px’ on a mobile is the problem.

    @tech55541

    Participant

    Hello,
    All phones, so even up to 488px.

    Thanks.

    @robin-w

    Moderator

    @tech55541

    If it works on PC, tablets etc. but doesn’t on a mobile, this will not be code functionality, but either JS or CSS.

    Given that few mods will have the time to work out what this code is doing, let alone load it to their site, a URL to a page where it works on a PC but doesn’t on a mobile would be useful.

    @tech55541

    Participant

    Hello,
    Having some caching and other related errors on the site today, I will get back here soon, I have not forgotten.

    Thanks.

    @robin-w

    Moderator

    ok, no problem, come back when you are ready 🙂

    @tech55541

    Participant

    Hello,
    Site is still a little unstable, but I think it is good enough to get this problem fixed.
    Just so we all understand, here is what is going on. The menu is designed to open on mouse hover and then close when the mouse pointer leaves the menu. On mobile devices such as phones and tablets, you cannot close the menu because clicking Options opens it. We need to add some additional code to first check if the menu is open, if not, on click open it, if so, on click close it. Would this be a doable task?

    You do have to login to see the options menu, this user account will be deleted as soon as we are done using it.
    Username: bbpress.org-support
    Password: 5oj^gI6OOx*DrCeAlM4J7ZKG
    URL: http://yourtechadvisors.com/forums/topic/testing/

    Thanks for your help.

    @robin-w

    Moderator

    ok, so now I think I understand your issue. I am presuming that you mean the options menu, which works fine on a pc as using the mouse to hover lists the menu items and closes them as the mouse moves away.

    with a smartphone you need to click rather than move a mouse? (I don’t have a smartphone!)

    Since having the menu expand is not part of the normal bbpress function (it just lists the menu items rather than having a dropdown list), I presume that either your theme is doing this, or you have added some js to do this?

    You could try

    http://wordpress.stackexchange.com/

    @tech55541

    Participant

    Since having the menu expand is not part of the normal bbpress function (it just lists the menu items rather than having a dropdown list), I presume that either your theme is doing this, or you have added some js to do this?

    Yes it is using JavaScript, I pasted it all above.

    Thanks, I will take a look at link posted in your last reply to.

    @tech55541

    Participant

    Hello,
    No one apparently wants to help at wordpress.stackexchange.com, anywhere else you suggest? Is there anyone else on this forum that is a Jquery expert?

    Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar