initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
42
static/js/directives/ui/source-ref-link.js
Normal file
42
static/js/directives/ui/source-ref-link.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* 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.slice(2).join('/');
|
||||
};
|
||||
|
||||
$scope.getUrl = function(ref, template, kind) {
|
||||
if (!template) { return ''; }
|
||||
return template.replace('{' + kind + '}', $scope.getTitle(ref));
|
||||
};
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
});
|
Reference in a new issue