"+errors[error]+""); $('body, html').animate({scrollTop:$(this).parent().offset().top}, 'slow'); } $(".errors").fadeIn(); return false; } }); updateNav(); // When the page first loads $(window).resize(function(){ updateNav(); }); $('#mobile-nav').click(function(e){ $('body').toggleClass('nav-open'); }); // force twitter button to re-init, and thus put screen name in: // broken due to being hidden initially. // from https://dev.twitter.com/discussions/6785 - maxb var reloadTwitterIframe = function() { var twitterIFrames = $('iframe.twitter-follow-button'); twitterIFrames.each(function(index,element) { try { var $e = $(element); var $clone = $e.clone(); $e.replaceWith($clone); } catch (e) { element.setAttribute('src',element.getAttribute('src')); } }); } $('iframe.twitter-follow-button').on('load', reloadTwitterIframe); reloadTwitterIframe(); }); function updateNav(){ // Get the dimensions of the viewport var width = $(window).width(); if(width > 768){ $('body').removeClass('nav-open'); $('#header-site-nav nav .navbar-collapse').toggleClass('in'); } } errors = []; var validators = {}; validators.email = function(value) { if ( !/^\s*\S+@\S+\.\S+\s*$/.test(value) ) return false return true; }; validators.zip = function(value){ if ( !/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(value) ) return false; return true; }; $(window).load(function() { var source; if (typeof FormSubmission === 'object' && typeof FormSubmission.data === 'object' && FormSubmission.data.source) { source = FormSubmission.data.source; } else if (getQueryVariable("prefill.source")) { source = getQueryVariable("prefill.source"); } if (source) { $actblueForms = $("form.actblue-donate"); $actblueForms.each(function() { var ref = $(this).find("input[name=refcode]"); if (ref.length) { ref.val(source); } }); } });