Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
node-slate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nguyễn Hải Sơn
node-slate
Commits
e669a0d4
Commit
e669a0d4
authored
Apr 10, 2014
by
Christopher Rogers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds rudimentary search support
Signed-off-by:
Christopher Rogers
<
chrissrogers@gmail.com
>
parent
d1b98be1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
166 additions
and
162 deletions
+166
-162
search.js
source/javascripts/app/search.js
+26
-22
screen.css.scss
source/stylesheets/screen.css.scss
+140
-140
No files found.
source/javascripts/app/search.js
View file @
e669a0d4
(
function
(
global
)
{
window
.
topic
=
topic
;
var
index
=
lunr
(
function
()
{
this
.
ref
(
'id'
);
this
.
field
(
'title'
,
{
boost
:
10
});
this
.
field
(
'tags'
,
{
boost
:
100
});
//
this.field('tags', { boost: 100 });
this
.
field
(
'body'
);
this
.
ref
(
'id'
);
});
$
(
bindSearch
);
$
(
populate
);
$
(
bind
);
function
populate
()
{
$
(
'h1'
).
each
(
function
()
{
var
title
=
$
(
this
);
var
body
=
title
.
nextUntil
(
'h1'
);
var
wrapper
=
$
(
'<section id="section-'
+
title
.
prop
(
'id'
)
+
'"></section>'
);
title
.
after
(
wrapper
.
append
(
body
));
wrapper
.
prepend
(
title
);
index
.
add
({
id
:
title
.
prop
(
'id'
),
title
:
title
.
text
(),
// tags: tags,
body
:
body
.
text
()
});
});
}
function
bind
Search
()
{
function
bind
()
{
$
(
'#search'
).
on
(
'keyup'
,
function
()
{
if
(
this
.
value
)
{
var
items
=
index
.
search
(
this
.
value
);
$
(
'
article, nav li
'
).
hide
();
$
(
'
section, #toc .tocify-item
'
).
hide
();
items
.
forEach
(
function
(
item
)
{
$
(
'#
'
+
item
.
ref
+
', #'
+
item
.
ref
+
'-nav'
).
show
();
$
(
'#
section-'
+
item
.
ref
+
', .tocify-item[data-unique='
+
item
.
ref
).
show
();
});
}
else
{
$
(
'article, nav li'
).
show
();
}
});
$
(
'form'
).
on
(
'submit'
,
function
(
event
)
{
event
.
preventDefault
();
});
$
(
'section, #toc .tocify-item'
).
show
();
}
function
topic
(
title
,
tags
,
handle
)
{
index
.
add
({
id
:
handle
,
title
:
title
,
tags
:
tags
,
body
:
$
(
'#'
+
handle
+
'-body'
).
text
()
});
}
...
...
source/stylesheets/screen.css.scss
View file @
e669a0d4
...
...
@@ -213,7 +213,7 @@ html, body {
position
:
relative
;
z-index
:
30
;
section
{
&
>
h1
,
&
>
h2
,
&
>
h3
,
&
>
p
,
&
>
table
,
&
>
ul
,
&
>
ol
,
&
>
aside
,
&
>
dl
{
margin-right
:
$examples-width
;
padding
:
0
$main-padding
;
...
...
@@ -384,7 +384,7 @@ html, body {
aside
.success
:before
{
@extend
%icon-ok-sign
;
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment