").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cd=a.document.documentElement;function dd(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dd(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cd;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cd})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dd(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=Lb(k.pixelPosition,function(a,c){return c?(c=Jb(a,b),Hb.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ed=a.jQuery,fd=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fd),b&&a.jQuery===m&&(a.jQuery=ed),m},typeof b===K&&(a.jQuery=a.$=m),m});
}
// Utility functions
// =================
function timeSplit(time) {
var split = time.toString().split('.'),
days = 0,
hr = 0;
split.forEach(function (val, ind) {
if (val.length === 0) {
val = 0;
}
if (ind === 0) {
days = parseInt(val);
} else {
hr = parseInt(val);
}
});
return (days * 24) + hr;
}
function setStorage(name, data, expiry, useCookie) {
'use strict';
///
/// Set given data in storage with either cookies or localStorage
///
///
///
/// Number of days and hours before expiry e.g. 1.12 for 1 day 12 hours
///
if (!useCookie && 'localStorage' in window && window.localStorage !== null) {
window.localStorage.setItem(name, data);
} else {
var exdate = new Date();
if (expiry !== null) {
var time = timeSplit(expiry);
exdate.setHours(exdate.getHours() + time);
}
var c_value = encodeURIComponent(data) + ((expiry === null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = name + "=" + c_value + ";path=/";
}
return true;
}
function getStorage(name, useCookie) {
'use strict';
///
/// Gets requested data from either cookies or localStorage
///
///
///
///
///
/// Gets requested data from either cookies or localStorage
///
///
///
///
if (!useCookie && 'localStorage' in window && window.localStorage !== null) {
return window.localStorage.getItem(name);
} else {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g, "");
if (x === name) {
return decodeURIComponent(y);
}
}
}
}
function convertToFrag(string) {
'use strict';
var frag = document.createDocumentFragment(),
div = document.createElement('div');
div.innerHTML = string;
while (div.firstChild) {
frag.appendChild(div.firstChild);
}
return frag; // Returns document fragment
}
function objectCount(obj) {
'use strict';
var count = 0;
var i;
for (i in obj) {
if (obj.hasOwnProperty(i)) {
count++;
}
}
return count; // Returns number
}
function splitIntoRows(elements) {
'use strict';
var arrayElements = [].slice.call(elements),
historyOffset = 0,
row = {},
rowLength = 0;
// breaking array into multiple objects
for (var i = 0, length = arrayElements.length; i < length; i++) {
var el = arrayElements[i], // Get individual item
offsetTop = el.getBoundingClientRect().top; // get offset from top of page
if (offsetTop === historyOffset) { // if the offsets match it must be the same/
row[rowLength][i] = el; // Add element to the object
} else { // if the don't match, must be new row
historyOffset = offsetTop; // Updade the new row offset
[].push.call(row, {}); // Add a new object
rowLength = [].slice.call(row).length - 1; // get position of new object
row[rowLength][i] = el; // Add element to object
}
}
return row; // Returns array of rows
}
function getParam(name) {
///
/// Returns the value of a given parameter from window.location
///
///
///
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if (results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
// Search JS
// Covers both the setting of the dynamic breadcrumb cookie and the rendering
// ==========================================================================
// When searching from any page other than the search results page
// Set a cookie for 60 minutes to allow for a dynamic breadcrumb on the results page.
var rememberSearch = (function() {
var searchWrappers = $('.searchBar, .home-bar-searchBar');
for (var i = 0; i < searchWrappers.length; i++) {
var form = $(searchWrappers[i]).find('form');
form.submit(function (e) {
var now = new Date();
var time = now.getTime();
time += 3600 * 1000;
now.setTime(time);
document.cookie =
'search_page=' + JSON.stringify({ url: window.location.pathname, title: $('h1')[0].innerHTML }) +
'; expires=' + now.toUTCString() +
'; path=/';
});
}
})();
/**
* Update search filters based on contextual facets.
*/
var setAllContextualFilterOptions = (function() {
// Wait for the document to finish loading
// before trying to use the facet values.
$(function() {
$("", {"class": "js-select-service-area-taxonomy"}).attr("name", "service_taxonomy").appendTo(".taxonomy-wrapper");
$("", {"class": "js-select-type"})
.attr("aria-label", "Content or File type")
.attr("name", "content_or_file_type")
.appendTo(".type-wrapper");
setContextualTaxonomyFilterOptions();
setContextualTypeFilterOptions();
searchFormAutoSubmit();
});
})();
/**
* Set the Service taxonomy search options based on the contextual results.
*/
var setContextualTaxonomyFilterOptions = function() {
// Get all contextual options
var options = getContextualTaxonomyFilterOptions();
var serviceAreaSelect = $(".js-select-service-area-taxonomy");
// Check if there are any contextual options available.
if(options.length > 0) {
// Remove all default options from the service areas and
// replace them with the options from the contextual options.
$(".js-form-item-field-service-taxonomy select option").each(function() {
this.remove();
});
options.forEach(function(option) {
var optionElement = $("");
if(option.selected) {
optionElement.attr("selected", "selected");
}
serviceAreaSelect.append(optionElement);
});
// Restore the selected option by triggering a select.
serviceAreaSelect.trigger("select");
} else {
serviceAreaSelect.append("");
}
};
/**
* Get all options from the contextual service taxonomy facet.
* @returns {Array}
*/
var getContextualTaxonomyFilterOptions = function() {
var options = [];
$("select[data-drupal-facet-id='service_taxonomy'] option").each(function() {
options.push(getValuesFromFacetOption($(this)));
});
return options;
};
/**
* Get the text and value from an option element.
* @param facetValueElement
* @returns {{name: string, value: string}}
*/
var getValuesFromFacetOption = function(facetValueElement) {
var selected = facetValueElement.attr("selected");
var values = {
"name": $(facetValueElement).html().trim(),
"value": $(facetValueElement).val(),
"selected": selected === "selected"
};
return values;
};
/**
* Set the Service taxonomy search options based on the contextual results.
*/
var setContextualTypeFilterOptions = function() {
var typeSelect = $(".js-select-type");
// Get all contextual options
var options = getContextualTypeFilterOptions();
// Default the options to hidden
var contentOptionAdded = false;
if(options.length > 0) {
options.forEach(function (option) {
var optionName = option.name.charAt(0).toUpperCase() + option.name.slice(1);
// If the option is a page option then rewrite the name.
if (optionName !== "File" && option.name !== "All types") {
optionName = "Page";
}
var optionElement = $("");
if (optionName === "File" || optionName === "All types") {
typeSelect.append(optionElement);
} else if (!contentOptionAdded) {
typeSelect.append(optionElement);
contentOptionAdded = true;
}
});
} else {
typeSelect.append("");
}
var selectedType = getTypeFilterOptionNameFromValue();
// Find option with Name of "selectedName" and set to selected
typeSelect.children("option").each(function() {
if(this.text === selectedType) {
$(this).attr("selected", "selected");
}
});
// Restore the selected option by triggering a select.
typeSelect.trigger("select");
};
/**
* Get the value of the currently applied type filter.
* @returns {string}
*/
var getTypeFilterValueFromUrl = function() {
var filterValue = "";
var search = decodeURIComponent(window.location.search);
if(search && search.indexOf("content_or_file_type:") !== -1) {
search = search.substr(1, search.length - 1);
var searchParts = search.split("&");
for(var i = 0; i < searchParts.length; i++) {
var searchPart = searchParts[i].split("=")[1];
if(searchPart.indexOf("content_or_file_type:") !== -1) {
filterValue = searchPart.split(":")[1];
}
}
}
return filterValue;
};
/**
* Based on the currently applied tyop filter, get an option name for that value.
* @returns {string}
*/
var getTypeFilterOptionNameFromValue = function() {
var typeValue = getTypeFilterValueFromUrl();
var name = "All types";
if(typeValue === "file") {
name = "File";
} else if (typeValue && typeValue !== name) {
name = "Page";
}
return name;
};
/**
* Get all options from the contextual type facet.
* @returns {Array}
*/
var getContextualTypeFilterOptions = function() {
var options = [];
$("select[data-drupal-facet-id='content_or_file_type'] option").each(function() {
options.push(getValuesFromFacetOption($(this)));
});
return options;
};
// If search results page add the dynamic breadcrumb
var setSearchBreadbrumb = (function() {
var storage = getStorage('search_page', true);
if(storage) {
var value = JSON.parse(storage),
html = '
',
output = $('body.path-search');
if (value) {
var builtHTML = html.replace(/{{URL}}/g, value.url).replace(/{{TITLE}}/g, value.title);
output.find('.content-header > .container > .row').prepend(builtHTML);
}
}
})();
var getSortOrder = function() {
return $("#search-page-form #edit-sort-by").val();
};
var searchFormAutoSubmit = function() {
// When facet filter changes, use the facet defined value to navigate the user to the search result.
$(".filter-container select").on("change", function(e) {
var searchQuery = $(this).val();
window.location.href = searchQuery;
});
// When the sort filter changes, apply the sort to the existing search URL.
$("#search-page-form #edit-sort-by").on("change", function(e) {
// Get sort order from form.
var sortOrder = getSortOrder();
// Declare full search URI.
var currentSearch = window.location.pathname + window.location.search;
// Declare current url.
var url = window.location.search;
// Check if the search already has a sort by and replace it rather than append it.
if(url.indexOf("sort_by") !== -1){
var newurl = "";
// Split the URL.
var split_sortby = url.split("&");
// Loop through array, rebuild the URL minus the sort_by parameter.
split_sortby.forEach(function(entry) {
if(entry.substr(0,7) !="sort_by"){
newurl = newurl + entry + "&";
}
});
// Trim the ampersand if there is one.
if(newurl.slice(-1) === "&"){
newurl = newurl.substr(0, newurl.length-1);
}
currentSearch = window.location.pathname + newurl + "&sort_by=" + sortOrder;
} else {
currentSearch = currentSearch + "&sort_by=" + sortOrder;
}
window.location.href = currentSearch;
});
};
// Search page styling.
var searchFilterStyling = (function() {
// Specify form to apply this js to.
// var pageSearchForm = $('#views-exposed-form-search-page-1');
// Clone the edit-actions element.
var actions = $('#edit-actions').clone();
// Remove the submit button.
$("#search-page-form #edit-submit-search").remove();
var count = $('.count-wrapper');
// Append elements
$('.search-container').append(actions);
$('.filter-container').prepend('
Filter results by:
');
$('.support-container').prepend(count);
})();
// Mobile navigations
// Requires jQuery
// ==================
function mobileNavigation() {
'use strict';
// var menuString = navigationObj, // get html menu string
var menuString = $('.js-mobile-menu-container'), // get html menu string
menuFrag = convertToFrag(menuString.html()), // Create initial menu frag
menu = $(menuFrag), // Convert menuFrag into a jQuery object
toggle = $('.js-menu-toggle'), // Get menu toggle
skipLinks = $('#skip-to-content'),
body = $('body'), // Get body element
level = 0; // Active level of navigation
// Manage and animated between levels of menu
function move(down, item, button) {
if (down) {
var nextMenu = item.find('> .menu'),
nextMenuItems = nextMenu.find('> .menu-item'),
itemSiblings = item.siblings('.menu-item');
item.addClass('menu-item--is-open');
if (!item.parent('.menu').hasClass('depth-0')) {
itemSiblings.hide();
}
nextMenu.addClass('is-open');
nextMenuItems.hide();
nextMenuItems.fadeIn('150');
} else {
// Ensure all child open elements close
item.find('.menu-item--is-open').removeClass('menu-item--is-open');
item.find('.is-open').removeClass('is-open');
// Close current level
item.removeClass('menu-item--is-open');
$(button).parent().siblings('.menu').removeClass('is-open');
// Fade in new level items
item.siblings('.menu-item').fadeIn('slow');
}
}
// Bind level toggle
function bindLevel(icon, item) {
$(icon).find('.js-toggle-level').on('click', function () {
if ($(item).hasClass('menu-item--is-open')) {
move(false, item, this);
} else {
move(true, item, this);
}
return false;
});
}
// close menu
function menuClose(icon, item) {
$(icon).find('.js-close-menu').on('click', function () {
body.removeClass('menu-is-open');
$('.navigation a, .navigation button').attr('tabIndex', '-1');
return false;
});
}
// Show only active level and add depth class for styling
var menuLevel = menu.find('.menu');
for (var i = 0; i < menuLevel.length; i++) {
var currentMenu = $(menuLevel[i]),
menuDepth = currentMenu.parents('.menu').length,
depthClass = 'depth-' + menuDepth;
currentMenu.addClass(depthClass);
if (1 >= i) {
currentMenu.addClass('is-open');
}
}
// Find 'menu-item--expanded', build and bind logic for toggling levels
var menuWithChild = menu.find('.menu-item--expanded'),
toggleLevel = '',
closeMenu = '';
var i;
var thisIcon;
for (var i = 0; i < menuWithChild.length; i++) {
if ($(menuWithChild[i]).parent('.menu').hasClass('depth-0')) {
thisIcon = convertToFrag(closeMenu);
$(menuWithChild[i]).addClass('menu-item--is-open');
// bind icon
menuClose(thisIcon, $(menuWithChild[i]));
} else {
thisIcon = convertToFrag(toggleLevel);
// bind icon
bindLevel(thisIcon, $(menuWithChild[i]));
}
// Add Icon
$(menuWithChild[i]).find('> a').append(thisIcon);
}
// Bind menu button
toggle.on('click', function () {
body.addClass('menu-is-open');
$('.navigation a, .navigation button').removeAttr('tabIndex');
$('.navigation .js-close-menu').focus();
$(document).keyup(function(e) {
if (e.keyCode == 27) { // escape key
body.removeClass('menu-is-open');
}
});
});
menuString.remove();
skipLinks.after(menu);
var home = '
';
$('.navigation > ul').append(home);
$('.navigation a, .navigation button').attr('tabIndex', '-1');
setTimeout(function () {
var isActive = $('.navigation .is-active');
if (isActive) {
var activeParents = isActive.parents('.menu-item--expanded');
for (var i = activeParents.length - 1; i >= 0; i--) {
var openItem = $(activeParents[i]);
move(true, openItem);
}
}
}, 10);
}
if ($('.js-mobile-menu-container').length > 0 ) {
mobileNavigation();
}
var menuItems = document.querySelectorAll('li.nav-item--expanded');
Array.prototype.forEach.call(menuItems, function(el, i){
var activatingA = el.querySelector('a');
var btn = '';
activatingA.insertAdjacentHTML('afterend', btn);
el.querySelector('button').addEventListener("click", function(event){
if (this.parentNode.className == "nav") {
this.parentNode.className = "nav-item";
this.parentNode.querySelector('a').setAttribute('aria-expanded', "true");
this.parentNode.querySelector('button').setAttribute('aria-expanded', "true");
} else {
this.parentNode.className = "nav-item nav-item--expanded";
this.parentNode.querySelector('a').setAttribute('aria-expanded', "false");
this.parentNode.querySelector('button').setAttribute('aria-expanded', "false");
}
event.preventDefault();
});
});
var menuAriaFix = (function() {
var getDropdownMenu = $('.service-nav-dropdown'),
btnNav = getDropdownMenu.find('button.nav-button.nav-button-down');
getDropdownMenu.each(function() {
var isContainTxtNode = $(".service-nav-dropdown .button.nav-button-down:contains(Dropdown Button)");
if (isContainTxtNode) {
return btnNav.attr('tabindex', '-1');
}
});
})();
$('.nav-button-down').click(function(){
$('.service-nav-dropdown').css('display', 'none');
$(this).next('.service-nav-dropdown').toggle();
});
$('.nav-bar-close').click(function(){
$(this).parent().fadeOut('slow');
});
$('.nav-bar-close').keydown(function(e) {
var code = e.keyCode || e.which;
if (code === 13) {
$('.service-nav-dropdown').fadeOut('slow');
}
});
/**
* Created by michaelcraddock on 28/06/2016.
*/
/* globals console, $ */
/*
* @requires jQuery
*/
$(document).ready(function () {
'use strict';
// loop through all the titles and only push ones with have expander content as its next element
$('.expander').each(function (key, val) {
if ($(val).next().hasClass('expander-content')) {
$(val).attr('tabindex', 0);
$(val).on('click', function() {
$(this).next().slideToggle();
$(this).toggleClass('expanded');
});
$(val).on('keydown', function (e) {
if(e.keyCode === 13) {
$(this).next().slideToggle();
$(this).toggleClass('expanded');
}
});
}
});
});
// Share this page button
// ======================
var shareThisPage = (function() {
var container = $('.js-shareThisPage'),
wrapper = $('.js-shareLinksWrapper'),
button = '';
container.prepend(button);
wrapper.css('display', 'none');
$('.js-shareThisPageButton').on('click', function(event) {
event.preventDefault();
wrapper.slideToggle(400);
});
})();
/**
* Created by michaelcraddock on 01/07/2016.
*/
/* globals $, console */
$(document).ready(function () {
'use strict';
var jumplinks = $('.jump-link'),
linkList = document.createElement('ul'),
wrapper = $('.jump-link-wrapper');
jumplinks.each(function (key, val) {
var li = document.createElement('li');
var container = document.createElement('div');
var strippedText = document.createTextNode(stripHtml($(val).html()));
container.appendChild(strippedText);
$(li).html('' + container.innerHTML + '');
linkList.appendChild(li);
if (wrapper.length > 0) {
$(this).attr('id', 'jumplink' + key).append('Back to top');
} else {
$(this).attr('id', 'jumplink' + key).append('Back to top');
}
});
wrapper.append(linkList);
wrapper.attr('id','jumplinktop');
// only the first set of jump links is allowed
if(wrapper.length > 1){
wrapper.each(function(key, val){
if(key !== 0){
$(this).remove();
}
});
}
// ccIframe();
wordTranscriptLink();
//ariaReadMoreLinks();
ariaCKBtns();
ariaHeaderLogo();
ariaServiceNavLinks();
ariaSocialLinks();
replaceHeaderTags();
});
function stripHtml(val){
var temporalDivElement = document.createElement("div");
temporalDivElement.innerHTML = val;
return temporalDivElement.textContent || temporalDivElement.innerText || "";
}
function ccIframe() {
// For closed Captioning (CC) on video
var vidElemIframe = $(".video-embed-field-responsive-video iframe");
var vidPlayerTxt = "Electronic Repeat Dispensing (eRD): An overview";
var srcString = "https://www.youtube.com/embed/zzaNeAaelAo?autoplay=0&start=0&rel=0";
var closedCaption = "?cc_load_policy=1";
var closedCaptionLang = "?cc_load_policy=1&cc_lang_pref=en";
iframeSrc = srcString + closedCaptionLang;
vidElemIframe.attr('title', vidPlayerTxt);
return vidElemIframe.attr("src", iframeSrc);
}
function wordTranscriptLink() {
var wordDocAnchor = $("#main-content article > div:nth-child(2) > div > p:nth-child(8) > a");
wordDocAnchor.attr('title', 'Download video transcript: This link will open a Word document - size:249kb')
.attr('aria-label', 'Download video transcript');
return wordDocAnchor;
}
function ariaReadMoreLinks() {
var getFlexContent = $("#main-content .flexible-content-row-content"),
getFooterContent = $("#main-content .service-area-footer");
getFlexContent.each(function() {
$(this).find("a.contentPageBlock-link").attr("title", $(this).find("h3 a").text());
$(this).find("h3 a").replaceWith(function() {
return "" + this.innerHTML + "";
});
$(this).find("a.contentPageBlock-link").text(function() {
return "Learn more";
});
});
getFooterContent.each(function() {
$(this).find("a").attr("title", $(this).find("h3 a").text());
$(this).find("h3 a").replaceWith(function() {
return "" + this.innerHTML + "";
});
$(this).find("a").text(function() {
return "Learn more";
});
$(this).find("h3").replaceWith(function () {
return "
" + $(this).html() + "
";
});
});
}
function ariaHeaderLogo() {
var siteLogo = $(".header-logo");
var elementTitle = siteLogo.find("a").attr('title');
var ImgTitle = siteLogo.find("img").attr('alt');
siteLogo.find("a").attr("title", "NHSBSA: " + elementTitle);
siteLogo.find("a").attr({
title: "NHSBSA: " + elementTitle,
href: '/#'
});
siteLogo.find("img").attr("alt", "Return to " + ImgTitle);
return siteLogo;
}
function ariaCKBtns() {
$("#main-content article").each(function() {
var ckBtnEl = $(this).find("a.ckbtn"),
ckBtnElNoTitle = $(this).find("a.ckbtn:not([title])");
ckBtnElNoTitle.each(function() {
$(this).attr('title', $(this).text());
});
ckBtnEl.each(function() {
$(this).attr('title', "Go to " + $(this).text());
});
});
}
function ariaSocialLinks() {
var fetchSocialBtn = $(".share-links-wrapper");
var getSpans = fetchSocialBtn.find(".share--link-span");
var txtNodesSocial = getSpans.attr("aria-labelledby");
var spanText;
fetchSocialBtn.each(function() {
$(this).find("a.share--link").each(function() {
var spanElem = $(this).find("span.share--link-text");
spanElem.each(function() {
$(this).attr("title", txtNodesSocial);
spanText = $(this).text();
getSpans.attr({
'aria-role': txtNodesSocial
});
getSpans.removeAttr('aria-labelledby');
});
$(this).attr('title', spanText + "!");
});
});
}
function ariaServiceNavLinks() {
var getNavListItem = $("#block-custommenu > nav > ul > li"),
getNavListItemExp = $("#block-custommenu > nav > ul > li.nav-item.nav-item--expanded");
getH3ServiceBlockItem = $("#block-service-block h3");
getNavListItem.each(function() {
var topLevelAnchors = $(this).find("a"),
elementTitle = topLevelAnchors.attr('title');
topLevelAnchors.attr("title", "Go to " + elementTitle).attr('tabindex', '0');
});
getNavListItemExp.each(function() {
var subLevelAnchors = $(this).find("a"),
$ulElemLi = $("ul.nav.focus > li.nav-item"),
$ulElemLiAnchorUrl = $ulElemLi.find("a");
subLevelAnchors.each(function() {
var $ulElem = $(this).next("ul.nav");
$ulElem.attr({
tabindex: '0'
}).addClass('focus');
$(this).keydown(function(e) {
var key = e.keyCode || e.which;
$ulElem.parent().prevAll("li").find("ul.nav").hide();
$ulElem.parent().nextAll("li").find("ul.nav").hide();
$ulElem.show();
if ( $ulElem.parent().attr('class') === "nav-item--expanded" ) {
$(this).parent().addClass("nav-item--expanded").addClass("nav-item");
$(this).attr('aria-expanded', "true");
} else {
$(this).parent().addClass("nav-item--expanded");
$(this).attr('aria-expanded', "false");
}
if (key === 27) {
$ulElem.hide();
}
if (key !== 13) {
$ulElem.removeClass('focus');
}
});
});
});
getH3ServiceBlockItem.each(function() {
var elemTitle = $(this).find("a").attr('title');
$(this).find("a").attr("title", "Go to " + elemTitle);
});
}
function replaceHeaderTags() {
var getHomebarList = $("#main-content .home-bar .home-bar-link-list");
getHomebarList.each(function() {
$(this).find("h4").replaceWith(function () {
return "
" + $(this).html() + "
";
});
});
}
/* globals $, jQuery, setStorage, getStorage, console, survey_popup */
var m = $('.survey-modal-screen');
function swap() {
'use strict';
$('#top').prepend(m);
}
var allNodes = document.querySelectorAll("*"),
modalOpen = false;
function noFocus(event) {
'use strict';
var isModal = $(event.target).parents('.survey-modal-screen').length;
if (modalOpen && isModal === 0) {
event.stopPropagation();
$(m).find('h2, p, button,a')[0].focus();
}
}
for (var i = allNodes.length; i >= 0; i--) {
$(allNodes[i]).focus(noFocus);
}
function getActiveElement() {
'use strict';
var originalFocus = document.activeElement;
return $(originalFocus);
}
function triggerPopUp() {
'use strict';
$('.page, #skip-to-content').attr('aria-hidden','true');
modalOpen = true;
if (survey_popup !== undefined) {
survey_popup.lastFocus = getActiveElement();
}
$(m).each(function (key, val) {
$(val).show();
bindTab($(val).find('h2, p, button,a'));
});
}
function removePopUp() {
'use strict';
$('.page, #skip-to-content').attr('aria-hidden','false');
var modalElements = $('.survey-modal-screen');
$(modalElements).each(function (key, val) {
$(val).remove();
});
survey_popup.lastFocus.focus();
$(window).off('keydown');
}
function bindTab(links) {
'use strict';
if (links.length > 0) {
var focusLink = $(links[links.length - 2]);
focusLink.focus();
}
$(window).on('keydown', function (e) {
var cancel = false;
if (e.ctrlKey || e.metaKey || e.altKey) {
return;
}
switch (e.which) {
case 27: // ESC
// assume if esc user selects later
if (focusLink !== undefined) {
focusLink.focus();
}
cancel = true;
break;
case 9: // TAB
if (e.target === links[links.length - 1]) {
links[0].focus();
cancel = true;
}
break;
}
if (cancel) {
e.preventDefault();
}
});
}
function surveyTriggerCookie(days) {
'use strict';
if (days !== 0) {
setStorage('popup' + survey_popup.id, true, days, true);
} else {
setStorage('popup' + survey_popup.id, true, 30, true);
}
removePopUp();
}
(function () {
'use strict';
// make sre the modal is first item in dom for tabbing
swap();
// check theres a popup on the page and then trigger the logic
if (typeof survey_popup !== "undefined") {
var modalShown = getStorage('popup' + survey_popup.id, true);
// if the popup hasn't been shown then show it
if (!modalShown) {
// setTimeout(triggerPopUp,3000);
triggerPopUp();
}
}
})();
/* global console, escape, $ */
// Service page section pods.
// Equal height the titles onload only.
// ====================================
var sectionPods = (function () {
'use strict';
var pods = $('.sectionBlock'),
row = splitIntoRows(pods);
for (var i = 0, length = row.length; i < length; i++) { // Loop through rows
var newHeight = 0, // Set current rows height
thisRow = row[i]; // Get current row data
for (var key in thisRow) { // Loop through elements
if (thisRow.hasOwnProperty(key)) {
var height = $(thisRow[key]).find('.sectionBlock-title')[0].offsetHeight; // get elements height
if (newHeight < height) { // Compare el height a row height
newHeight = height;
}
}
}
$.each(thisRow, function (key, val) {
$(val).find('.sectionBlock-title').css('minHeight', newHeight + 'px');
});
}
})();
$('.serviceFooterBlock h3').replaceWith(function (){
return '
' + $(this).html() + '
'
});
var ariaFeedbackSubmit = (function () {
submitBtnFeedback = $("#edit-submit");
submitBtnFeedback.attr({
'aria-labelledby': 'edit-submit',
title: 'Submit your feedback',
role: 'button',
type: 'submit',
});
labelSubmit = '';
submitBtnFeedback.before(labelSubmit);
// submitBtnFeedback.wrap('');
})();
// Flexible content row news block managment.
// Brings news blocks together and add title.
// ==========================================
var newsBlocks = (function () {
'use strict';
var contentRow = $('.flexible-content-row'),
arrayRows = [].slice.call(contentRow);
for (var i = 0; i < arrayRows.length; i++) { // Loop through rows
var thisRow = arrayRows[i],
newsBlocks = $(thisRow).find('.news-block'),
blockCount = newsBlocks.length,
htmlLocation, // Finding the location to output HTML string
html = "", // HTML string
htmlOpen = "
", // Opening HTML
htmlClose = "
"; // Closing HTMl
if (newsBlocks.length < 1) {
continue;
}
// Add initial opening HTML to HTML string
html += htmlOpen;
for (var t = 0, length = newsBlocks.length; t < length; t++) { // Loop through rows
var el = $(newsBlocks[t]), // Get news item
parent = el.parent(); // Get news item parent
// Get append location and add title markup to HTML string
if (t === 0) {
htmlLocation = parent;
html += "
";
html += $('h1')[0].innerHTML + ' news';
html += "
";
}
// Removing all CMS classes
parent.attr('class', 'column news-block-wrapper');
// Looping to check what class to add to elements
if (blockCount === 3) {
parent.addClass('sm-is-4 is-12 ie-is-4');
} else if (blockCount === 2) {
parent.addClass('sm-is-6 is-12 ie-is-6');
} else if (blockCount === 1) {
parent.addClass('is-12 ie-is-12');
}
// Add element into HTML string
html += parent[0].outerHTML;
// Remove element from DOM
if (t !== 0) {
parent.remove();
}
}
// Close HTML string
html += htmlClose;
htmlLocation[0].outerHTML = html;
}
// Add class based on amount of items
var newsContainer = $('.news-block-container');
for (var it = 0; it < newsContainer.length; it++) {
var container = $(newsContainer[it]),
items = container.find('.news-block-wrapper');
if (items.length === 1) {
container.addClass('sm-is-4 ie-is-4');
} else if (items.length === 2) {
container.addClass('sm-is-8 ie-is-8');
} else if (items.length === 3) {
container.addClass('sm-is-12 ie-is-12');
}
}
})();
// Function of setting a class on hover of the title of the .serviceBlock
// Find title a and then trigger hover state
// ======================================================================
var serviceBlockHover = (function () {
var title = $('.serviceBlock-title a');
title.hover(function () {
$(this).parents('.serviceBlock').toggleClass('is-hovered');
});
})();
// Search toggle
// =============
var searchToggle = (function () {
var container = $('.js-search-controller'),
toggle = $('.js-search-toggle'),
bar = $('.js-search-container');
toggle.on('click', function (event) {
event.preventDefault();
toggle.toggleClass('search-is-visible');
container.toggleClass('search-is-visible');
bar.slideToggle(400);
});
})();
$(window).on('resize', function () {
'use strict';
var container = $('.js-search-controller'),
toggle = $('.js-search-toggle'),
bar = $('.js-search-container');
if (window.innerWidth >= 620) {
bar[0].style.display = 'block';
} else if (!toggle.hasClass('search-is-visible')) {
bar[0].style.display = 'none';
}
});
// Contextual toggle
// =================
var contextualToggle = (function () {
var container = $('.contextual-tabs .contextual-region'),
html = '';
container.find('> ul').append(html);
$('.js-contextual-toggle').on('click', function (event) {
event.preventDefault();
container.toggleClass('controls-are-visible');
setTimeout(function(){
container.toggleClass('auto-height');
}, 300);
});
})();
// Tables!
// ======
var responsive_tables = (function () {
var tables = $('table:not([class])');
for (var i = 0; i < tables.length; i++) {
var this_table = $(tables[i]),
html = $('');
html.insertBefore(this_table);
html.append(this_table.clone());
this_table.remove();
}
})();
// Function to manage the news listing year select box
// ===================================================
var newsListingFilter = function () {
var years = newsListingYears,
controls = $('.news-listing-controls'),
param = getParam('y'),
paramPage = getParam('page'),
html = '';
html += '