blob: b198f2d0c8e7b08666da485d827401179c261569 [file] [log] [blame]
Iftekharul Islam8b4828a2017-04-19 14:37:55 -05001window.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
Iftekharul Islam171c6a12017-08-11 08:35:47 -050025 $scope.clear = function(){
26 $scope.customSearch = "";
27 $scope.clearSearchItem();
28 }
29
Iftekharul Islam8b4828a2017-04-19 14:37:55 -050030 $scope.doSearchOnClick = function() {
31 var search = $scope.customSearch.replace(/^\s+/g,'').replace(/\s+$/g,'');
32 if (search.length >= 2) {
33 $scope.clearSearchItem();
34 $scope.addSearchItem(search);
35 }else{
36 if(search.length == 0){
37 $scope.clearSearchItem();
38 }
39 }
40 }
41 }]
42 };
43 }]);
44})(window.angular);