{"version":3,"names":[],"mappings":"","sources":["vendor/speedbump/speedbump.js"],"sourcesContent":["(function ($) {\r\n 'use strict';\r\n\r\n $.fn.speedBumpModal = function (options) {\r\n\r\n // Pass array through settings\r\n var settings = $.extend({\r\n 'speedBumpTitle': 'You are leaving this website',\r\n 'speedBumpSummary': 'You are leaving our website and entering a third party website over which we have no control. We do not endorse or guarantee and are not responsible for the content, links, privacy, or security of the website, or the products, services, information, or recommendations offered on this website.',\r\n 'speedBumpContinueLink': 'Continue',\r\n 'speedBumpCancelLink': 'Cancel',\r\n 'speedBumpIgnoreArray': [],\r\n 'speedBumpHeadingTag': '

',\r\n 'speedBumpCloseIconClass': ''\r\n }, options);\r\n\r\n // Build outer speedbump modal div\r\n $(document.createElement('div'))\r\n .addClass('speed-bump')\r\n .attr('tabindex', '-1')\r\n .attr('role', 'dialog')\r\n .attr('aria-modal', true)\r\n .attr('aria-labelledby', 'speedBumpTitle')\r\n .appendTo('body');\r\n\r\n // Build outer speed-bump dialog\r\n $(document.createElement('div'))\r\n .addClass('speed-bump__dialog')\r\n .attr('role', 'document')\r\n .appendTo('.speed-bump');\r\n\r\n // Build speed-bump content\r\n $(document.createElement('div'))\r\n .addClass('speed-bump__content')\r\n .appendTo('.speed-bump__dialog');\r\n\r\n // Build speed-bump title\r\n $(settings.speedBumpHeadingTag)\r\n .addClass('speed-bump__title')\r\n .attr('id', 'speedBumpTitle')\r\n .html(settings.speedBumpTitle)\r\n .appendTo('.speed-bump__content');\r\n\r\n // Build speed-bump summary\r\n $(document.createElement('p'))\r\n .addClass('speed-bump__summary')\r\n .html(settings.speedBumpSummary)\r\n .appendTo('.speed-bump__content');\r\n\r\n // Build speed-bump continue link\r\n $(document.createElement('a'))\r\n .addClass('speed-bump__continue')\r\n .attr('href', null)\r\n .html(settings.speedBumpContinueLink)\r\n .appendTo('.speed-bump__content');\r\n\r\n // Build speed-bump cancel link\r\n $(document.createElement('button'))\r\n .addClass('speed-bump__cancel')\r\n .attr({\r\n 'type': 'button'\r\n })\r\n .html(settings.speedBumpCancelLink)\r\n .appendTo('.speed-bump__content');\r\n\r\n // Build speed-bump close button\r\n $(document.createElement('button'))\r\n .addClass('speed-bump__close')\r\n .attr('type', 'button')\r\n .attr('aria-label', 'Close')\r\n .insertAfter('.speed-bump__title');\r\n\r\n // Build speed-bump cancel button icon\r\n if (settings.speedBumpCloseIconClass !== '') {\r\n $(document.createElement('span'))\r\n .addClass(settings.speedBumpCloseIconClass)\r\n .attr('aria-hidden', 'true')\r\n .appendTo('.speed-bump__close');\r\n }\r\n\r\n // Trap the keyboard to the off canvas elements when speedbump modal is showing\r\n var focusBeforeSpeedbump;\r\n var trapKeyboardToSpeedbump = function () {\r\n\r\n // Cache anchor that fired speedbump\r\n focusBeforeSpeedbump = $(':focus');\r\n\r\n var firstTabbable = $('.speed-bump__close');\r\n var lastTabbable = $('.speed-bump__cancel');\r\n\r\n // Set focus on first input\r\n firstTabbable.focus();\r\n\r\n // Redirect last tab to first input\r\n lastTabbable.on('keydown', function (e) {\r\n if (e.which === 9 && !e.shiftKey) {\r\n e.preventDefault();\r\n firstTabbable.focus();\r\n }\r\n });\r\n\r\n // Redirect first shift+tab to last input\r\n firstTabbable.on('keydown', function (e) {\r\n if (e.which === 9 && e.shiftKey) {\r\n e.preventDefault();\r\n lastTabbable.focus();\r\n }\r\n });\r\n\r\n // Focus on the off canvas element\r\n $('.speed-bump__content').focus();\r\n };\r\n\r\n // Close speed-bump function\r\n function speedBumpHide() {\r\n $('body').removeClass('js-speedbump-showing');\r\n $('[data-anchor-active]')\r\n .focus()\r\n .removeAttr('data-anchor-active');\r\n $('.speed-bump__continue').attr('target', '');\r\n focusBeforeSpeedbump.focus();\r\n }\r\n\r\n // Setup array of domains to ignore\r\n var flaggedArr = settings.speedBumpIgnoreArray;\r\n var localUrl = location.host;\r\n flaggedArr.push(localUrl);\r\n\r\n var cleanArray = $.map(flaggedArr, function (n, i) {\r\n var arrayItem = n.split(' ').join('');\r\n\r\n if (arrayItem === '') {\r\n return;\r\n } else {\r\n return arrayItem.toLowerCase();\r\n }\r\n });\r\n\r\n // Set class on internal and ignored links\r\n $('a[href]').each(function () {\r\n var $this = $(this),\r\n anchorHref = $this.attr('href').toLowerCase();\r\n\r\n for (var i = cleanArray.length - 1; i >= 0; --i) {\r\n if (anchorHref.indexOf(cleanArray[i]) !== -1) {\r\n $this.addClass('js-no-speed-bump');\r\n }\r\n }\r\n });\r\n\r\n var selectorString =\r\n 'a:not(.js-no-speed-bump)' +\r\n ':not([href^=\"#\"])' +\r\n ':not([href^=\"/\"])' +\r\n ':not(.speed-bump__continue)' +\r\n ':not([href=\"\"])'\r\n ;\r\n\r\n // Anchor click modal functionality\r\n $(selectorString).on('click', function (e) {\r\n\r\n $('body').addClass('js-speedbump-showing');\r\n\r\n e.preventDefault();\r\n e.stopPropagation();\r\n\r\n var $this = $(this);\r\n var $thisUrl = $this.attr('href');\r\n var newWindow = ($this.attr('target') === '_blank') ? true : false;\r\n\r\n // Add data attribute to currently active anchor\r\n $this.attr('data-anchor-active', 'true');\r\n\r\n // Display and focus on the speed-bump modal\r\n $('.speed-bump')\r\n .focus();\r\n\r\n // Speedbump continue link\r\n $('.speed-bump__continue').attr('href', $thisUrl);\r\n\r\n if (newWindow === true) {\r\n $('.speed-bump__continue').attr('target', '_blank');\r\n }\r\n\r\n trapKeyboardToSpeedbump();\r\n });\r\n\r\n // Speedbump cancel button click\r\n $('.speed-bump__close, .speed-bump__cancel').on('click', function (e) {\r\n speedBumpHide();\r\n });\r\n\r\n // Close speed bump after clicking continue\r\n $('.speed-bump__continue').on('click', function () {\r\n setTimeout(function () {\r\n speedBumpHide();\r\n }, 300);\r\n });\r\n\r\n // Click off speed-bump closes it\r\n $('.speed-bump').on('click', function (e) {\r\n if (!$(e.target).closest('.speed-bump__content').length) {\r\n speedBumpHide();\r\n }\r\n }).on('keydown', function (e) {\r\n if (e.keyCode === 27) {\r\n speedBumpHide();\r\n }\r\n });\r\n };\r\n})(jQuery);\r\n"],"file":"vendor/speedbump/speedbump.js"}