'use strict';
/**
* Search tabs.
* @namespace searchTabs
* @memberof UCASDesignFramework
* @param {object} global - UCASDesignFramework object.
* @param {object} _u - UCASUtilities object.
*/
(function (global, _u) {
/**
* Initialise plugin.
*/
function init () {
/**
* Initialise plugin.
* @function init
* @memberof! UCASDesignFramework.searchTabs
* @public
*/
var ariaCurrentTab = document.querySelector('.search-tabs__tab-link[aria-current="page"]')
if (ariaCurrentTab) {
// Scroll the current tab into view on mobile.
// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
// https://caniuse.com/#feat=scrollintoview
// Scrolling the parent as that contains padding, bringing the link away from the edges of the screen.
ariaCurrentTab.parentElement.scrollIntoView(false)
}
}
// Expose public methods.
global.searchTabs = {
init: init,
/**
* @memberof! UCASDesignFramework.searchTabs
* @property {Boolean} initOnLoad - run init() on page load
*/
initOnLoad: true
}
})(UCASDesignFramework, UCASUtilities)