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
b363be87
Commit
b363be87
authored
Jun 12, 2014
by
Robert Lord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update language tabs to properly stay in section, and fix history navigation bug
parent
7dead4c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
lang.js
source/javascripts/app/lang.js
+14
-5
No files found.
source/javascripts/app/lang.js
View file @
b363be87
...
...
@@ -22,17 +22,25 @@ under the License.
function
activateLanguage
(
language
)
{
if
(
!
language
)
return
;
var
hash
=
window
.
location
.
hash
;
if
(
hash
)
hash
=
hash
.
replace
(
/^#+/
,
''
);
// do not reload the page every time the language is changed
if
(
history
)
history
.
pushState
({},
''
,
'?'
+
language
+
'#'
+
hash
);
$
(
"#lang-selector a"
).
removeClass
(
'active'
);
$
(
"#lang-selector a[data-language-name='"
+
language
+
"']"
).
addClass
(
'active'
);
for
(
var
i
=
0
;
i
<
languages
.
length
;
i
++
)
{
$
(
".highlight."
+
languages
[
i
]).
hide
();
}
$
(
".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
)
{
...
...
@@ -60,6 +68,7 @@ under the License.
$
(
function
()
{
$
(
"#lang-selector a"
).
on
(
"click"
,
function
()
{
var
language
=
$
(
this
).
data
(
"language-name"
);
pushURL
(
language
);
activateLanguage
(
language
);
return
false
;
});
...
...
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