@@ -107,7 +107,7 @@ function extensionMap(angular, name) {
107
107
}
108
108
109
109
function jqLiteWrap ( element ) {
110
- if ( typeof element == 'string' ) {
110
+ if ( isString ( element ) ) {
111
111
var div = document . createElement ( 'div' ) ;
112
112
div . innerHTML = element ;
113
113
element = div . childNodes [ 0 ] ;
@@ -126,6 +126,12 @@ function lowercase(value){ return isString(value) ? value.toLowerCase() : value;
126
126
function uppercase ( value ) { return isString ( value ) ? value . toUpperCase ( ) : value ; }
127
127
function trim ( value ) { return isString ( value ) ? value . replace ( / ^ \s * / , '' ) . replace ( / \s * $ / , '' ) : value ; }
128
128
function nodeName ( element ) { return ( element [ 0 ] || element ) . nodeName ; }
129
+
130
+ function isVisible ( element ) {
131
+ var rect = element [ 0 ] . getBoundingClientRect ( ) ;
132
+ return rect . width != 0 && rect . height != 0 ;
133
+ }
134
+
129
135
function map ( obj , iterator , context ) {
130
136
var results = [ ] ;
131
137
foreach ( obj , function ( value , index , list ) {
@@ -1940,6 +1946,11 @@ JQLite.prototype = {
1940
1946
this [ 0 ] . className = trim ( ( " " + this [ 0 ] . className + " " ) . replace ( / [ \n \t ] / g, " " ) . replace ( " " + selector + " " , "" ) ) ;
1941
1947
} ,
1942
1948
1949
+ toggleClass : function ( selector , condition ) {
1950
+ var self = this ;
1951
+ ( condition ? self . addClass : self . removeClass ) . call ( self , selector ) ;
1952
+ } ,
1953
+
1943
1954
addClass : function ( selector ) {
1944
1955
if ( ! this . hasClass ( selector ) ) {
1945
1956
this [ 0 ] . className = trim ( this [ 0 ] . className + ' ' + selector ) ;
@@ -2361,7 +2372,7 @@ var angularFilterGoogleChartApi;
2361
2372
2362
2373
foreach ( {
2363
2374
'currency' : function ( amount ) {
2364
- jQuery ( this . $element ) . toggleClass ( 'ng-format-negative' , amount < 0 ) ;
2375
+ this . $element . toggleClass ( 'ng-format-negative' , amount < 0 ) ;
2365
2376
return '$' + angularFilter [ 'number' ] . apply ( this , [ amount , 2 ] ) ;
2366
2377
} ,
2367
2378
@@ -2397,7 +2408,7 @@ foreach({
2397
2408
} ,
2398
2409
2399
2410
'json' : function ( object ) {
2400
- jQuery ( this . $element ) . addClass ( "ng-monospace" ) ;
2411
+ this . $element . addClass ( "ng-monospace" ) ;
2401
2412
return toJson ( object , true ) ;
2402
2413
} ,
2403
2414
@@ -3124,7 +3135,9 @@ function valueAccessor(scope, element) {
3124
3135
required = required || required === '' ;
3125
3136
if ( ! validator ) throw "Validator named '" + validatorName + "' not found." ;
3126
3137
function validate ( value ) {
3127
- var error = required && ! trim ( value ) ? "Required" : validator ( { state :scope , scope :{ get :scope . $get , set :scope . $set } } , value ) ;
3138
+ var error = required && ! trim ( value ) ?
3139
+ "Required" :
3140
+ validator ( { state :scope , scope :{ get :scope . $get , set :scope . $set } } , value ) ;
3128
3141
if ( error !== lastError ) {
3129
3142
elementError ( element , NG_VALIDATION_ERROR , error ) ;
3130
3143
lastError = error ;
@@ -3450,6 +3463,13 @@ angularService("$invalidWidgets", function(){
3450
3463
if ( index === - 1 )
3451
3464
invalidWidgets . push ( element ) ;
3452
3465
} ;
3466
+ invalidWidgets . visible = function ( ) {
3467
+ var count = 0 ;
3468
+ foreach ( invalidWidgets , function ( widget ) {
3469
+ count = count + ( isVisible ( widget ) ? 1 : 0 ) ;
3470
+ } ) ;
3471
+ return count ;
3472
+ } ;
3453
3473
return invalidWidgets ;
3454
3474
} ) ;
3455
3475
var browserSingleton ;
0 commit comments