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/ui/namespace-input.js

33 lines
948 B
JavaScript
Raw Normal View History

/**
* An element which displays an input box for creating a namespace.
*/
angular.module('quay').directive('namespaceInput', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/namespace-input.html',
replace: false,
transclude: true,
restrict: 'C',
scope: {
'binding': '=binding',
'isBackIncompat': '=isBackIncompat',
'hasExternalError': '=?hasExternalError',
'namespaceTitle': '@namespaceTitle',
},
controller: function($scope, $element) {
$scope.USERNAME_PATTERN = USERNAME_PATTERN;
$scope.usernamePattern = new RegExp(USERNAME_PATTERN);
$scope.$watch('binding', function(binding) {
if (!binding) {
$scope.isBackIncompat = false;
return;
}
$scope.isBackIncompat = (binding.indexOf('-') > 0 || binding.indexOf('.') > 0);
})
}
};
return directiveDefinitionObject;
});