Page 1 of 1

Custom include

Posted: Fri Apr 16, 2021 10:39 am
by Support_Talea
Hi,

I have to say that I have not found much valid information.
I would like to implement my own menu inside the nagiosxi through the custom includes.
I found a sample but it works halfway and I can't solve the problem.

https://pastebin.com/k5KJAu14

How do I create a custom identical menu, which closes and opens drop-down?

Regards,
-Federico

Re: Custom include

Posted: Fri Apr 16, 2021 5:33 pm
by ssax
I was able to get it to work like this:

Code: Select all

$(document).ready(function () {
   $("#leftnav").append(
   '<div class="menusection">' +
    '<div id="mid-menu-home-section-custom" class="menusectiontitle mid-menu-home-section-custom" data-id="menu-home-section-custom">' +
        '<i class="fa fa-chevron-down" title="Collapse menu section"></i> Custom Section</div>' +
    '<ul class="menusection">' +
        '<li class="menulink">' +
            '<a href="http://www.bing.com" target="_new">Bing</a>' +
        '</li>' +
        '<li class="menulink">' +
            '<a href="http://www.google.com" target="_new">Google</a>' +
        '</li>' +
        '<li class="menulink">' +
            '<a href="http://www.yahoo.com" target="_new">Yahoo</a>' +
        '</li>' +
    '</ul>' +
'</div>'
   );

    $(".mid-menu-home-section-custom").click(function(e) {

        // Verify that we aren't clicking a link
        var target = $(e.target);
        if (target.is('a')) { return; }

        var menusection = $(this).parents('.menusection');
        if (menusection.hasClass("menusection-collapsed")) {
            menusection.removeClass("menusection-collapsed");
            menusection.find('.fa.fa-chevron-up').removeClass('fa-chevron-up').addClass('fa-chevron-down').attr('title', '');
            var optsarr = {
                "keyname": "menu_collapse_options",
                "menuid": $(this).data('id'),
                "keyvalue": 1,
                "autoload": false
                };
            var opts = JSON.stringify(optsarr);
            get_ajax_data('setusermeta', opts);
        } else {
            menusection.addClass("menusection-collapsed");
            menusection.find('.fa.fa-chevron-down').removeClass('fa-chevron-down').addClass('fa-chevron-up').attr('title', '');
            var optsarr = {
                "keyname": "menu_collapse_options",
                "menuid": $(this).data('id'),
                "keyvalue": 0,
                "autoload": false
                };
            var opts = JSON.stringify(optsarr);
            get_ajax_data('setusermeta', opts);
        }
    });
});

Re: Custom include

Posted: Sat Apr 17, 2021 7:26 am
by Support_Talea
Hi,

great! it works great.
Good work and many greetings.

Regards,
-Federico

Re: Custom include

Posted: Sat Apr 17, 2021 8:39 am
by scottwilkerson
Support_Talea wrote:Hi,

great! it works great.
Good work and many greetings.

Regards,
-Federico
Locking thread