1window.angular && (function(angular) { 2 'use strict'; 3 4 angular.module('app.common.directives').directive('logSearchControl', [ 5 'APIUtils', 6 function(APIUtils) { 7 return { 8 'restrict': 'E', 9 'template': require('./log-search-control.html'), 10 'controller': [ 11 '$rootScope', '$scope', 'dataService', '$location', 12 function($rootScope, $scope, dataService, $location) { 13 $scope.dataService = dataService; 14 $scope.doSearchOnEnter = function(event) { 15 var search = 16 $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, ''); 17 if (event.keyCode === 13 && search.length >= 2) { 18 $scope.clearSearchItem(); 19 $scope.addSearchItem(search); 20 } else { 21 if (search.length == 0) { 22 $scope.clearSearchItem(); 23 } 24 } 25 }; 26 27 $scope.clear = function() { 28 $scope.customSearch = ''; 29 $scope.clearSearchItem(); 30 }; 31 32 $scope.doSearchOnClick = function() { 33 var search = 34 $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, ''); 35 if (search.length >= 2) { 36 $scope.clearSearchItem(); 37 $scope.addSearchItem(search); 38 } else { 39 if (search.length == 0) { 40 $scope.clearSearchItem(); 41 } 42 } 43 }; 44 } 45 ] 46 }; 47 } 48 ]); 49})(window.angular); 50