@@ -12,35 +12,37 @@ angular.module('wmProfile.directives', [])
1212 }
1313 } ;
1414 } )
15- . directive ( 'wmpSrc' , [ 'jQuery' , function ( jQuery ) {
16- // Add wmp-src to an img to only give it a src if the target is loadable
17- // This prevents broken images from displaying and creates hooks for other display logic
18- return {
19- restrict : 'A' ,
20- scope : {
21- url : '@wmpSrc' ,
22- didFail : '=wmpSrcFailed'
23- } ,
24- link : function ( $scope , el , attrs ) {
25- var elLoader = jQuery ( '<img>' ) ;
26- el . fadeTo ( 0 , 0 ) ;
27-
28- elLoader . on ( 'load' , function ( ) {
29- el . attr ( 'src' , $scope . url ) . fadeTo ( 200 , 1 ) ;
30- $scope . didFail = false ;
31- $scope . $apply ( ) ;
32- } ) ;
15+ . directive ( 'wmpSrc' , [ 'jQuery' ,
16+ function ( jQuery ) {
17+ // Add wmp-src to an img to only give it a src if the target is loadable
18+ // This prevents broken images from displaying and creates hooks for other display logic
19+ return {
20+ restrict : 'A' ,
21+ scope : {
22+ url : '@wmpSrc' ,
23+ didFail : '=wmpSrcFailed'
24+ } ,
25+ link : function ( $scope , el , attrs ) {
26+ var elLoader = jQuery ( '<img>' ) ;
27+ el . fadeTo ( 0 , 0 ) ;
3328
34- elLoader . on ( 'error' , function ( ) {
35- $scope . didFail = true ;
36- $scope . $apply ( ) ;
37- } ) ;
29+ elLoader . on ( 'load' , function ( ) {
30+ el . attr ( 'src' , $scope . url ) . fadeTo ( 200 , 1 ) ;
31+ $scope . didFail = false ;
32+ $scope . $apply ( ) ;
33+ } ) ;
3834
39- // Attempt to load target image in a non attached IMG element
40- elLoader . attr ( 'src' , $scope . url ) ;
41- }
42- } ;
43- } ] )
35+ elLoader . on ( 'error' , function ( ) {
36+ $scope . didFail = true ;
37+ $scope . $apply ( ) ;
38+ } ) ;
39+
40+ // Attempt to load target image in a non attached IMG element
41+ elLoader . attr ( 'src' , $scope . url ) ;
42+ }
43+ } ;
44+ }
45+ ] )
4446 . directive ( 'wmpLogin' , [ '$rootScope' ,
4547 function ( $rootScope ) {
4648 return {
0 commit comments