Created
June 9, 2021 15:09
-
-
Save dmurphy1/80353db25cab988555be584f6c9ac629 to your computer and use it in GitHub Desktop.
Snippet from theme.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(window).on('load', function() { | |
// Add data attribute for each Marketo form wrapper. | |
window.FormsPlus = window.FormsPlus || { | |
allDescriptors: {}, | |
allMessages: {}, | |
detours: {} | |
}; | |
/*! @author Sanford Whiteman @license MIT */ | |
FormsPlus.tagWrappers = function tagWrappers() { | |
/* common vars & aliases */ | |
var ANCESTORS_STOR = '.mktoFormRow, .mktoFormCol', | |
INPUTS_STOR = 'INPUT,SELECT,TEXTAREA,BUTTON', | |
attrTag = 'data-wrapper-for', | |
_forEach = Array.prototype.forEach; | |
/* utility fn to tag wrapper containers with inner form inputs */ | |
function tagMktoWrappers(formEl) { | |
_forEach.call(formEl.querySelectorAll(ANCESTORS_STOR), function(ancestor) { | |
ancestor.setAttribute(attrTag, ''); | |
_forEach.call(ancestor.querySelectorAll(INPUTS_STOR), function(input) { | |
var currentTag = ancestor.getAttribute(attrTag); | |
ancestor.setAttribute(attrTag, [currentTag ? currentTag : '', input.id, input.name != input.id ? input.name : ''].join(' ').trim()); | |
}); | |
}); | |
} | |
MktoForms2.whenRendered(function(form) { | |
var formEl = form.getFormElem()[0]; | |
tagMktoWrappers(formEl); | |
}); | |
}; | |
FormsPlus.tagWrappers(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment