Copyright © Murphy USA. All rights reserved.
' /* beautify preserve:end */ ), location: '.pane--footer' }, offsetTopElem: [$('.pane--navigation .pane_inner')], offsetTopBreakPoint: [{ breakPoint: 1024, offsetTopElem: [] }], getTopOffset: function() { var inst = this, topOffsetScroll = 0; if ((inst.offsetTopBreakPoint.length && $(window).width() > inst.offsetTopBreakPoint[0].breakPoint) || !inst.offsetTopBreakPoint.length) { if (inst.offsetTopElem.length) { $.each(inst.offsetTopElem, function(i, thisOffsetelem) { topOffsetScroll += thisOffsetelem.outerHeight(); }); } } else { $.each(inst.offsetTopBreakPoint, function(i, thisBreakPoint) { var index = inst.offsetTopBreakPoint.length - 1, next = i + 1; if (!(index > 0 && index > i && $(window).width() <= inst.offsetTopBreakPoint[next].breakPoint)) { if ($(window).width() <= thisBreakPoint.breakPoint && thisBreakPoint.offsetTopElem.length) { $.each(thisBreakPoint.offsetTopElem, function(j, thisOffsetelem) { topOffsetScroll += thisOffsetelem.outerHeight(); }); } } }); } return topOffsetScroll; } }), setHeaderOffset: function() { var app = this; o = this.options; $(window).on('resize.headerOffset', function() { app.options.headerOffset = app.options.getTopOffset(); }).trigger('resize.headerOffset'); }, sections: function() { var hash = decodeURIComponent(window.location.hash.length ? window.location.hash.substring(1) : ''), isMobileOpen = function() { return $('.layout').hasClass('js--mobile'); }; if ($('.module-' + hash).length) { setTimeout(function() { q4App.scrollTo($('.module-' + hash)); window.location.hash = hash; }, 1000); } $('nav').on('click', 'a[href*="#"]', function(e) { var $parent = $(this).closest('ul').parent('li'), hash = $(this).attr('href').split('#')[1]; if ($parent.hasClass('selected')) { if (isMobileOpen()) { $('.layout').removeClass('js--mobile'); } e.preventDefault(); window.location.hash = hash; q4App.scrollTo($('.module-' + hash)); } }); }, tabs: function($container, triggerContainer, trigger, content, select, useHash, useKBTabs) { // display specific tab using hash from url var hash = window.location.hash.split('#')[1], hashTargetExists = $(content + '.' + hash).length > 0, changeHash = useHash != undefined ? useHash : true, first, $hiddenContent = function() { return $(content).addClass('js--hidden').attr('aria-hidden', 'true'); }; // accessibility $(triggerContainer).attr('role', 'tablist'); $(trigger).attr('role', 'tab').attr('aria-selected', 'false'); if (hash && hashTargetExists) { $hiddenContent().filter('.' + hash).removeClass('js--hidden').attr('aria-hidden', 'false'); if (trigger) $(trigger).attr('tabindex', '0').filter('[data-tab=".' + hash + '"]').addClass('js--selected').attr('aria-selected', 'true'); if (select) $(select + ' option[value=".' + hash + '"]').attr('selected', true); } else { $hiddenContent(); } // if trigger is used/defined if (trigger) { first = $(trigger).first().data('tab'); if (!hash || !hashTargetExists) { $(trigger).attr('tabindex', '0').first().addClass('js--selected').attr('aria-selected', 'true'); $(first).removeClass('js--hidden').attr('aria-hidden', 'false'); // change hash on load if (changeHash) window.location.hash = first.split('.')[1]; } $container.on('click keypress', trigger, function(e) { if (changeHash) window.location.hash = $(this).data('tab').split('.')[1]; if ($(trigger).is('a, button')) e.preventDefault(); $(this).addClass('js--selected').attr('aria-selected', 'true').closest($container).find('.js--selected').not(this).removeClass('js--selected').attr('aria-selected', 'false'); $hiddenContent().filter($(this).data('tab')).removeClass('js--hidden').attr('aria-hidden', 'false'); // update select if (select) { $(select).val($(this).data('tab')); } }); } // if select is used/defined if (select) { first = $(select + ' option:first-child').val(); if (!hash || !hashTargetExists) { $(select + ' option:first-child').attr('selected', true); $(first).removeClass('js--hidden').attr('aria-hidden', 'false'); // change hash on load if (changeHash) window.location.hash = first.split('.')[1]; } $container.on('change', select, function() { var tab = $(this).val(); if (changeHash) window.location.hash = $(this).val().split('.')[1]; $hiddenContent().filter(tab).removeClass('js--hidden').attr('aria-hidden', 'false'); if (trigger) $(trigger).removeClass('js--selected').filter('[data-tab="' + tab + '"]').addClass('js--selected'); }); } if (useKBTabs || useKBTabs === undefined) { var tabs = document.querySelectorAll('[role="tab"]'); var tabList = document.querySelector('[role="tablist"]'); // Add a click event handler to each tab tabs.forEach(function(tab) { var tabContentID = tab.getAttribute("data-tab").replace(".", ""), tabContentIDs = ""; $("." + tabContentID).each(function(i) { $(this).attr("id", tabContentID + "-" + i); tabContentIDs += (tabContentID + "-" + i + " "); }); tab.setAttribute("aria-controls", tabContentIDs); tab.setAttribute("tabindex", -1); tab.addEventListener("click", changeTabs); }); $('[role="tab"][aria-selected="true"]').attr("tabindex", 0); // Enable arrow navigation between tabs in the tab list var tabFocus = 0; tabList.addEventListener("keydown", function(e) { // Move right if (e.keyCode === 39 || e.keyCode === 37) { tabs[tabFocus].setAttribute("tabindex", -1); if (e.keyCode === 39) { tabFocus++; // If we're at the end, go to the start if (tabFocus >= tabs.length) { tabFocus = 0; } // Move left } else if (e.keyCode === 37) { tabFocus--; // If we're at the start, move to the end if (tabFocus < 0) { tabFocus = tabs.length - 1; } } tabs[tabFocus].setAttribute("tabindex", 0); tabs[tabFocus].focus(); } }); } function changeTabs(e) { var target = e.target; var parent = target.closest('[role="tablist"]'); var grandparent = parent.parentNode; // Remove all current selected tabs parent .querySelectorAll('[aria-selected="true"]') .forEach(function(t) { t.setAttribute("aria-selected", false); }); // Set this tab as selected target.setAttribute("aria-selected", true); // Hide all tab panels grandparent .querySelectorAll('[role="tabpanel"]') .forEach(function(p) { p.setAttribute("hidden", true); }); // Show the selected panels var tabContentIDArr = target.getAttribute("aria-controls").split(" "); $.each(tabContentIDArr, function(index, value) { if (value && value != "") $('#' + value).removeAttr("hidden"); }); } }, init: function() { var app = this; app.setHeaderOffset(); app.cleanUp(); app.unWrapLink('a.module-stock-header_stock-price'); app.submitOnEnter('.module-unsubscribe'); app.submitOnEnter('.module-search'); app.validateSubmit('.module-search'); app.superfish($('.nav--main .level2'), { cssArrows: false }, 1024); app.mobileMenuToggle($('.layout'), '.pane--navigation', '.layout_toggle i'); app.cleanQuickLinks($('.module-links')); app.copyright($('.copyright_year')) app.reveal('.pane--footer .module-subscribe', '.module-subscribe_email', '.module-subscribe_mailing-list, .module_actions', true); app.docTracking(); app.fancySignup(); app.resetDate(['a[href*="s3.q4web.com"]:not([href$=".pdf"])']); app.previewToolbar(); app.nav__mobileTapSupport($('.nav--main .level1')); app.signUpButtonText(); app.sections(); app.nav_sticky({ $stickyElemTrigger: $('.pane--navigation'), $stikyElem: $('.pane--navigation .pane_inner'), stopStickyBreakPoint: 1024, stopStickySwitchCondition: true }); app.linkRemoveTarget('.module-header-links'); app.linkRemoveTarget('.module-links--home'); }, superfish: function($nav, options) { if (!this.isMobile.any() && this.options.superfish && $(window).width() > 1024) { $nav.superfish(options); } }, nav__mobileTapSupport: function($selector) { if (this.isMobile.any()) { $selector.on('click', 'li.has-children > a', function(e) { var $this = $(this), $parent = $this.parent(); if (!$parent.hasClass('js--nav-dropdown')) { e.preventDefault(); $parent.siblings().removeClass('js--nav-dropdown'); $parent.addClass('js--nav-dropdown'); } }); } }, signUpButtonText: function() { $('.module-subscribe').find('input[type="submit"]').attr("value", "Subscribe"); }, nav_sticky: function(settings) { var generalOpt = this.options, sticky = { options: { $stikyElem: null, $stickyElemTrigger: null, stopStickyBreakPoint: null, stopStickySwitchCondition: null, offsetTopElem: [], offsetTopBreakPoint: [], getTopOffset: generalOpt.getTopOffset }, init: function(options) { $.extend(this.options, options); var inst = this; inst.onScroll(); inst.onResize(); }, onScroll: function() { var inst = this; $(window).on('scroll.navSticky', function() { inst._addRemoveSticky(); }).trigger('scroll.navSticky'); }, onResize: function() { var inst = this, o = inst.options; $(window).on('resize.navSticky', function() { inst._addRemoveSticky(); if (o.stopStickySwitchCondition === ($(window).width() <= o.stopStickyBreakPoint)) { o.$stikyElem.removeClass('js--sticky').add(o.$stickyElemTrigger).removeAttr('style'); } }); }, _addRemoveSticky: function() { var inst = this, o = inst.options, condition = o.stopStickySwitchCondition === ($(window).width() <= o.stopStickyBreakPoint); if (!condition) { var curentScroll = $(window).scrollTop(), topOffset = o.getTopOffset(); //cache value; stickyElemWrapper_offsetTop = o.$stickyElemTrigger.offset().top - topOffset; o.$stickyElemTrigger.css('height', o.$stikyElem.outerHeight()); if (curentScroll >= stickyElemWrapper_offsetTop) { o.$stikyElem.addClass('js--sticky').css("top", topOffset + 'px'); } else { o.$stikyElem.removeClass('js--sticky').removeAttr('style'); } } } }; sticky.init(settings); }, // We use this function to remove the "target:_blank" from quick links wich link to the corporate site linkRemoveTarget: function(module) { $(module).find('a[target="_blank"]').removeAttr('target'); }});q4App.init();