Permalink
Browse files

Use bootstrap styles for validation summary. Bumped version.

  • Loading branch information...
1 parent 3e44195 commit 3b39b1b20238b66bc4dbb7aff3ba6a7d5b93498a @jmarnold jmarnold committed May 2, 2012
@@ -1,4 +1,4 @@
-// fubuvalidation.js v0.2.4
+// fubuvalidation.js v0.3.5
//
// Copyright (C)2011 Joshua Arnold
// Distributed under Apache License, Version 2.0
@@ -16,7 +16,7 @@
matches: function (context) { return true; },
reset: function (context) {
var self = this;
- context.container.html('');
+ context.container.find('.validation-summary').html('');
context.container.hide();
$('.error', context.form).each(function () {
@@ -25,8 +25,9 @@
},
process: function (context) {
var self = this;
- var container = $('.validation-summary', context.form);
+ var container = $('.validation-container', context.form);
context.container = container;
+ context.summary = container.find('ul.validation-summary');
this.reset(context);
if (context.errors.length == 0) {
@@ -43,7 +44,7 @@
append: function (context, error) {
var found = false;
context
- .container
+ .summary
.find("li[data-field='" + error.field + "']")
.each(function () {
if (found) return;
@@ -60,9 +61,9 @@
token: self.generateToken(error)
}));
token.find('a').click(function () {
- self.findElement(context, error.field).focus();
+ $.fubuvalidation.findElement(context, error.field).focus();
});
- context.container.append(token);
+ context.summary.append(token);
}
},
generateToken: function (error) {
@@ -164,7 +165,7 @@
$.fn.resetForm = function () {
var context = {
form: $(this),
- container: $('.validation-summary', $(this))
+ container: $('.validation-container', $(this))
};
$.fubuvalidation.defaultHandler.reset(context);
reset.call(this);
@@ -1,5 +1,8 @@
<form id="test" action="/test" method="post">
- <ul class="validation-summary" style="display:none;"></ul>
+ <div class="alert-message block-message validation-container" style="display:none;">
+ <p>There are errors with the information you provided.</p>
+ <ul class="validation-summary"></ul>
+ </div>
<fieldset>
<div class="col">
<label for="FirstName">First Name *</label>
@@ -69,9 +69,9 @@ describe('Default validation handler integrated tests', function () {
it('should show validation summary', function() {
process();
- expect($('#test > .validation-summary').is(':visible')).toEqual(true);
+ expect($('#test > .validation-container').is(':visible')).toEqual(true);
});
-
+
it('should only highlight fields with errors', function() {
process();
expect($('#FirstName', '#test').hasClass('error')).toEqual(true);
@@ -84,7 +84,7 @@ describe('Default validation handler integrated tests', function () {
theContinuation.errors.length = 0;
process();
- expect($('#test > .validation-summary').is(':visible')).toEqual(false);
+ expect($('#test > .validation-container').is(':visible')).toEqual(false);
});
it('should unhighlight fields when validation succeeds', function() {
@@ -102,7 +102,7 @@ describe('Default validation handler integrated tests', function () {
var token = $.fubuvalidation.defaultHandler.generateToken(error);
var found = false;
- $('#test > .validation-summary > li').each(function() {
+ $('#test > .validation-container > .validation-summary > li').each(function() {
if($('a', this).html() == token) {
found = true;
}
@@ -158,7 +158,7 @@ describe('jquery.continuations and fubuvalidation.js integration tests', functio
var token = $.fubuvalidation.defaultHandler.generateToken(error);
var found = false;
- $('#test > .validation-summary > li').each(function() {
+ $('#test > .validation-container > .validation-summary > li').each(function() {
if($('a', this).html() == token) {
found = true;
}
@@ -176,8 +176,8 @@ describe('jquery.continuations and fubuvalidation.js integration tests', functio
waits(500);
runs(function() {
- expect($('#test > .validation-summary').is(':visible')).toEqual(false);
- expect($('#test > .validation-summary > li').size()).toEqual(0);
+ expect($('#test > .validation-container').is(':visible')).toEqual(false);
+ expect($('#test > .validation-container > .validation-summary > li').size()).toEqual(0);
expect($('#FirstName', '#test').hasClass('error')).toEqual(false);
});

0 comments on commit 3b39b1b

Please sign in to comment.