Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EBI-Framework
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ebiwd
EBI-Framework
Commits
c970b658
Commit
c970b658
authored
7 years ago
by
khawkins98
Browse files
Options
Downloads
Patches
Plain Diff
Add utility functions
parent
385453d8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/ebi-global-includes/script/1_about.js
+21
-1
21 additions, 1 deletion
js/ebi-global-includes/script/1_about.js
js/ebi-global-includes/script/4_ebiFrameworkContent.js
+14
-2
14 additions, 2 deletions
js/ebi-global-includes/script/4_ebiFrameworkContent.js
with
35 additions
and
3 deletions
js/ebi-global-includes/script/1_about.js
+
21
−
1
View file @
c970b658
// Copyright (c) EMBL-EBI 2017
// Copyright (c) EMBL-EBI 2017
// Do not edit this file directly.
// It is made by concating .js files with by npm into script.js.
// Source files: js/ebi-css-build/script/*.js
/**
* Utility function to get params from the URL.
*
* @param {string} name The string to look for
* @param {string} [url=browserURL] Optionally pass a specific URL to parse
*
* @example
* query string: ?foo=lorem&bar=&baz
* var foo = getParameterByName('foo'); // "lorem"
*/
function
ebiGetParameterByName
(
name
,
url
)
{
if
(
!
url
)
url
=
window
.
location
.
href
;
name
=
name
.
replace
(
/
[\[\]]
/g
,
"
\\
$&
"
);
var
regex
=
new
RegExp
(
"
[?&]
"
+
name
+
"
(=([^&#]*)|&|#|$)
"
),
results
=
regex
.
exec
(
url
);
if
(
!
results
)
return
null
;
if
(
!
results
[
2
])
return
''
;
return
decodeURIComponent
(
results
[
2
].
replace
(
/
\+
/g
,
"
"
));
}
This diff is collapsed.
Click to expand it.
js/ebi-global-includes/script/4_ebiFrameworkContent.js
+
14
−
2
View file @
c970b658
/**
* Utility function to toggle classes. Chiefly to show the #embl-bar.
*/
function
ebiToggleClass
(
element
,
toggleClass
){
var
currentClass
=
element
.
className
;
var
newClass
;
if
(
currentClass
.
split
(
"
"
).
indexOf
(
toggleClass
)
>
-
1
){
// has class
newClass
=
currentClass
.
replace
(
new
RegExp
(
'
\\
b
'
+
toggleClass
+
'
\\
b
'
,
'
g
'
),
""
)
}
else
{
newClass
=
currentClass
+
"
"
+
toggleClass
;
}
element
.
className
=
newClass
.
trim
();
}
/**
* Remove global-nav/global-nav-expanded from header/footer if body.no-global-nav is set
*/
function
ebiFrameworkHideGlobalNav
()
{
//
//
try
{
var
hasGlobalMasthead
=
document
.
getElementById
(
'
masthead-black-bar
'
)
!==
null
;
var
disabled
=
document
.
body
.
className
.
indexOf
(
'
no-global-nav
'
)
!==
-
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment