Skip to content

Commit bb77588

Browse files
author
Dani Palou
committed
MOBILE-1218 keyboard: Close keyboard when submitting some forms
1 parent 634ce71 commit bb77588

File tree

8 files changed

+39
-5
lines changed

8 files changed

+39
-5
lines changed

www/addons/messages/controllers/contacts.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ angular.module('mm.addons.messages')
2121
* @ngdoc controller
2222
* @name mmaMessagesContactsCtrl
2323
*/
24-
.controller('mmaMessagesContactsCtrl', function($scope, $mmaMessages, $mmSite, $mmUtil, mmUserProfileState) {
24+
.controller('mmaMessagesContactsCtrl', function($scope, $mmaMessages, $mmSite, $mmUtil, $mmApp, mmUserProfileState) {
2525

2626
var currentUserId = $mmSite.getUserId();
2727

@@ -52,6 +52,9 @@ angular.module('mm.addons.messages')
5252
// too many users!
5353
return;
5454
}
55+
56+
$mmApp.closeKeyboard();
57+
5558
$scope.loaded = false;
5659
return $mmaMessages.searchContacts(query).then(function(result) {
5760
$scope.hasContacts = result.length > 0;

www/addons/messages/controllers/discussion.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ angular.module('mm.addons.messages')
102102
message.sending = false;
103103
notifyNewMessage();
104104
}, function(error) {
105+
106+
// Only close the keyboard if an error happens, we want the user to be able to send multiple
107+
// messages withoutthe keyboard being closed.
108+
$mmApp.closeKeyboard();
109+
105110
if (typeof error === 'string') {
106111
$mmUtil.showErrorModal(error);
107112
} else {

www/addons/mod_chat/controllers/chat.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ angular.module('mm.addons.mod_chat')
137137
$scope.newMessage.text = '';
138138
}
139139
}, function(error) {
140+
// Only close the keyboard if an error happens, we want the user to be able to send multiple
141+
// messages withoutthe keyboard being closed.
142+
$mmApp.closeKeyboard();
143+
140144
showError(error);
141145
});
142146
};

www/addons/notes/services/handlers.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ angular.module('mm.addons.notes')
2323
* @ngdoc service
2424
* @name $mmaNotesHandlers
2525
*/
26-
.factory('$mmaNotesHandlers', function($mmaNotes, $mmSite, $translate, $ionicLoading, $ionicModal, $mmUtil) {
26+
.factory('$mmaNotesHandlers', function($mmaNotes, $mmSite, $mmApp, $ionicModal, $mmUtil) {
2727

2828
var self = {};
2929

@@ -92,6 +92,9 @@ angular.module('mm.addons.notes')
9292
};
9393

9494
$scope.addNote = function(){
95+
96+
$mmApp.closeKeyboard();
97+
9598
var loadingModal = $mmUtil.showModalLoading('mm.core.sending', true);
9699
// Freeze the add note button.
97100
$scope.processing = true;

www/core/components/login/controllers/credentials.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ angular.module('mm.core.login')
2121
* @ngdoc controller
2222
* @name mmLoginCredentialsCtrl
2323
*/
24-
.controller('mmLoginCredentialsCtrl', function($scope, $state, $stateParams, $mmSitesManager, $mmUtil, $ionicHistory) {
24+
.controller('mmLoginCredentialsCtrl', function($scope, $state, $stateParams, $mmSitesManager, $mmUtil, $ionicHistory, $mmApp) {
2525

2626
$scope.siteurl = $stateParams.siteurl;
2727
$scope.credentials = {};
2828

2929
$scope.login = function() {
3030

31+
$mmApp.closeKeyboard();
32+
3133
// Get input data.
3234
var siteurl = $scope.siteurl,
3335
username = $scope.credentials.username,

www/core/components/login/controllers/reconnect.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ angular.module('mm.core.login')
2121
* @ngdoc controller
2222
* @name mmLoginReconnectCtrl
2323
*/
24-
.controller('mmLoginReconnectCtrl', function($scope, $state, $stateParams, $mmSitesManager, $mmSite, $mmUtil, $ionicHistory) {
24+
.controller('mmLoginReconnectCtrl', function($scope, $state, $stateParams, $mmSitesManager, $mmApp, $mmUtil, $ionicHistory) {
2525

2626
var infositeurl = $stateParams.infositeurl; // Siteurl in site info. It might be different than siteurl (http/https).
2727
$scope.siteurl = $stateParams.siteurl;
@@ -42,6 +42,8 @@ angular.module('mm.core.login')
4242

4343
$scope.login = function() {
4444

45+
$mmApp.closeKeyboard();
46+
4547
// Get input data.
4648
var siteurl = $scope.siteurl,
4749
username = $scope.credentials.username,

www/core/components/login/controllers/site.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ angular.module('mm.core.login')
2121
* @ngdoc controller
2222
* @name mmLoginSiteCtrl
2323
*/
24-
.controller('mmLoginSiteCtrl', function($scope, $state, $mmSitesManager, $mmUtil, $translate, $ionicHistory,
24+
.controller('mmLoginSiteCtrl', function($scope, $state, $mmSitesManager, $mmUtil, $translate, $ionicHistory, $mmApp,
2525
$ionicModal, $mmLoginHelper) {
2626

2727
$scope.siteurl = '';
@@ -45,6 +45,8 @@ angular.module('mm.core.login')
4545

4646
$scope.connect = function(url) {
4747

48+
$mmApp.closeKeyboard();
49+
4850
if (!url) {
4951
$mmUtil.showErrorModal('mm.login.siteurlrequired', true);
5052
return;

www/core/lib/app.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@ angular.module('mm.core')
111111
$stateProvider.state(name, config);
112112
};
113113

114+
/**
115+
* Closes the keyboard if plugin is available.
116+
*
117+
* @return {Boolean} True if plugin is available, false otherwise.
118+
*/
119+
self.closeKeyboard = function() {
120+
if (cordova && cordova.plugins && cordova.plugins.Keyboard && cordova.plugins.Keyboard.close) {
121+
cordova.plugins.Keyboard.close();
122+
return true;
123+
}
124+
return false;
125+
};
126+
114127
/**
115128
* Get the application global database.
116129
* @return {Object} App's DB.

0 commit comments

Comments
 (0)