mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-13 12:26:57 +01:00
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
(function() {
|
|
|
|
'use strict';
|
|
|
|
angular
|
|
.module('harbor.search')
|
|
.directive('searchInput', searchInput);
|
|
|
|
SearchInputController.$inject = ['$scope', '$location', '$window'];
|
|
|
|
function SearchInputController($scope, $location, $window) {
|
|
var vm = this;
|
|
|
|
vm.searchFor = searchFor;
|
|
|
|
function searchFor(searchContent) {
|
|
$location
|
|
.path('/ng/search')
|
|
.search({'q': searchContent});
|
|
$window.location.href = $location.url();
|
|
}
|
|
|
|
}
|
|
|
|
function searchInput() {
|
|
|
|
var directive = {
|
|
'restrict': 'E',
|
|
'templateUrl': '/static/ng/resources/js/components/search/search-input.directive.html',
|
|
'scope': {
|
|
'searchInput': '=',
|
|
},
|
|
'link': link,
|
|
'controller': SearchInputController,
|
|
'controllerAs': 'vm',
|
|
'bindToController': true
|
|
};
|
|
return directive;
|
|
|
|
function link(scope, element, attrs, ctrl) {
|
|
element
|
|
.find('input[type="text"]')
|
|
.on('keydown', keydownHandler);
|
|
|
|
function keydownHandler(e) {
|
|
if(e.keyCode === 13) {
|
|
ctrl.searchFor($(this).val());
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
})(); |