blob: abdc9ffd5335e8fe12c7a7b4b292c0c383cd209d [file] [log] [blame]
window.angular && (function(angular) {
'use strict';
angular.module('app.common.directives').directive('logSearchControl', [
'APIUtils',
function(APIUtils) {
return {
'restrict': 'E',
'template': require('./log-search-control.html'),
'controller': [
'$rootScope', '$scope', 'dataService', '$location',
function($rootScope, $scope, dataService, $location) {
$scope.dataService = dataService;
$scope.doSearchOnEnter = function(event) {
var search =
$scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
if (event.keyCode === 13 && search.length >= 2) {
$scope.clearSearchItem();
$scope.addSearchItem(search);
} else {
if (search.length == 0) {
$scope.clearSearchItem();
}
}
};
$scope.clear = function() {
$scope.customSearch = '';
$scope.clearSearchItem();
};
$scope.doSearchOnClick = function() {
var search =
$scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
if (search.length >= 2) {
$scope.clearSearchItem();
$scope.addSearchItem(search);
} else {
if (search.length == 0) {
$scope.clearSearchItem();
}
}
};
}
]
};
}
]);
})(window.angular);