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

42 lines
1 KiB
JavaScript
Raw Normal View History

2015-02-26 22:45:28 +00:00
/**
* 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;
});