Skip to content

use own menu button #76

Open
Open
@toneffectory

Description

@toneffectory

I added a bit of code to be able to use my own menu button. Might be worth adding as parameter?

I added a settings parameter called menuButton which defaults to ''.
Next added this (from line 83 onwards):

        if (settings.menuButton === '') {
            $this.btn = $(
                ['<' + settings.parentTag + ' aria-haspopup="true" tabindex="0" class="' + prefix + '_btn ' + prefix + '_collapsed">',
                    '<span class="' + prefix + '_menutxt">' + settings.label + '</span>',
                    '<span class="' + iconClass + '">',
                    '<span class="' + prefix + '_icon-bar"></span>',
                    '<span class="' + prefix + '_icon-bar"></span>',
                    '<span class="' + prefix + '_icon-bar"></span>',
                    '</span>',
                    '</' + settings.parentTag + '>'
                ].join('')
            );
        }
        else {
            $this.btn = $(settings.menuButton);
        }

Obviously this would require the user to add an element that will be used as menubutton:
<a id="menuButton" class="slicknav_btn slicknav_collapsed" tabindex="0" aria-haspopup="true" href="#" style="outline: medium none;">click here</a>

The new menu button is finally attached to slicknav by:

$('#menu').slicknav({
        menuButton: '#menuButton'
});

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions