var FE = {}; jQuery(function() { "use strict"; homebrew.Carousel.prototype.options.transitions.enable = Modernizr.csstransitions; homebrew.Tooltip.prototype.options.appendTo = '#mainContent'; homebrew.Tooltip.prototype.options.transitions.enable = Modernizr.csstransitions; jQuery.extend(FE, { $els : { backToTop : jQuery('#globalBackToTop'), body : jQuery('body'), mainSite : jQuery('#mainSite'), pageOverlay : jQuery('#pageOverlay'), root : jQuery('html') }, events: { transitionEnd : homebrew.events.transitionEnd || 'transitionend oTransitionEnd otransitionend webkitTransitionEnd msTransitionEnd', animationEnd: homebrew.events.animationEnd || 'animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd' }, browser : homebrew.browser, baseURL : (typeof fileUrl === 'string') ? fileUrl : (window.location.href.indexOf('') > -1) ? '' : '' }); if(!FE.$els.pageOverlay.length) { FE.$els.pageOverlay = jQuery('
').appendTo(FE.$els.mainSite); } if(!FE.$els.backToTop.length) { FE.$els.backToTop = jQuery('').appendTo('#mainContent'); FE.$els.backToTop.on('click', function(e) { e.preventDefault(); jQuery('html, body').animate({ scrollTop : 0 }, 400); }); jQuery(window).on('scroll.toggleBackToTop', homebrew.utils.throttle(function() { FE.$els.backToTop.toggleClass('is-shown', jQuery(window).scrollTop() > jQuery(window).height()*0.5); }, 50)); } if(typeof FE.browser === 'undefined') { FE.browser = { ie : FE.$els.root.hasClass('ie'), ie9 : FE.$els.root.hasClass('ie9'), lt9 : FE.$els.root.hasClass('lt9'), ie8 : FE.$els.root.hasClass('ie8'), lt8 : FE.$els.root.hasClass('lt8'), ie7 : FE.$els.root.hasClass('ie7'), firefox : (window.mozIndexedDB !== undefined) } } jQuery.extend(true, FE, { alert : function(args) { this.showAlertPopup(args, 'alert'); }, confirm : function(args) { this.showAlertPopup(args, 'confirm'); }, showAlertPopup : function(args, method) { args = args || {}; var $popup = jQuery('#FE__alertPopup'); if(!$popup.length) { $popup = jQuery([ '
', '

', '' ].join('')).appendTo('body'); $popup.popupify({ addCloseBtns : false, closeOnOverlay : false }); } /* Alerts/Confirm dialog boxes should only happen one at a time, * so if it is already shown, then do not proceed. */ if(jQuery('body').hasClass('popup-is-shown') && $popup.hasClass('is-shown')) { return; } var $title = $popup.find('.title'), $message = $popup.find('.popup-message'), $prevPopup = jQuery('.popup-is-shown').find('.ssf-popup.is-shown'); if(args.title) $title.html(args.title); if(args.message) $message.html(args.message); $popup.find('.cancel-button').toggle(method === 'confirm'); $popup.find('.okay-button, .cancel-button') .off('.alert') .on('click.alert', function() { if($prevPopup.length && typeof $prevPopup.eq(0).data('popupify') !== 'undefined') { $prevPopup.data('popupify').reveal(); } else { $popup.data('popupify').conceal(); } if(typeof args.onConfirm === 'function') { if(method === 'confirm') { args.onConfirm(jQuery(this).is('.okay-button')); } else { args.onConfirm(); } } }); $popup.data('popupify').reveal(); }, FootnoteAnchor : function() { this.init.apply(this, arguments); }, Hasher : function(options) { this.options = options; }, HeightSlider : function(heightSlider) { if(typeof heightSlider === 'string') heightSlider = jQuery(heightSlider); var self = this; jQuery.extend(self, { reveal : function() { if(Modernizr.csstransitions) { if(heightSlider.height() !== 0) return; var targetHeight = 0; heightSlider.css('height', 'auto'); targetHeight = heightSlider.height(); heightSlider.css('height', ''); setTimeout(function() { heightSlider .off(FE.events.transitionEnd) .on(FE.events.transitionEnd, function() { heightSlider .off(FE.events.transitionEnd) .removeClass('is-transitionable') .css('height', '') .addClass('is-toggled'); }) .addClass('is-transitionable') .css('height', targetHeight + 'px'); }, 1); } else { if(heightSlider.css('display') !== 'none') return; heightSlider.slideDown(400, function() { jQuery(this).addClass('is-toggled'); }); } }, conceal : function() { if(Modernizr.csstransitions) { if(heightSlider.height() === 0) return; heightSlider .css('height', heightSlider.height() + 'px') .removeClass('is-toggled'); setTimeout(function() { heightSlider .off(FE.events.transitionEnd) .on(FE.events.transitionEnd, function() { heightSlider.off(FE.events.transitionEnd); heightSlider.removeClass('is-transitionable'); heightSlider.css('height', ''); }) .addClass('is-transitionable') .css('height', '0px'); }, 1); } else { if(heightSlider.css('display') === 'none') return; heightSlider .removeClass('is-toggled') .slideUp(400); } }, toggle : function() { if(Modernizr.csstransitions) { heightSlider.trigger((heightSlider.height() === 0) ? 'reveal' : 'conceal'); } else { heightSlider.trigger((heightSlider.css('display') === 'none') ? 'reveal' : 'conceal'); } } }); heightSlider.data('height-slider', self); }, /* End HeightSlider */ StickyColumn : function() { this.load.apply(this, arguments); }, getHash : function() { var hash = window.location.hash; /* * Need to check if second character is a period; sometimes * AddThis adds its own hash to the URL, and its second * character is always a period, which is problematic. */ if(hash === '' || hash.substr(1,1) === '.') { return ''; } else { return hash; } }, /* End getHash */ getQueryStr: function(str) { var search = window.location.search; if(!search) return false; if(search.substr(0,1) === '?') { search = search.substr(1); } var splitSearch = search.split('&'); keyValuePairs = {}; splitSearch.map(function(searchStr) { var splitSearchStr = searchStr.split('='); splitSearchStr = splitSearchStr.map(function(str) { return jQuery.trim(str); }); keyValuePairs[splitSearchStr[0]] = splitSearchStr[1]; }); if(typeof str === 'string') { return (typeof keyValuePairs[str] === 'undefined') ? false : keyValuePairs[str]; } else { return keyValuePairs; } }, /* End getQueryStr */ initContentTabbers : function() { /* For tabs that toggle contents instead of going to new pages */ jQuery('.js-togglerify-tabs').each(function() { var $this = jQuery(this), $nestedTabs = $this.find('.js-togglerify-tabs').find('.tab'), $tabs = $this.find('.tab').not($nestedTabs), $nestedContents = $this.find('.js-togglerify-tabs').find('.tab-content'), $contents = $this.find('.tab-content').not($nestedContents); $tabs .togglerify('destroy') .togglerify({ toggledClass: 'current', selfToggleable: false, singleActive: true, content: function(index) { return $contents.eq(index); } }) .on('afterToggleOn', function() { jQuery(window).trigger('resize'); }) .on('toggleOff', function(e, $thisTab, $thisContent) { /* Pause videos if available */ $thisContent.find('.video-holder').find('iframe').each(function() { this.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); }); }); }); }, /* End initContentTabbers */ initContentShowers : function() { var types = { TAB: 'tab', TOGGLER: 'toggler', NOTES: 'notes' }, $notesToggler = jQuery('#notesToggler'), $notesContent = jQuery('#notesContent'); jQuery('.js-show-content').each(function() { var $this = jQuery(this), thisHref = $this.attr('href'); if(typeof thisHref !== 'string') { console.log($this); console.error("No target specified. Set the target's ID as the `href` attribute on the element."); return } var $target = jQuery($this.attr('href')); if(!$target.length) { console.log($this); console.error("Target `" + $this.attr('href') + "` does not exist."); return; } var data = $this.data('show-content-options'); if(!data) { console.log($this); console.error('Options undeclared. Declare the options using the `data-show-content-options` attribute on the element.'); return; } var options = (typeof data === 'string') ? homebrew.getKeyValuePairsFromString(data) : {}; if(!options.type) { console.log($this); console.error('Options declared, but no type specified.'); return; } var scrollArgs = [$target]; if(options.smoothScroll !== true) { scrollArgs.push('snap'); } switch(options.type) { case types.TAB: $this.on('click', function(e) { e.preventDefault(); var $tabContent = $target.closest('.tab-content'), $heightSyncers = $tabContent.find('.js-sync-height-wrapper'); if($tabContent.hasClass('current')) { FE.scrollTo.apply(null, scrollArgs); } else { if($heightSyncers.length) { $heightSyncers.last().one('afterSync', function() { FE.scrollTo.apply(null, scrollArgs); }); $tabContent.data('togglerify').toggleOn(); } else { $tabContent.data('togglerify').toggleOn(); FE.scrollTo.apply(null, scrollArgs); } } }); break; case types.NOTES: if(!$notesToggler.length || !$notesContent.length) { return; } $this.on('click', function(e) { e.preventDefault(); if(!$notesToggler.hasClass('is-toggled')) { $notesToggler.togglerify('toggleOn', { noSlide : true }); } FE.scrollTo($target); }); break; default: console.log($this); var errorMsg = [ 'The type `', options.type, '` is not supported. Our currently supported types are: ' ]; jQuery.each(types, function(key, value) { errorMsg.push('\n' + value); }); errorMsg.push('\n\nCheck the type again.'); console.error(errorMsg.join('')); break; } }); }, /* End initContentShowers */ initDropdownSwitchers : function($scope) { var $holders = ($scope && $scope.length) ? $scope.find('.dropdown-switcher-holder') : jQuery('.dropdown-switcher-holder'); if(!$holders.length) return; $holders.each(function() { var $dropdown = jQuery(this).find('.dropdown-switcher'), $contents = jQuery(this).find('.dropdown-content'); $dropdown .on('change', function() { $contents .hide() .eq(this.selectedIndex) .show(); }) .trigger('change'); }); }, initNumberTabbers : function() { jQuery('.number-tabber').each(function() { var $tabs = jQuery(this).find('.number-tabber__tabs').children('li'), $contents = jQuery(this).find('.number-tabber__contents').children('li'); $tabs .togglerify('destroy') .togglerify({ toggledClass: 'current', singleActive: true, selfToggleable: false, content: function(index) { return $contents.eq(index); } }); }); }, /* End initNumberTabbers */ initPage : function() { jQuery('.js-dropdownify').dropdownify(); jQuery('.js-inputify').inputify(); jQuery.each(FE, function(key, value) { if(key.indexOf('init') === 0 && key !== 'initPage') value(); }); FE.loadXMLForm(jQuery('.js-xml-form-holder')); FE.loadXMLTable(jQuery('.js-xml-tbl-holder')); FE.loadXMLLocations(jQuery('.js-xml-locations-holder')); if(FE.browser.ie) jQuery('[placeholder]').placeholderify(); }, /* End initPage */ initSectionSnap : function() { /* Only needed for touchscreens, where the header does not * automatically hide itself. */ if(!Modernizr.touch) return; var hash = FE.getHash(); if(!hash || hash.indexOf('#/') > -1) return; var $hash = jQuery(hash); if(!$hash.length || !$hash.is('.section')) return; setTimeout(function() { FE.scrollTo($hash); }, 25); }, /* End initSectionSnap */ initSelfTogglers : function() { /* Self Togglers - for things like FAQ questions */ jQuery('.self-toggler__toggler').togglerify({ singleActive: false, slide: true, content: function() { return jQuery(this).next(); } }); }, /* End initSelfTogglers */ initSectionContentToggler : function() { /* Section Content togglers - for pages like Popular FAQs */ var $sectionContentTogglers = jQuery('.section-content-toggler'); if(!$sectionContentTogglers.length) return; var $sectionToggleableContents = jQuery('.section-toggleable-content'), $sectionDropdown = jQuery('', '', options.join(''), '', '', '', '', '', '', '', (tooltip) ? '' : '', floaterStr, '

' ].join('')); break; case 'radio': case 'checkbox': var validifyStrArray = ['groupResponse: #response_' + uniqueInputID], validifyRequiredStr = ''; if(required === 'yes') { validifyStrArray.unshift('required: true'); validifyRequiredStr = [ '', '
This input is required.', '
' ].join(''); } var optionsArray = getText($thisInput.find('options')).split('\n'), optionsLabelsArray = getText($thisInput.find('optionsLabels')).split('\n'), options = [], currentOption; for(var i = 0, ii = optionsArray.length; i < ii; i++) { if(optionsArray[i] === '__other_option__') { } else { options.push([ '' ].join('')); } } xmlFormStrArray.push([ '
', '

', label, (required === 'yes') ? '*' : '', (tooltip) ? ' ' : '', ' ', '', '', '', validifyRequiredStr, '', '

', options.join(''), '
' ].join('')); break; } }); xmlFormStrArray.push([ '
', '', '
' ].join('')); $xmlForm.append(xmlFormStrArray.join('')); $xmlForm.find('.icon--question[title]').tooltipify(); var $hiddenIframe = jQuery('