aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Angular.js4
-rw-r--r--src/Formatters.js6
-rw-r--r--src/Widgets.js4
3 files changed, 11 insertions, 3 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 3c88c6b7..ded4485f 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -97,6 +97,10 @@ function isLeafNode (node) {
}
}
+function isVisible(element) {
+ return jQuery(element).is(":visible");
+}
+
function setHtml(node, html) {
if (isLeafNode(node)) {
if (msie) {
diff --git a/src/Formatters.js b/src/Formatters.js
index 661dd701..6aa832af 100644
--- a/src/Formatters.js
+++ b/src/Formatters.js
@@ -1,4 +1,4 @@
-function formater(format, parse) {return {'format':format, 'parse':parse};}
+function formater(format, parse) {return {'format':format, 'parse':parse || format};}
function toString(obj) {return ""+obj;};
extend(angularFormatter, {
'noop':formater(identity, identity),
@@ -10,5 +10,9 @@ extend(angularFormatter, {
function(value) {
return value ? _(_(value.split(',')).map(jQuery.trim)).select(_.identity) : [];
}
+ ),
+
+ 'trim':formater(
+ function(obj) { return obj ? $.trim("" + obj) : ""; }
)
});
diff --git a/src/Widgets.js b/src/Widgets.js
index c5ab7c6f..01877128 100644
--- a/src/Widgets.js
+++ b/src/Widgets.js
@@ -230,7 +230,7 @@ TextController.prototype = {
var isValidationError = false;
view.removeAttribute('ng-error');
if (this.required) {
- isValidationError = !(value && $.trim(value).length > 0);
+ isValidationError = !(value && $.trim("" + value).length > 0);
}
var errorText = isValidationError ? "Required Value" : null;
if (!isValidationError && this.validator && value) {
@@ -239,7 +239,7 @@ TextController.prototype = {
}
if (this.lastErrorText !== errorText) {
this.lastErrorText = isValidationError;
- if (errorText !== null) {
+ if (errorText !== null && isVisible(view)) {
view.setAttribute('ng-error', errorText);
scope.markInvalid(this);
}