-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ECO-294/Form-errors #172
ECO-294/Form-errors #172
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
$(document).ready(function() { | ||
var autoformError = $('#autoform-error').get(0); | ||
if (autoformError) { | ||
autoform.addCloseButtonListener(autoformError); | ||
|
||
var emailInputField = $('#autoform-email').get(0); | ||
emailInputField.addEventListener('click', function (){ | ||
autoform.removeErrors(autoformError) | ||
}); | ||
|
||
var domainInputField = $('#autoform-domain').get(0); | ||
domainInputField.addEventListener('click', function (){ | ||
autoform.removeErrors(autoformError) | ||
}); | ||
} | ||
|
||
$('#autoform-form').submit(function() { | ||
if ($('#autoform-email').val() == '' || $('#autoform-domain').val() == '') { | ||
$('#autoform-form-sent').hide(); | ||
|
@@ -29,33 +44,19 @@ $(document).ready(function() { | |
return true; | ||
} | ||
}); | ||
|
||
var autoformError = $('#autoform-error').get(0); | ||
addCloseButtonListener(autoformError); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jsuchal chcel som označiť tento riadok, keď sa nenájde autoformError z predchádzajúceho riadku nič sa nestane, no keď sa potom posunie do funkcie |
||
|
||
var emailInputField = $('#autoform-email').get(0); | ||
emailInputField.addEventListener('click', function (){ | ||
removeErrors(autoformError) | ||
}); | ||
|
||
var domainInputField = $('#autoform-domain').get(0); | ||
domainInputField.addEventListener('click', function (){ | ||
removeErrors(autoformError) | ||
}); | ||
}); | ||
|
||
function addCloseButtonListener(node) { | ||
var closeButton = node.querySelector('.alert .close'); | ||
closeButton.addEventListener("click", function (){ | ||
removeErrors(node); | ||
}); | ||
} | ||
|
||
function removeErrors(node) { | ||
$('#autoform-email').parent('.form-group').removeClass('has-error'); | ||
$('#autoform-domain').parent('.form-group').removeClass('has-error'); | ||
$('#' + node.id).hide(); | ||
} | ||
|
||
|
||
|
||
var autoform = { | ||
addCloseButtonListener: function(node) { | ||
var closeButton = node.querySelector('.alert .close'); | ||
closeButton.addEventListener("click", function (){ | ||
autoform.removeErrors(node); | ||
}); | ||
}, | ||
|
||
removeErrors: function(node) { | ||
$('#autoform-email').parent('.form-group').removeClass('has-error'); | ||
$('#autoform-domain').parent('.form-group').removeClass('has-error'); | ||
$('#' + node.id).hide(); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,10 +53,17 @@ | |
<p class="lead">Nechajte nám Váš emailový kontakt alebo nám napíšte na <a href="mailto:[email protected]">[email protected]</a>.</p> | ||
|
||
<div id="consultations-error" style="display: none;"> | ||
<%= render 'services/share/flash_message', {type: :alert, message: 'Vyplňte prosím email a skúste znova.'} %> | ||
<div class="alert alert-danger alert-dismissible" role="alert"> | ||
<button type="button" class="close" aria-label="Close"><span aria-hidden="true" class="error">×</span></button> | ||
<%= 'Vyplňte prosím email a skúste znova.' %> | ||
</div> | ||
</div> | ||
<div id="consultations-form-sent" style="display: none;"> | ||
<%= render 'services/share/flash_message', {type: :notice, message: 'Ďakujeme, za Váš záujem. Budeme Vás kontaktovať cez zadaný email.'} %> | ||
<div class="alert alert-success alert-dismissible" role="alert"> | ||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true" class="success">×</span> | ||
</button> | ||
<%= 'Ďakujeme, za Váš záujem. Budeme Vás kontaktovať cez zadaný email.' %> | ||
</div> | ||
</div> | ||
|
||
<iframe name="form-result" style="display: none;"></iframe> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuchal konkretne tato cast, ktora hladala na kazdej pagy autoform classy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ale ved to by nemalo vadit nie? Nenajde tak nie je problem.