Browse Source

Add dpop-down menu

First item of the same section is drop-down
pull/22/head
sim2github 11 years ago
parent
commit
359e24376e
2 changed files with 27 additions and 2 deletions
  1. +10
    -1
      static/css/style.css
  2. +17
    -1
      static/js/main.js

+ 10
- 1
static/css/style.css View File

@ -77,7 +77,16 @@ h4.author { font-size:14px; margin-bottom:5px; font-style:italic; }
#menu-toggle-handle .icon-bar { display: block; margin:auto; width:22px; height:2px; background-color:#fff; border-radius:1px; } #menu-toggle-handle .icon-bar { display: block; margin:auto; width:22px; height:2px; background-color:#fff; border-radius:1px; }
#menu-toggle-handle .icon-bar + .icon-bar { margin-top:4px; } #menu-toggle-handle .icon-bar + .icon-bar { margin-top:4px; }
.dropdown-menu .glyphicon { padding-right:5px; }
.dropdown-menu .glyphicon { padding-right:5px; }
/* Pills dropdown*/
ul.nav.nav-pills li.dropdown:hover ul.dropdown-menu{
display: block;
}
ul.nav.nav-pills .dropdown-menu {
margin-top: 1px;
}
a.rss { padding-left:23px; background:url(../img/rss.png) no-repeat left; } a.rss { padding-left:23px; background:url(../img/rss.png) no-repeat left; }
a.pdf { padding-left:23px; background-image:url(../img/pdf.png); background-repeat:no-repeat; background-position: top left; } a.pdf { padding-left:23px; background-image:url(../img/pdf.png); background-repeat:no-repeat; background-position: top left; }


+ 17
- 1
static/js/main.js View File

@ -1,5 +1,21 @@
$(function() { $(function() {
$("#menu-toggle-handle").click(function(e) { $('#nav').slideToggle('fast'); });
$('#menu-toggle-handle').click(function(e) { $('#nav').slideToggle('fast'); });
$('ul.nav.nav-pills > li').each(
function(){
var _sameSection = $('li[data-section*="'+$(this).data('section')+'"]');
if(_sameSection.length > 1 && !_sameSection.hasClass('dropdown')){
_sameSection.first().addClass('dropdown')
.find('a:first')
.append('<span class="caret"></span>');
_sameSection.first().append(_sameSection.not(':first'));
_sameSection.not(':first').removeClass('active')
.wrapAll('<ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>');
}
}
);
}); });

Loading…
Cancel
Save