initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
24
static/js/directives/ng-image-watch.js
Normal file
24
static/js/directives/ng-image-watch.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Adds a ng-image-watch attribute, which is a callback invoked when the image is loaded or fails.
|
||||
*/
|
||||
angular.module('quay').directive('ngImageWatch', function ($parse) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
compile: function($element, attr) {
|
||||
var fn = $parse(attr['ngImageWatch']);
|
||||
return function(scope, element) {
|
||||
element.bind('error', function() {
|
||||
scope.$apply(function() {
|
||||
fn(scope, {result: false});
|
||||
})
|
||||
});
|
||||
|
||||
element.bind('load', function() {
|
||||
scope.$apply(function() {
|
||||
fn(scope, {result: true});
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
Reference in a new issue