// JavaScript Document $( document ).ready(function() { // Desktop if ((!navigator.userAgent.match(/Mobi/))&&($(window).width() > 768)) { var itsout = function () { $(this).removeClass("open"); $(this).find("a").addClass('collapsed'); }; $('.dropdown').bind('mouseout', itsout); $("header#top .dropdown a.dropdown-toggle").click(function() { if (!$(this).parent().hasClass('open')) { $(this).parent().addClass('open'); $(this).removeClass('collapsed'); $(this).parent().siblings().removeClass("open"); $(this).parent().siblings().find("a.dropdown-toggle").addClass('collapsed'); } else { $(this).parent().removeClass('open'); $(this).addClass('collapsed'); } }); } // iPhone/smartphone if ((navigator.userAgent.match(/Mobi/))&&($(window).width() < 768)) { $("header#top .dropdown a.dropdown-toggle").click(function() { if($(this).parent().hasClass('open')) { $(this).parent().removeClass('open'); $(this).addClass('collapsed'); } else { $(this).parent().addClass('open'); $(this).removeClass('collapsed'); } }); $(":not(.popover)").click(function() { $('[data-toggle="popover"]').each(function (e) { //the 'is' for buttons that trigger popups //the 'has' for icons within a button that triggers a popup if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { $(this).popover('hide'); } }); }); } // Tablet + Phablet if ((navigator.userAgent.match(/Mobi/))&&($(window).width() >= 768)) { var tabletOut = function () { $(this).removeClass("open"); $(this).find("a").addClass('collapsed'); $("video").attr("controls", "controls"); }; var tabletIn = function () { $(this).addClass("open"); $(this).find("a").removeClass('collapsed'); $("video").removeAttr("controls"); }; $('.dropdown').bind('click', tabletIn); $(':not(.dropdown)').bind('click', tabletOut); } // Desktop but smartphone size if ((!navigator.userAgent.match(/Mobi/))&&($(window).width() < 768)) { // do stuff $("header#top .dropdown a.dropdown-toggle").click(function() { if($(this).parent().hasClass('open')) { $(this).parent().removeClass('open'); $(this).addClass('collapsed'); } else { $(this).parent().addClass('open'); $(this).removeClass('collapsed'); } }); } // Must debounce to keep resize event from firing repeatedly (function($,sr){ // debouncing function from John Hann // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ var debounce = function (func, threshold, execAsap) { var timeout; return function debounced () { var obj = this, args = arguments; function delayed () { if (!execAsap) func.apply(obj, args); timeout = null; }; if (timeout) clearTimeout(timeout); else if (execAsap) func.apply(obj, args); timeout = setTimeout(delayed, threshold || 200); }; } // smartresize jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; })(jQuery,'smartresize'); // Desktop resize to smartphone size using smartresize $(window).smartresize(function() { if ((!navigator.userAgent.match(/Mobi/))&&($(window).width() < 768)) { // Make nav act like it does on mobile $('.dropdown').unbind('mouseout', itsout); } }); $('.uhc-search').on('shown.bs.collapse', function (e) { $("input[name=premember-search]").focus(); }) if(window.location.hash) { clicker = window.location.hash + 'view'; $(clicker).click(); } $("body").popover({selector: '[data-toggle="popover"]', trigger: 'click hover focus'}); $(".more-about").click(function() { if ($(this).hasClass("collapsed")) { $(this).children("span.moreless").text("- Less about"); } else { $(this).children("span.moreless").text("+ More about"); } }); $(".content-expander").click(function () { if($(this).hasClass("collapsed")) { $(this).children("span.glyphicon").removeClass("glyphicon-plus-sign").addClass("glyphicon-minus-sign"); } else { $(this).children("span.glyphicon").removeClass("glyphicon-minus-sign").addClass("glyphicon-plus-sign"); } }); // popover can be closed by clicking outside of itself $('html').on('click', function(e) { if (typeof $(e.target).data('original-title') == 'undefined' && !$(e.target).parents().is('.popover.in')) { $('[data-original-title]').popover('hide'); } }); $('.ttip').click(function(){ $('.ttip').not(this).popover('hide'); //all but this }); $('.closepopover').click(function(){ $('.ttip').popover('hide'); }); $('.closemodal').live('click',function(){ $('.modal').modal('hide'); }); $('.blue.hidden-xs a.icon-link').each(function(){ if($(this).height() > 20){ $(this).parent().addClass('padding-top-sm'); } else { $(this).parent().addClass('padding-top-md'); } }); });