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