Navigation Menu

Skip to content

Commit

Permalink
Use scroll spy
Browse files Browse the repository at this point in the history
  • Loading branch information
darashi committed Aug 21, 2012
1 parent 9e39ab2 commit 3b314c8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/server.js
Expand Up @@ -78,7 +78,7 @@ app.get('/search', function(request, response, next) {
var options = {
q: request.query.query,
start: parseInt((request.query.start || '0'), 10),
size: 100,
size: 20,
facet: 'path'
};

Expand Down
2 changes: 1 addition & 1 deletion public/css/norema.css
@@ -1,5 +1,5 @@
body {
margin-top: 60px;
padding-top: 60px;
}

.search-on-top {
Expand Down
9 changes: 9 additions & 0 deletions public/js/norema.js
@@ -1,3 +1,12 @@
$(document).ready(function($) {
var offset = 50;

$('#query').focus();

// scroll spy
$('.side-nav li a').click(function(event) {
event.preventDefault();
$($(this).attr('href'))[0].scrollIntoView();
scrollBy(0, -offset);
});
});
2 changes: 1 addition & 1 deletion views/layout.jade
Expand Up @@ -8,7 +8,7 @@ html
script(src="/js/bootstrap.min.js", type="text/javascript")
script(src="/js/norema.js", type="text/javascript")

body
body('data-spy'='scroll', 'data-target'='.side-nav', 'data-offset'='60')
.navbar.navbar-fixed-top
.navbar-inner
.container
Expand Down
11 changes: 9 additions & 2 deletions views/search.jade
Expand Up @@ -24,7 +24,7 @@ block content
if records.length > 0
include pager
each record, index in records
.record
section.record(id=record.id)
h2
a(href="http://nodejs.org/docs/latest/api/all.html#all_"+titleToId(record.data.title), target="_blank")= record.data.title
p.path
Expand All @@ -39,7 +39,7 @@ block content
include pager

.span3
.side-nav('data-spy'='affix')
.side-nav('data-spy'='affix', style='width: 220px;')
if pathFacets.length > 0
.well(style="padding: 8px 0;")
ul.nav.nav-list
Expand All @@ -49,3 +49,10 @@ block content
= facet.value
|
span.badge.badge-info= facet.count
if records.length > 0
.well(style="padding: 8px 0;")
ul.nav.nav-list
each record, index in records
li
a(href='#'+record.id)
= record.data.title

0 comments on commit 3b314c8

Please sign in to comment.