Skip to content

Commit

Permalink
Fix a few linting issues in form feedback JS
Browse files Browse the repository at this point in the history
* Add missing semicola
* Better escaping of EOL
* Swap misleading unused variable for "Do not use 'new' for side effects"'
  (which I haven't fixed but found it's a more truthful error message)
  • Loading branch information
selfthinker committed Oct 10, 2016
1 parent e897eed commit 20d33c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/report-a-problem-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
$form.on('submit', this.submit.bind(this));

this.appendHiddenContextInformation();
}
};

ReportAProblemForm.prototype.appendHiddenContextInformation = function() {
// form submission for reporting a problem
Expand Down Expand Up @@ -46,7 +46,7 @@

ReportAProblemForm.prototype.setUrl = function() {
this.$form.find('input#url').val(window.location);
}
};

ReportAProblemForm.prototype.postFormViaAjax = function() {
$.ajax({
Expand Down
26 changes: 12 additions & 14 deletions app/assets/javascripts/report-a-problem.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

var ReportAProblem = function ($container) {
this.$container = $container;
var $form = $container.find('form'),
form = new GOVUK.ReportAProblemForm($form);
var $form = $container.find('form');
new GOVUK.ReportAProblemForm($form);

$form.on("reportAProblemForm.success", this.showConfirmation.bind(this));
$form.on("reportAProblemForm.error", this.showError.bind(this));
Expand All @@ -15,12 +15,11 @@
};

ReportAProblem.prototype.addToggleLink = function() {
this.$container.before('\
<div class="report-a-problem-toggle-wrapper js-footer">\
<p class="report-a-problem-toggle">\
<a href="" class="js-report-a-problem-toggle">Is there anything wrong with this page?</a>\
</p>\
</div>');
this.$container.before('<div class="report-a-problem-toggle-wrapper js-footer">' +
'<p class="report-a-problem-toggle">' +
'<a href="" class="js-report-a-problem-toggle">Is there anything wrong with this page?</a>' +
'</p>' +
'</div>');
};

ReportAProblem.prototype.toggleForm = function(evt) {
Expand All @@ -39,16 +38,15 @@

ReportAProblem.prototype.showConfirmation = function(evt, data) {
this.$container.find('.report-a-problem-content').html(data.message);
}
};

ReportAProblem.prototype.showError = function() {
var response = "\
<h2>Sorry, we’re unable to receive your message right now.</h2>\
<p>We have other ways for you to provide feedback on the \
<a href='/contact'>contact page</a>.</p>";
var response = '<h2>Sorry, we’re unable to receive your message right now.</h2>' +
'<p>We have other ways for you to provide feedback on the ' +
'<a href="/contact">contact page</a>.</p>';

this.$container.find('.report-a-problem-content').html(response);
}
};

ReportAProblem.prototype.trackEvent = function(action){
if (GOVUK.analytics && GOVUK.analytics.trackEvent) {
Expand Down

0 comments on commit 20d33c8

Please sign in to comment.