JSFiddle - React, Tailwind, and code Playground

by Ilia Lesnykh

JavaScript

(function($){
    
    //plugin's default options
    var settings = {
        prependTo: 'nav',                //insert at top of page by default
        switchWidth: 768,                //width at which to switch to select, and back again
        topOptionText: 'Выберите пункт меню:'    //default "unselected" state
    },
    
    menuCount = 0,                        //used as a unique index for each menu if no ID exists
    uniqueLinks = [];                    //used to store unique list items for combining lists
    //go to page
    function goTo(url){document.location.href = url;}
    
    //does menu exist?
    function menuExists(){return ($('.mnav').length) ? true : false;}
    //validate selector's matched list(s)
    function isList($this){
        var pass = true;
        $this.each(function(){
            if(!$(this).is('ul') && !$(this).is('ol')){
                pass=false;
            }
        });
        return pass;
    }//isList()
    //function to decide if mobile or not
    function isMobile(){return ($(document).width() < settings.switchWidth);}
    
    //function to get text value of element, but not it's children
    function getText($item){return $.trim($item.clone().children('ul, ol').remove().end().text());}
    
    //function to check if URL is unique
    function isUrlUnique(url){return ($.inArray(url, uniqueLinks) === -1) ? true : false;}
    //function to create options in the select menu
    function createOption($item, $container, text){
        //if no text param is passed, use list item's text, otherwise use settings.groupPageText
        var $selected, $disabled, $sel_text;
        
        if ($item.hasClass('current')) $selected='selected';
        if ($item.hasClass('disabled')) {
            if ($('.current').length) $disabled='disabled';
            else $disabled='selected';
        }
        
        $sel_text=$.trim(getText($item));
        $sel_text = $sel_text.replace('›', '');
        if ($item.parent('ul...