Skip to content

Commit

Permalink
Focus on search bar on button press 
Browse files Browse the repository at this point in the history
  • Loading branch information
melonmanchan committed Mar 24, 2016
1 parent 93eccb5 commit 4767014
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
16 changes: 9 additions & 7 deletions app/js/controllers/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
angular.module('contacts', [])
.controller('ContactsCtrl', function ($scope, $localStorage, $ionicModal, contactsFactory,
modalFactory, peerFactory, socketFactory, configFactory,
$state, $ionicActionSheet, $translate, $window) {
$state, $ionicActionSheet, $timeout, $translate, $window) {
var newContactModal = null;

var translations = $translate(['SAR_CALL', 'PROFILE', 'ACTIONS', 'CANCEL']).then(function (trans) {
Expand Down Expand Up @@ -99,13 +99,15 @@ angular.module('contacts', [])

$scope.toggleSearchBar = function () {
$scope.isSearchBarVisible = !$scope.isSearchBarVisible;
if ($sope.isSearchBarVisible === true) {
if (cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.show();
}

if ($scope.isSearchBarVisible === true) {
$timeout(function () {
document.getElementById('search-bar').focus();
}, 0);

} else {
if (cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hide();
if (cordova.plugins.Keyboard && cordova.plugins.Keyboard.isVisible === true) {
cordova.plugins.Keyboard.close();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/contacts.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<span on-tap="toggleSearchBar()">
<i class="icon ion-ios-arrow-back search-icon placeholder-icon"></i>
</span>
<input type="text" placeholder="{{'SEARCH' | translate}}" ng-model="contactSearch" ng-keyup="searchKeyPress($event.keyCode)">
<input type="text" id="search-bar" placeholder="{{'SEARCH' | translate}}" ng-model="contactSearch" ng-keyup="searchKeyPress($event.keyCode)">
</label>
</div>
<div class="list" >
Expand Down
1 change: 1 addition & 0 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
<preference name="xwalkCommandLine" value="--disable-pull-to-refresh-effect" />
<preference name="xwalkMode" value="embedded" />
<preference name="xwalkMultipleApk" value="true" />
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
</widget>

0 comments on commit 4767014

Please sign in to comment.