JSFiddle - React, Tailwind, and code Playground

by Сергей Тарасевич

HTML

<ul class="anyClass2 skinPlank">
    <li>
        <a href="http://jsfiddle.net/D0Gmatist/8NdQN/181/">Very long link</a>
        <a href="#"></a>
        <ul>
            <li><a href="#">Clickable link One</a>
            </li>
            <li><a href="#">Clickable link Two</a>
            </li>
            <li><a href="#">Clickable link Three</a>
            </li>
            <li><a href="#">Clickable link Four</a>
            </li>
            <li><a href="#">Clickable link Five</a>
            </li>
        </ul>
    </li>
    <li>
        <a href="http://jsfiddle.net/D0Gmatist/8NdQN/181/">Very long link</a>
        <a href="#"></a>
        <ul>
            <li><a href="#">Clickable link One</a>
            </li>
            <li><a href="#">Clickable link Two</a>
            </li>
            <li><a href="#">Clickable link Three</a>
            </li>
            <li><a href="#">Clickable link Four</a>
            </li>
        </ul>
    </li>
</ul>

CSS

/*layout css*/
 body, html {
    min-height:100%;
    padding:0;
    margin:0
}
body {
    font:12px/1.2em Arial, Helvetica, sans-serif;
    color:#999;
    padding:0 100px;
    margin:0;
}
+
/*plugin css*/

/*skin Plank [.skinPlank]*/
 .skinPlank, .skinPlank ul {
    margin:0;
    padding:0;
    list-style:none;
}
.skinPlank ul {
    display:none;
    //zoom:1
}
.skinPlank li {
    list-style: none;
    padding: 0;
    margin: 0;
    display: block;
    font-size: 0;
    //zoom:1;
}
.skinPlank a {
    font: 12px/1.2em Arial, Helvetica, sans-serif;
    color: #fff;
    background: #7F7F7F;
    padding: 4px 8px;
    display: inline-block;
    text-decoration: none;
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    -ms-transition: all 0.3s ease;
    transition: all 0.3s ease;
    position: relative;
}
.skinPlank a:hover {
    background:#5c5c5c
}
.skinPlank ul li {
    border-top:1px solid #ccc;
}
.skinPlank ul a {
    font: 12px/1.2em Arial, Helvetica, sans-serif;
    color: #808080;
    padding: 3px 8px;
    background: #E5E8EB;
    box-shadow: none;
    display: block;
    text-decoration: none;
}
.skinPlank ul a:hover {
    background: #CED3D9;
    text-decoration: underline;
}
.skinPlank a.harFull {
    vertical-align: top;
    height: 14px;
    width: 6px;
}
.skinPlank a.harOpen.harFull {
    background: #5c5c5c;
}
.skinPlank a.harFull:before {
    //zoom:1;
    content:'';
    width: 0;
    height: 0;
    border: 0;
    border-top: 4px solid transparent;
    border-left: 5px solid #fff;
    border-bottom: 4px solid transparent;
    display: block;
    margin: 0;
    position: absolute;
    top: 7px;
    right: 8px;
}
.skinPlank a.harOpen.harFull:before {
    border-right: 4px solid transparent;
    border-top: 5px solid #fff;
    border-left: 4px solid transparent;
    top: 9px;
    right: 7px;
}
.skinPlank ul a.harFull:before {
    //zoom:1;
    content:'';
    border-left-color: #7d7d7d;
   ...

JavaScript

/*Код плагина*/
(function ($) {
    $.fn.liHarmonica = function (params) {
        var p = $.extend({
            currentClass: 'cur', //Класс для выделенного пункта меню
            onlyOne: true, //true - открытым может быть только один пункт, 
            //false - число открытых одновременно пунктов не ограничено
            speed: 500 //Скорость анимации
        }, params);
        return this.each(function () {
            var
            el = $(this).addClass('harmonica'),
                linkItem = $('ul', el).prev('a');
            el.children(':last').addClass('last');
            $('ul', el).each(function () {
                $(this).children(':last').addClass('last');
            });
            $('ul', el).prev('a').addClass('harFull');
            el.find('.' + p.currentClass).parents('ul').show().prev('a').addClass(p.currentClass).addClass('harOpen');
            linkItem.on('click', function () {
                if ($(this).next('ul').is(':hidden')) {
                    $(this).addClass('harOpen');
                } else {
                    $(this).removeClass('harOpen');
                }
                if (p.onlyOne) {
                    $(this).closest('ul').closest('ul').find('ul').not($(this).next('ul')).slideUp(p.speed).prev('a').removeClass('harOpen');
                    $(this).next('ul').slideToggle(p.speed);
                } else {
                    $(this).next('ul').stop(true).slideToggle(p.speed);
                }
                return false;
            });
        });
    };
})(jQuery);

/*Инициализация плагина*/
$(function () {
    $('.anyClass').liHarmonica({
        onlyOne: false,
        speed: 500
    });
    $('.anyClass2').liHarmonica({
        onlyOne: true,
        speed: 400
    });
});