Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
akozenko committed Dec 12, 2014
1 parent d738bed commit bfc4216
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
16 changes: 11 additions & 5 deletions dist/angular-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,10 @@
* @returns {}
*/
var validFunc = function(element, validMessage, validation, callback, ctrl) {
var messageElem = angular.element(document.querySelector('[validator-msg-for="' + ctrl.$name + '"]'));
messageElem = messageElem || element.next();
var messageElem, node = document.querySelector('[validator-msg-for="' + ctrl.$name + '"]');
if ((messageElem = angular.element(node)).length === 0) {
messageElem = element.next();
}
var messageToShow = validMessage || $validationProvider.getDefaultMsg(validation).success;

if ($validationProvider.showSuccessMessage && messageToShow) {
Expand All @@ -331,8 +333,12 @@
* @returns {}
*/
var invalidFunc = function(element, validMessage, validation, callback, ctrl) {
var messageElem = angular.element(document.querySelector('[validator-msg-for="' + ctrl.$name + '"]'));
messageElem = messageElem || element.next();
var messageElem, node = document.querySelector('[validator-msg-for="' + ctrl.$name + '"]');

if ((messageElem = angular.element(node)).length === 0) {
messageElem = element.next();
}
messageElem.css('display', '');

var html = '';
if ($validationProvider.showErrorMessage) {
Expand Down Expand Up @@ -474,7 +480,7 @@
/**
* Valid/Invalid Message
*/
if (!angular.element(document.querySelector('[validator-msg-for="' + ctrl.$name + '"]'))) {
if (!document.querySelector('[validator-msg-for="' + ctrl.$name + '"]')) {
element.after('<span></span>');
}

Expand Down
2 changes: 1 addition & 1 deletion dist/angular-validation.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions src/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
* @returns {}
*/
var validFunc = function(element, validMessage, validation, callback, ctrl) {
var messageElem = angular.element(document.querySelector('[validator-msg-for="' + ctrl.$name + '"]'));
messageElem = messageElem || element.next();
var messageElem, node = document.querySelector('[validator-msg-for="' + ctrl.$name + '"]');
if ((messageElem = angular.element(node)).length === 0) {
messageElem = element.next();
}
var messageToShow = validMessage || $validationProvider.getDefaultMsg(validation).success;

if ($validationProvider.showSuccessMessage && messageToShow) {
Expand All @@ -45,8 +47,12 @@
* @returns {}
*/
var invalidFunc = function(element, validMessage, validation, callback, ctrl) {
var messageElem = angular.element(document.querySelector('[validator-msg-for="' + ctrl.$name + '"]'));
messageElem = messageElem || element.next();
var messageElem, node = document.querySelector('[validator-msg-for="' + ctrl.$name + '"]');

if ((messageElem = angular.element(node)).length === 0) {
messageElem = element.next();
}
messageElem.css('display', '');

var html = '';
if ($validationProvider.showErrorMessage) {
Expand Down Expand Up @@ -188,7 +194,7 @@
/**
* Valid/Invalid Message
*/
if (!angular.element(document.querySelector('[validator-msg-for="' + ctrl.$name + '"]'))) {
if (!document.querySelector('[validator-msg-for="' + ctrl.$name + '"]')) {
element.after('<span></span>');
}

Expand Down

0 comments on commit bfc4216

Please sign in to comment.