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
0a8c73ad
Commit
0a8c73ad
authored
Jun 22, 2014
by
Tariq Islam
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #78 from tripit/dev
Fix scrolling bugs, history bugs, and add search minimum score to display
parents
0eb4caa4
b363be87
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
30 deletions
+45
-30
README.md
README.md
+1
-0
lang.js
source/javascripts/app/lang.js
+20
-16
search.js
source/javascripts/app/search.js
+3
-8
jquery.tocify.js
source/javascripts/lib/jquery.tocify.js
+16
-1
screen.css.scss
source/stylesheets/screen.css.scss
+5
-5
No files found.
README.md
View file @
0a8c73ad
...
@@ -59,6 +59,7 @@ Examples of Slate in the Wild
...
@@ -59,6 +59,7 @@ Examples of Slate in the Wild
*
[
ChaiOne Gameplan API docs
](
http://chaione.github.io/gameplanb2b/#introduction
)
*
[
ChaiOne Gameplan API docs
](
http://chaione.github.io/gameplanb2b/#introduction
)
*
[
Drcaban's Build a Quine tutorial
](
http://drcabana.github.io/build-a-quine/#introduction
)
*
[
Drcaban's Build a Quine tutorial
](
http://drcabana.github.io/build-a-quine/#introduction
)
*
[
PricePlow API docs
](
https://www.priceplow.com/api/documentation
)
*
[
PricePlow API docs
](
https://www.priceplow.com/api/documentation
)
*
[
Emerging Threats API docs
](
http://apidocs.emergingthreats.net/
)
(Feel free to add your site to this list in a pull request!)
(Feel free to add your site to this list in a pull request!)
...
...
source/javascripts/app/lang.js
View file @
0a8c73ad
...
@@ -20,12 +20,27 @@ under the License.
...
@@ -20,12 +20,27 @@ under the License.
global
.
activateLanguage
=
activateLanguage
;
global
.
activateLanguage
=
activateLanguage
;
function
activateLanguage
(
language
)
{
function
activateLanguage
(
language
)
{
if
(
!
language
)
return
;
$
(
"#lang-selector a"
).
removeClass
(
'active'
);
$
(
"#lang-selector a"
).
removeClass
(
'active'
);
$
(
"#lang-selector a[data-language-name='"
+
language
+
"']"
).
addClass
(
'active'
);
$
(
"#lang-selector a[data-language-name='"
+
language
+
"']"
).
addClass
(
'active'
);
for
(
var
i
=
0
;
i
<
languages
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
languages
.
length
;
i
++
)
{
$
(
".highlight."
+
languages
[
i
]).
hide
();
$
(
".highlight."
+
languages
[
i
]).
hide
();
}
}
$
(
".highlight."
+
language
).
show
();
$
(
".highlight."
+
language
).
show
();
// scroll to the new location of the position
$
(
window
.
location
.
hash
).
get
(
0
).
scrollIntoView
(
true
);
}
// if a button is clicked, add the state to the history
function
pushURL
(
language
)
{
if
(
!
history
)
{
return
;
}
var
hash
=
window
.
location
.
hash
;
if
(
hash
)
{
hash
=
hash
.
replace
(
/^#+/
,
''
);
}
history
.
pushState
({},
''
,
'?'
+
language
+
'#'
+
hash
);
}
}
function
setupLanguages
(
l
)
{
function
setupLanguages
(
l
)
{
...
@@ -33,8 +48,8 @@ under the License.
...
@@ -33,8 +48,8 @@ under the License.
var
defaultLanguage
=
localStorage
.
getItem
(
"language"
);
var
defaultLanguage
=
localStorage
.
getItem
(
"language"
);
languages
=
l
;
languages
=
l
;
if
((
location
.
search
.
substr
(
1
)
!=
""
)
&&
(
jQuery
.
inArray
(
location
.
search
.
substr
(
1
),
languages
))
!=
-
1
)
{
if
((
location
.
search
.
substr
(
1
)
!=
=
""
)
&&
(
jQuery
.
inArray
(
location
.
search
.
substr
(
1
),
languages
))
!=
-
1
)
{
// the language is in the URL, so use that language!
// the language is in the URL, so use that language!
activateLanguage
(
location
.
search
.
substr
(
1
));
activateLanguage
(
location
.
search
.
substr
(
1
));
...
@@ -47,25 +62,14 @@ under the License.
...
@@ -47,25 +62,14 @@ under the License.
// no language selected, so use the default
// no language selected, so use the default
activateLanguage
(
languages
[
0
]);
activateLanguage
(
languages
[
0
]);
}
}
// if we click on a language tab, reload the page with that language in the URL
$
(
"#lang-selector a"
).
bind
(
"click"
,
function
()
{
window
.
location
.
replace
(
"?"
+
$
(
this
).
data
(
"language-name"
)
+
window
.
location
.
hash
);
return
false
;
});
}
}
// if we click on a language tab, activate that language
// if we click on a language tab, activate that language
$
(
function
()
{
$
(
function
()
{
$
(
"#lang-selector a"
).
on
(
"click"
,
function
()
{
$
(
"#lang-selector a"
).
on
(
"click"
,
function
()
{
var
lang
=
$
(
this
).
data
(
"language-name"
);
var
language
=
$
(
this
).
data
(
"language-name"
);
var
hash
=
window
.
location
.
hash
;
pushURL
(
language
);
if
(
hash
)
hash
=
hash
.
replace
(
/^#+/
,
''
);
activateLanguage
(
language
);
// do not reload the page every time the language is changed
if
(
history
)
history
.
pushState
({},
''
,
'?'
+
lang
+
'#'
+
hash
);
activateLanguage
(
lang
);
return
false
;
return
false
;
});
});
window
.
onpopstate
=
function
(
event
)
{
window
.
onpopstate
=
function
(
event
)
{
...
...
source/javascripts/app/search.js
View file @
0a8c73ad
...
@@ -71,18 +71,13 @@
...
@@ -71,18 +71,13 @@
if
(
this
.
value
)
{
if
(
this
.
value
)
{
sections
.
hide
();
sections
.
hide
();
// results are sorted by score in descending order
// results are sorted by score in descending order
var
tmpResults
=
index
.
search
(
this
.
value
);
var
results
=
index
.
search
(
this
.
value
);
var
results
=
[];
// remove low score matches
$
.
each
(
tmpResults
,
function
(
index
,
item
)
{
if
(
item
.
score
>=
0.0001
)
results
.
push
(
item
);
});
if
(
results
.
length
)
{
if
(
results
.
length
)
{
lastRef
=
null
;
resetHeaderLocations
();
resetHeaderLocations
();
var
lastRef
;
$
.
each
(
results
,
function
(
index
,
item
)
{
$
.
each
(
results
,
function
(
index
,
item
)
{
if
(
item
.
score
<=
0.0001
)
return
;
// remove low-score results
var
itemRef
=
item
.
ref
;
var
itemRef
=
item
.
ref
;
$
(
'#section-'
+
itemRef
).
show
();
$
(
'#section-'
+
itemRef
).
show
();
// headers must be repositioned in the DOM
// headers must be repositioned in the DOM
...
...
source/javascripts/lib/jquery.tocify.js
View file @
0a8c73ad
...
@@ -147,6 +147,7 @@
...
@@ -147,6 +147,7 @@
var
self
=
this
;
var
self
=
this
;
self
.
tocifyWrapper
=
$
(
'.tocify-wrapper'
);
self
.
extendPageScroll
=
true
;
self
.
extendPageScroll
=
true
;
// Internal array that keeps track of all TOC items (Helps to recognize if there are duplicate TOC item strings)
// Internal array that keeps track of all TOC items (Helps to recognize if there are duplicate TOC item strings)
...
@@ -703,6 +704,20 @@
...
@@ -703,6 +704,20 @@
// Highlights the corresponding list item
// Highlights the corresponding list item
elem
.
addClass
(
self
.
focusClass
);
elem
.
addClass
(
self
.
focusClass
);
// Scroll to highlighted element's header
var
tocifyWrapper
=
self
.
tocifyWrapper
;
var
scrollToElem
=
$
(
elem
).
closest
(
'.tocify-header'
);
var
elementOffset
=
scrollToElem
.
offset
().
top
,
wrapperOffset
=
tocifyWrapper
.
offset
().
top
;
var
offset
=
elementOffset
-
wrapperOffset
;
if
(
offset
>=
$
(
window
).
height
())
{
var
scrollPosition
=
offset
+
tocifyWrapper
.
scrollTop
();
tocifyWrapper
.
scrollTop
(
scrollPosition
);
}
else
if
(
offset
<
0
)
{
tocifyWrapper
.
scrollTop
(
0
);
}
}
}
if
(
self
.
options
.
scrollHistory
)
{
if
(
self
.
options
.
scrollHistory
)
{
...
@@ -1021,4 +1036,4 @@
...
@@ -1021,4 +1036,4 @@
});
});
}));
//end of plugin
}));
//end of plugin
\ No newline at end of file
source/stylesheets/screen.css.scss
View file @
0a8c73ad
...
@@ -226,15 +226,15 @@ html, body {
...
@@ -226,15 +226,15 @@ html, body {
padding
:
0
10px
;
padding
:
0
10px
;
line-height
:
30px
;
line-height
:
30px
;
&
.active
{
background-color
:
$lang-select-active-bg
;
color
:
$lang-select-active-text
;
}
&
:active
{
&
:active
{
background-color
:
$lang-select-pressed-bg
;
background-color
:
$lang-select-pressed-bg
;
color
:
$lang-select-pressed-text
;
color
:
$lang-select-pressed-text
;
}
}
&
.active
{
background-color
:
$lang-select-active-bg
;
color
:
$lang-select-active-text
;
}
}
}
&
:after
{
&
:after
{
...
...
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