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/source-ref-link.js
2015-02-26 17:45:28 -05:00

41 lines
1 KiB
JavaScript

/**
* An element which displays a link to a branch or tag in source control.
*/
angular.module('quay').directive('sourceRefLink', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/source-ref-link.html',
replace: false,
transclude: false,
restrict: 'C',
scope: {
'ref': '=ref',
'branchTemplate': '=branchTemplate',
'tagTemplate': '=tagTemplate'
},
controller: function($scope, $element) {
$scope.getKind = function(ref) {
var parts = (ref || '').split('/');
if (parts.length < 3) {
return '';
}
return parts[1];
};
$scope.getTitle = function(ref) {
var parts = (ref || '').split('/');
if (parts.length < 3) {
return '';
}
return parts[2];
};
$scope.getUrl = function(ref, template, kind) {
return template.replace('{' + kind + '}', $scope.getTitle(ref));
};
}
};
return directiveDefinitionObject;
});