Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
Make search icon perform the search
Browse files Browse the repository at this point in the history
  • Loading branch information
lsilvs committed Aug 28, 2018
1 parent 2c01707 commit ebe4bdc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions src/components/search/search.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ AppSearch.directive('search', ($stateParams, $location, $timeout, Global, $http)
}, 200);
};

this.expandInput = () => {
this.activeForm = !this.activeForm;
$timeout(() => {
document.getElementById('search').focus();
}, 500);
this.onSearchIconClick = () => {
if (!this.mobileView) {
this.search();
} else {
this.activeForm = !this.activeForm;
$timeout(() => {
document.getElementById('search').focus();
}, 500);
}
};

this.hideSuggestion = () => {
_resetSearch();
if (!this.loading) {
_resetSearch();
}
};

this.search = () => {
Expand Down Expand Up @@ -75,7 +81,8 @@ AppSearch.directive('search', ($stateParams, $location, $timeout, Global, $http)
};
};

const SearchLink = function () {
const SearchLink = function (scope) {
scope.activeForm = !scope.mobileView;
};

return {
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="wrapper" data-ng-class="{'has-error': sch.badQuery}">
<input id="search" type="text" class="input search" data-ng-model="sch.q" placeholder="Find a transaction, address, delegate or block"
data-ng-submit="sch.search()" data-ng-blur="sch.hideSuggestion()" autocomplete="off" />
<span class="glyphicon" aria-hidden="true" data-ng-click="sch.expandInput()" data-ng-class="{'glyphicon-remove': sch.mobileView && sch.activeForm, 'glyphicon-search': !sch.mobileView || !sch.activeForm}"></span>
<span class="glyphicon" aria-hidden="true" data-ng-mousedown="sch.onSearchIconClick()" data-ng-class="{'glyphicon-remove': sch.mobileView && sch.activeForm, 'glyphicon-search': !sch.mobileView || !sch.activeForm}"></span>
<div class="search-suggestion-list list-group"
ng-if="sch.showingResults && sch.results">
<a href="/address/{{result.address}}" class="search-suggestion-item list-group-item list-group-item-action flex-column align-items-start"
Expand Down

0 comments on commit ebe4bdc

Please sign in to comment.