This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/directives/file-present.js
Joseph Schorr b3fcd3f84e Better build dialog UX
We now automatically validate the chosen Dockerfile/archive, and automatically check to see if a robot is needed
2015-08-20 13:41:08 -04:00

37 lines
No EOL
975 B
JavaScript

/**
* Sets the 'filePresent' value on the scope if a file on the marked <input type="file"> exists.
*/
angular.module('quay').directive("filePresent", [function () {
return {
restrict: 'A',
scope: {
'filePresent': "="
},
link: function (scope, element, attributes) {
element.bind("change", function (changeEvent) {
scope.$apply(function() {
scope.filePresent = changeEvent.target.files.length > 0;
});
});
}
}
}]);
/**
* Raises the 'filesChanged' event on the scope if a file on the marked <input type="file"> exists.
*/
angular.module('quay').directive("filesChanged", [function () {
return {
restrict: 'A',
scope: {
'filesChanged': "&"
},
link: function (scope, element, attributes) {
element.bind("change", function (changeEvent) {
scope.$apply(function() {
scope.filesChanged({'files': changeEvent.target.files});
});
});
}
}
}]);