Skip to content
Snippets Groups Projects
Commit c970b658 authored by khawkins98's avatar khawkins98
Browse files

Add utility functions

parent 385453d8
No related branches found
No related tags found
No related merge requests found
// 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, " "));
}
/**
* 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;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment