Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Close menu on click of Options button and outside of container Reply To: Close menu on click of Options button and outside of container

#240382
Anonymous
Inactive

Hello,
I cannot make the CodePen work for this situation. Here is the full code, if you can get it to work, thanks in advance.

/*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($) {
          $('.bbp-admin-links:even').css({position: 'absolute', right: '380px'});
$('.bbp-meta ul.bbp_custom_links_menu li.parent > a').click(function(e) {
    $(this).next('.bbp_custom_links_submenu').toggle();
    e.preventDefault();
})
.mouseup(function(e) {
    e.stopPropagation();
});
});
</script>

     <?php
    }
}

Thanks.