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

Make search icon perform the search - Closes #785 #802

Merged
merged 1 commit into from
Aug 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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