@hmcts/frontend
Advanced tools
Comparing version 0.0.30-alpha to 0.0.31-alpha
29
all.js
@@ -192,3 +192,2 @@ var HMCTSFrontend = {}; | ||
this.summary = (options && options.summary) ? $(options.summary) : $('.govuk-error-summary'); | ||
// this.summary.on('click', 'a', $.proxy(this, 'onErrorClick')); | ||
this.originalTitle = document.title; | ||
@@ -208,3 +207,3 @@ }; | ||
HMCTSFrontend.FormValidator.escapeHtml = function(string) { | ||
HMCTSFrontend.FormValidator.prototype.escapeHtml = function(string) { | ||
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) { | ||
@@ -215,9 +214,2 @@ return HMCTSFrontend.FormValidator.entityMap[s]; | ||
HMCTSFrontend.FormValidator.prototype.onErrorClick = function(e) { | ||
e.preventDefault(); | ||
var href = e.target.href; | ||
var id = href.substring(href.indexOf("#"), href.length); | ||
$(id).focus(); | ||
}; | ||
HMCTSFrontend.FormValidator.prototype.resetTitle = function() { | ||
@@ -245,4 +237,4 @@ document.title = this.originalTitle; | ||
html += '<li>'; | ||
html += '<a href="#' + HMCTSFrontend.FormValidator.escapeHtml(error.fieldName) + '">'; | ||
html += HMCTSFrontend.FormValidator.escapeHtml(error.message); | ||
html += '<a href="#' + this.escapeHtml(error.fieldName) + '">'; | ||
html += this.escapeHtml(error.message); | ||
html += '</a>'; | ||
@@ -281,3 +273,3 @@ html += '</li>'; | ||
var errorSpanId = error.fieldName + '-error'; | ||
var errorSpan = '<span class="govuk-error-message" id="'+ errorSpanId +'">'+HMCTSFrontend.FormValidator.escapeHtml(error.message)+'</span>'; | ||
var errorSpan = '<span class="govuk-error-message" id="'+ errorSpanId +'">'+this.escapeHtml(error.message)+'</span>'; | ||
var control = $("#" + error.fieldName); | ||
@@ -329,3 +321,3 @@ var fieldContainer = control.parents(".govuk-form-group"); | ||
var validator = null, | ||
validatorValid = true, | ||
validatorReturnValue = true, | ||
i, | ||
@@ -336,5 +328,6 @@ j; | ||
for (j = 0; j < validator.rules.length; j++) { | ||
validatorValid = validator.rules[j].method(validator.field, | ||
validatorReturnValue = validator.rules[j].method(validator.field, | ||
validator.rules[j].params); | ||
if (!validatorValid) { | ||
if (typeof validatorReturnValue === 'boolean' && !validatorReturnValue) { | ||
this.errors.push({ | ||
@@ -345,2 +338,8 @@ fieldName: validator.fieldName, | ||
break; | ||
} else if(typeof validatorReturnValue === 'string') { | ||
this.errors.push({ | ||
fieldName: validatorReturnValue, | ||
message: validator.rules[j].message | ||
}); | ||
break; | ||
} | ||
@@ -347,0 +346,0 @@ } |
@@ -7,3 +7,2 @@ HMCTSFrontend.FormValidator = function(form, options) { | ||
this.summary = (options && options.summary) ? $(options.summary) : $('.govuk-error-summary'); | ||
// this.summary.on('click', 'a', $.proxy(this, 'onErrorClick')); | ||
this.originalTitle = document.title; | ||
@@ -23,3 +22,3 @@ }; | ||
HMCTSFrontend.FormValidator.escapeHtml = function(string) { | ||
HMCTSFrontend.FormValidator.prototype.escapeHtml = function(string) { | ||
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) { | ||
@@ -30,9 +29,2 @@ return HMCTSFrontend.FormValidator.entityMap[s]; | ||
HMCTSFrontend.FormValidator.prototype.onErrorClick = function(e) { | ||
e.preventDefault(); | ||
var href = e.target.href; | ||
var id = href.substring(href.indexOf("#"), href.length); | ||
$(id).focus(); | ||
}; | ||
HMCTSFrontend.FormValidator.prototype.resetTitle = function() { | ||
@@ -60,4 +52,4 @@ document.title = this.originalTitle; | ||
html += '<li>'; | ||
html += '<a href="#' + HMCTSFrontend.FormValidator.escapeHtml(error.fieldName) + '">'; | ||
html += HMCTSFrontend.FormValidator.escapeHtml(error.message); | ||
html += '<a href="#' + this.escapeHtml(error.fieldName) + '">'; | ||
html += this.escapeHtml(error.message); | ||
html += '</a>'; | ||
@@ -96,3 +88,3 @@ html += '</li>'; | ||
var errorSpanId = error.fieldName + '-error'; | ||
var errorSpan = '<span class="govuk-error-message" id="'+ errorSpanId +'">'+HMCTSFrontend.FormValidator.escapeHtml(error.message)+'</span>'; | ||
var errorSpan = '<span class="govuk-error-message" id="'+ errorSpanId +'">'+this.escapeHtml(error.message)+'</span>'; | ||
var control = $("#" + error.fieldName); | ||
@@ -144,3 +136,3 @@ var fieldContainer = control.parents(".govuk-form-group"); | ||
var validator = null, | ||
validatorValid = true, | ||
validatorReturnValue = true, | ||
i, | ||
@@ -151,5 +143,6 @@ j; | ||
for (j = 0; j < validator.rules.length; j++) { | ||
validatorValid = validator.rules[j].method(validator.field, | ||
validatorReturnValue = validator.rules[j].method(validator.field, | ||
validator.rules[j].params); | ||
if (!validatorValid) { | ||
if (typeof validatorReturnValue === 'boolean' && !validatorReturnValue) { | ||
this.errors.push({ | ||
@@ -160,2 +153,8 @@ fieldName: validator.fieldName, | ||
break; | ||
} else if(typeof validatorReturnValue === 'string') { | ||
this.errors.push({ | ||
fieldName: validatorReturnValue, | ||
message: validator.rules[j].message | ||
}); | ||
break; | ||
} | ||
@@ -162,0 +161,0 @@ } |
{ | ||
"name": "@hmcts/frontend", | ||
"description": "HMCTS Frontend contains the code you need to start building a user interface for HMCTS.", | ||
"version": "0.0.30-alpha", | ||
"version": "0.0.31-alpha", | ||
"main": "all.js", | ||
@@ -6,0 +6,0 @@ "sass": "all.scss", |
Sorry, the diff of this file is not supported yet
436702
127
9289