/* form', this); $frm.addClass('gform'); if ( $('.gfield_error:visible', $frm).length > 0 ) { $frm.addClass('gform-has-errors'); }; var $gfH = $('.gform_heading', $frm), $gfB = $('.gform_body', $frm), $gfF = $('.gform_footer', $frm); // Wrap body & footer for easy positioning of submit button if ( $('.gform_guts', $frm).length == 0 ) { // Only process this once $gfB.before('
'); $gfB.add($gfF).appendTo($('.gform_guts', $frm)); }; var gfID = 1; // Default start for numbering try { gfID = parseInt(element.id.replace(/^gform_wrapper_/i, '')); } catch(e) {}; // Get GForm ID var tL = 1000*gfID, tR = (1000*gfID + 1000); // Set starter tabIndex // Set tab indices for column-based layouts using gf-left and gf-right classes $('ul.gform_fields', this).addClass('clearfix').find('> li').each(function(index, element) { var $li = $(element); $('input, select, textarea', $li).each(function(index, element) { if ( $li.hasClass('gf-left') ) { $(element).attr('tabIndex', ++tL); } else if ( $li.hasClass('gf-right') ) { $(element).attr('tabIndex', ++tR); } else { $(element).attr('tabIndex', ++tL); }; }); $('label', $li).each(function(index, element) { $(element).attr('title', $(element).text().replace(/\*/, '')); // Remove asterisk }); }); // Prevent auto-complete on CAPTCHA $('.gfield_captcha_input_container input', this).attr('autocomplete','off').attr('tabIndex', ++tR); // Set Submit button tooltip, class & clear $('input:submit', this).each(function(index, element) { var $el = $(this); $el.attr('title', $el.val()).enableMe().addClass('gf-button-submit').attr('tabIndex', ++tR).after('
'); /* * Disable & modify text on form submit (submit button click event is fired onsubmit) * Must use evt.preventDefault() or GF will ignore code. Not advisable to prevent default frm.submit() * because you can't fire event afterwards. Use this with caution! */ $el.click(function(evt) { evt.preventDefault(); $el.val('Processing...').disableMe(); $frm.submit(); return true; }); }); // Add lightbox class to body if form has a parent with class "colorbox" if ( $(this).parents('.colorbox').length > 0 ) { $('body').addClass('has-gform-lightbox'); }; // Initialize 'enhanced' dropdowns try { $('select[multiple]', this).chosen({no_results_text: "No results found"}); } catch(e) {}; /* * If form is in error, scroll to error message first, then scroll on to error field * after a short delay to allow error message to be seen first. */ if ( $frm.hasClass('gform-has-errors') ) { var $fErr = $('.gfield_error', $frm); if ( $fErr.length > 0 ) { $('html, body').scrollTop( $('.validation_error', $frm).offset().top - twig_admin_bump ); setTimeout(function() { $('html, body').animate({ scrollTop: ($fErr.slice(0, 1).offset().top - twig_admin_bump) }, 500); }, 1500); }; }; }); }); twig_gforms(); // Fire initially $(document).on('gform_post_render', function() { // Fired with any page AJAX-enabled change/error/success: http://www.gravityhelp.com/documentation/page/Gform_post_render twig_gforms(); // Update Ajax-rendered code }); $(document).on('gform_confirmation_loaded', function() { // Fired only when success page is displayed: http://www.gravityhelp.com/documentation/page/Gform_confirmation_loaded if ( $.fn.colorbox ) { if ( $('body').hasClass('has-gform-lightbox') ) { // See above for this class addition // Retarget lightbox to success element, not the form wrapper to prevent stale results being displayed var $el = $.colorbox.element(); // opening element $el.colorbox({ href: '#gforms_confirmation_message' }); }; }; }); /* * Pardot dynamic iframe handling * * Defining document.domain at top of page allows access to iframe'd content using the iframe.document scope (el) * - this must be matched in pardot.js used in the iframe'd content too. However, this may cause problems with plugins * that expect the domain to match the WP url (notably Gravity Forms). * * Note that Pardot plugin does not expose id or name attributes to