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
0f93ffcc
Commit
0f93ffcc
authored
Jun 22, 2014
by
Robert Lord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More js cleanup for #80
parent
bdbd7a38
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
search.js
source/javascripts/app/search.js
+11
-11
No files found.
source/javascripts/app/search.js
View file @
0f93ffcc
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
$
(
populate
);
$
(
populate
);
$
(
bind
);
$
(
bind
);
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'
);
var
wrapper
=
$
(
'<section id="section-'
+
title
.
prop
(
'id'
)
+
'"></section>'
);
var
wrapper
=
$
(
'<section id="section-'
+
title
.
prop
(
'id'
)
+
'"></section>'
);
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
});
});
}
}
function
bind
()
{
function
bind
()
{
content
=
$
(
'.content'
);
content
=
$
(
'.content'
);
darkBox
=
$
(
'.dark-box'
);
darkBox
=
$
(
'.dark-box'
);
searchInfo
=
$
(
'.search-info'
);
searchInfo
=
$
(
'.search-info'
);
...
@@ -42,24 +42,24 @@
...
@@ -42,24 +42,24 @@
.
on
(
'blur'
,
inactive
);
.
on
(
'blur'
,
inactive
);
}
}
function
refToHeader
(
itemRef
)
{
function
refToHeader
(
itemRef
)
{
return
$
(
'.tocify-item[data-unique='
+
itemRef
+
']'
).
closest
(
'.tocify-header'
);
return
$
(
'.tocify-item[data-unique='
+
itemRef
+
']'
).
closest
(
'.tocify-header'
);
}
}
function
sortDescending
(
obj2
,
obj1
)
{
function
sortDescending
(
obj2
,
obj1
)
{
var
s1
=
parseInt
(
obj1
.
id
.
replace
(
/
[^\d]
/g
,
''
),
10
);
var
s1
=
parseInt
(
obj1
.
id
.
replace
(
/
[^\d]
/g
,
''
),
10
);
var
s2
=
parseInt
(
obj2
.
id
.
replace
(
/
[^\d]
/g
,
''
),
10
);
var
s2
=
parseInt
(
obj2
.
id
.
replace
(
/
[^\d]
/g
,
''
),
10
);
return
s1
===
s2
?
0
:
s1
<
s2
?
-
1
:
1
;
return
s1
===
s2
?
0
:
s1
<
s2
?
-
1
:
1
;
}
}
function
resetHeaderLocations
()
{
function
resetHeaderLocations
()
{
var
headers
=
$
(
".tocify-header"
).
sort
(
sortDescending
);
var
headers
=
$
(
".tocify-header"
).
sort
(
sortDescending
);
$
.
each
(
headers
,
function
(
index
,
item
)
{
$
.
each
(
headers
,
function
(
index
,
item
)
{
$
(
item
).
insertBefore
(
$
(
"#toc ul:first-child"
));
$
(
item
).
insertBefore
(
$
(
"#toc ul:first-child"
));
});
});
}
}
function
search
(
event
)
{
function
search
(
event
)
{
var
sections
=
$
(
'section, #toc .tocify-header'
);
var
sections
=
$
(
'section, #toc .tocify-header'
);
searchInfo
.
hide
();
searchInfo
.
hide
();
...
@@ -110,20 +110,20 @@
...
@@ -110,20 +110,20 @@
$global
.
triggerHandler
(
'resize'
);
$global
.
triggerHandler
(
'resize'
);
}
}
function
active
()
{
function
active
()
{
search
.
call
(
this
,
{});
search
.
call
(
this
,
{});
}
}
function
inactive
()
{
function
inactive
()
{
unhighlight
();
unhighlight
();
searchInfo
.
hide
();
searchInfo
.
hide
();
}
}
function
highlight
()
{
function
highlight
()
{
if
(
this
.
value
)
content
.
highlight
(
this
.
value
,
highlightOpts
);
if
(
this
.
value
)
content
.
highlight
(
this
.
value
,
highlightOpts
);
}
}
function
unhighlight
()
{
function
unhighlight
()
{
content
.
unhighlight
(
highlightOpts
);
content
.
unhighlight
(
highlightOpts
);
}
}
...
...
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