Skip to content

Instantly share code, notes, and snippets.

@salsalabs
Last active March 2, 2018 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salsalabs/5f0e2f7656b202809d28cd3907c3ea1e to your computer and use it in GitHub Desktop.
Save salsalabs/5f0e2f7656b202809d28cd3907c3ea1e to your computer and use it in GitHub Desktop.
Script to change the labels and add placeholders to the address and zip fields on the first page of an Advocacy 4 action. Also does some decoration. See
<!-- BEGIN: Change the appearance of the first page of an Advocacy 4 action. -->
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
if (RegExp('action4/common/public/\\?action_KEY=\\d+').test(window.location.href)) {
var tempAddress = document.querySelector('#tempAddress');
if (tempAddress != null) {
var tempAddressLabel = tempAddress.parentNode.querySelector('label');
if (tempAddressLabel != null) {
tempAddressLabel.innerHTML = document.getElementById('address-label').innerHTML;
}
tempAddress.setAttribute('placeholder', document.getElementById('address-placeholder').innerHTML);
}
var tempZip = document.querySelector('#tempZip2');
if (tempZip != null) {
var tempZipLabel = tempZip.parentNode.querySelector('label');
if (tempZipLabel != null) {
tempZipLabel.innerHTML = document.getElementById('zip-label').innerHTML;
}
tempZip.setAttribute('placeholder', document.getElementById('zip-placeholder').innerHTML);
}
}
})
</script>
<style type="text/css">
/* CSS to
1. Line up the input fields.
2. Change the font size to be a bit larger.
3. Make the address field longer.
4. Fancy-up the submit button.
5. Put a thin grey line between the action copy and the input form.
Optional. Change or remove as needed. */
#addressform {
margin-bottom: 20px;
}
#addressform label{
font-size: 1.0em;
min-width: 160px;
display: inline-block;
}
#addressform input {
font-size: 1.0em;
}
#tempAddress {
min-width: 200px;
}
#tempZip2 {
min-width: 100px;
}
#addressform input[type="button"] {
background-color: #449d44;
border-color: #398439;
border-radius: 10px;
color: #fff;
font-size: 1.2em;
margin-left: 175px;
margin-top: 15px;
padding: 7px 15px 7px 15px;
}
#postalCodeForm {
border-top: 1pt solid lightgray;
margin-top: 20px;
padding-top: 20px;
}
</style>
<div style="display: none;">
<!-- Configure prompts here. -->
<div id="address-label">Your street address<span class="required">*</span></div>
<div id="address-placeholder">12345 Honey Hammock Hill</div>
<div id="zip-label">ZIP code (5 digits)<span class="required">*</span></div>
<div id="zip-placeholder">NNNNN</div>
</div>
<!-- END: Change the appearance of the first page of an Advocacy 4 action. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment