-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 38203-load-recaptcha-on-focus-only
- Loading branch information
Showing
69 changed files
with
1,005 additions
and
124 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,41 @@ | ||
var form = form || {}; | ||
form.type = form.type || ''; | ||
jQuery(document).ready(function ($) { | ||
if (honeypot_enabled['honeypotValue'] == true && form.type !== '' && form.type !== 'applicantsearch') { | ||
var messageTextarea = $('textarea[name="message"]'); | ||
var messageInput = $('input[name="message"]'); | ||
if(messageTextarea.length === 1){ | ||
messageTextarea.attr('name', 'tmpField'); | ||
} else if (messageInput.length === 1) { | ||
messageInput.attr('name', 'tmpField'); | ||
} | ||
var label = $('<label>').text('Message:').attr("class", "message"); | ||
var input = $('<input>').attr({ | ||
'type': 'text', | ||
'name': 'message', | ||
'class': 'message' | ||
const formElements = getFormsBySpecialHtmlAttribute(); | ||
|
||
addHoneypotToForms(formElements); | ||
|
||
function getFormsBySpecialHtmlAttribute() { | ||
const formElements = []; | ||
const forms = document.querySelectorAll('.oo-form, #onoffice-form'); | ||
|
||
forms.forEach(form => { | ||
const dataAttr = form.getAttribute('data-applicant-form-id'); | ||
if (dataAttr === null) { | ||
formElements.push(form); | ||
} | ||
}); | ||
$("#onoffice-form").prepend(input); | ||
$("#onoffice-form").prepend(label); | ||
var originalInput = $('input[name="message"]'); | ||
originalInput.before(label, input); | ||
|
||
return formElements; | ||
} | ||
|
||
function addHoneypotToForms(formElements) { | ||
formElements.forEach((formElement) => { | ||
const messageTextarea = $(formElement).find('textarea[name="message"]'); | ||
const messageInput = $(formElement).find('input[name="message"]'); | ||
if (messageTextarea.length === 1) { | ||
messageTextarea.attr('name', 'tmpField'); | ||
} else if (messageInput.length === 1) { | ||
messageInput.attr('name', 'tmpField'); | ||
} | ||
const label = $('<label>').text('Message:').attr("class", "message"); | ||
const input = $('<input>').attr({ | ||
'type': 'text', | ||
'name': 'message', | ||
'class': 'message' | ||
}); | ||
$(formElement).prepend(input); | ||
$(formElement).prepend(label); | ||
const originalInput = $(formElement).find('input[name="message"]'); | ||
originalInput.before(label, input); | ||
}); | ||
}; | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
jQuery(document).ready(function ($) { | ||
const formElements = document.querySelectorAll('.oo-form, #onoffice-form'); | ||
|
||
handleFormSubmissions(formElements); | ||
|
||
function handleFormSubmissions(formElements) { | ||
formElements.forEach((formElement) => { | ||
let submitted = false; | ||
const submitButton = $(formElement).find('.submit_button'); | ||
|
||
$(formElement).on('submit', function (event) { | ||
if (submitted) { | ||
event.preventDefault(); | ||
} else { | ||
submitted = true; | ||
} | ||
}); | ||
|
||
submitButton.on('click', function () { | ||
submitButton.prop('disabled', true); | ||
}); | ||
}); | ||
} | ||
}); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.