blob: f262f5fd0f01d017064802771b6179e4cbd0ce1f [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);