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
535a3b04
Commit
535a3b04
authored
Apr 12, 2014
by
Christopher Rogers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds 'no results found' message to search
Signed-off-by:
Christopher Rogers
<
chrissrogers@gmail.com
>
parent
5892700b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
12 deletions
+50
-12
search.js
source/javascripts/app/search.js
+21
-9
layout.erb
source/layouts/layout.erb
+6
-1
screen.css.scss
source/stylesheets/screen.css.scss
+23
-2
No files found.
source/javascripts/app/search.js
View file @
535a3b04
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
function
populate
()
{
function
populate
()
{
$
(
'h1'
).
each
(
function
()
{
$
(
'h1'
).
each
(
function
()
{
var
title
=
$
(
this
);
var
title
=
$
(
this
);
var
body
=
title
.
nextUntil
(
'h1'
);
var
body
=
title
.
nextUntil
(
'h1
, .search-nothing-found
'
);
var
wrapper
=
$
(
'<section id="section-'
+
title
.
prop
(
'id'
)
+
'"></section>'
);
var
wrapper
=
$
(
'<section id="section-'
+
title
.
prop
(
'id'
)
+
'"></section>'
);
title
.
after
(
wrapper
.
append
(
body
));
title
.
after
(
wrapper
.
append
(
body
));
...
@@ -33,18 +33,30 @@
...
@@ -33,18 +33,30 @@
$
(
'#input-search'
).
on
(
'keyup'
,
search
);
$
(
'#input-search'
).
on
(
'keyup'
,
search
);
}
}
function
search
()
{
function
search
(
event
)
{
var
sections
=
$
(
'section, #toc .tocify-header'
);
var
$sections
=
$
(
'section, #toc .tocify-header'
);
var
$content
=
$
(
'.content'
);
var
opts
=
{
element
:
'span'
,
className
:
'search-highlight'
};
$content
.
unhighlight
(
opts
);
// esc clears the field
if
(
event
.
keyCode
===
27
)
this
.
value
=
''
;
if
(
this
.
value
)
{
if
(
this
.
value
)
{
var
items
=
index
.
search
(
this
.
value
);
var
items
=
index
.
search
(
this
.
value
);
sections
.
hide
();
$sections
.
hide
();
if
(
items
.
length
)
{
items
.
forEach
(
function
(
item
)
{
items
.
forEach
(
function
(
item
)
{
$
(
'#section-'
+
item
.
ref
).
show
();
$
(
'#section-'
+
item
.
ref
).
show
();
$
(
'.tocify-item[data-unique='
+
item
.
ref
+
']'
).
closest
(
'.tocify-header'
).
show
();
$
(
'.tocify-item[data-unique='
+
item
.
ref
+
']'
).
closest
(
'.tocify-header'
).
show
();
});
});
$content
.
highlight
(
this
.
value
,
opts
);
}
else
{
$sections
.
filter
(
'.search-nothing-found'
).
show
();
}
}
else
{
}
else
{
sections
.
show
();
$
sections
.
show
();
}
}
// HACK trigger tocify height recalculation
// HACK trigger tocify height recalculation
...
...
source/layouts/layout.erb
View file @
535a3b04
...
@@ -23,7 +23,7 @@ under the License.
...
@@ -23,7 +23,7 @@ under the License.
<%=
stylesheet_link_tag
:screen
,
media: :screen
%>
<%=
stylesheet_link_tag
:screen
,
media: :screen
%>
<%=
stylesheet_link_tag
:print
,
media: :print
%>
<%=
stylesheet_link_tag
:print
,
media: :print
%>
<script
src=
"https://code.jquery.com/j
query-1.10.1
.min.js"
></script>
<script
src=
"https://code.jquery.com/j
avascripts/jquery-1.11.0
.min.js"
></script>
<%=
javascript_include_tag
"all"
%>
<%=
javascript_include_tag
"all"
%>
<%
if
language_tabs
%>
<%
if
language_tabs
%>
...
@@ -57,6 +57,11 @@ under the License.
...
@@ -57,6 +57,11 @@ under the License.
<%
current_page
.
data
.
includes
&&
current_page
.
data
.
includes
.
each
do
|
include
|
%>
<%
current_page
.
data
.
includes
&&
current_page
.
data
.
includes
.
each
do
|
include
|
%>
<%=
partial
"includes/
#{
include
}
"
%>
<%=
partial
"includes/
#{
include
}
"
%>
<%
end
%>
<%
end
%>
<section
class=
"search-nothing-found"
>
<aside
class=
"search-info"
>
No results found
</aside>
</section>
</div>
</div>
<div
class=
"dark-box"
>
<div
class=
"dark-box"
>
<%
if
language_tabs
%>
<%
if
language_tabs
%>
...
...
source/stylesheets/screen.css.scss
View file @
535a3b04
...
@@ -33,10 +33,16 @@ html, body {
...
@@ -33,10 +33,16 @@ html, body {
-moz-osx-font-smoothing
:
grayscale
;
-moz-osx-font-smoothing
:
grayscale
;
@extend
%default-font
;
@extend
%default-font
;
background-color
:
$main-bg
;
background-color
:
$main-bg
;
height
:
100%
;
}
}
.highlight
{
.search-highlight
{
background-color
:
#FFFF88
;
background-image
:
linear-gradient
(
to
bottom
right
,
#F7E633
0%
,
#F1D32F
100%
);
padding
:
2px
;
margin
:
-2px
;
border-radius
:
4px
;
border
:
1px
solid
#F7E633
;
text-shadow
:
1px
1px
0
#666
;
}
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
...
@@ -180,6 +186,7 @@ html, body {
...
@@ -180,6 +186,7 @@ html, body {
position
:
relative
;
position
:
relative
;
z-index
:
10
;
z-index
:
10
;
background-color
:
$main-bg
;
background-color
:
$main-bg
;
min-height
:
100%
;
padding-bottom
:
1px
;
// prevent margin overflow
padding-bottom
:
1px
;
// prevent margin overflow
...
@@ -412,6 +419,20 @@ html, body {
...
@@ -412,6 +419,20 @@ html, body {
aside
.success
:before
{
aside
.success
:before
{
@extend
%icon-ok-sign
;
@extend
%icon-ok-sign
;
}
}
aside
.search-info
{
font-size
:
1
.2em
;
margin-top
:
0
;
height
:
52px
;
&
:before
{
@extend
%icon-search
;
font-size
:
1
.2em
;
}
}
.search-nothing-found
{
display
:
none
;
}
}
}
}
}
...
...
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