Skip to content

Commit

Permalink
Revert "MOBILE-1891 ios: Fix send message bar hidden by keyboard"
Browse files Browse the repository at this point in the history
This reverts commit a7dc28c.
  • Loading branch information
jleyva committed Dec 12, 2016
1 parent 8584241 commit 3ddeddb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
2 changes: 1 addition & 1 deletion www/addons/messages/templates/discussion.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</mm-loading>
</ion-content>

<ion-footer-bar class="bar-light" keyboard-attach>
<ion-footer-bar class="bar-light">
<form class="mma-messages-send-message-bar" ng-submit="sendMessage(newMessage); newMessage = '';">
<div class="mma-messages-input-inset item-input-inset">
<ion-input class="item-input-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod/chat/templates/chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h2>{{ message.userfullname }}</h2>
</mm-loading>
</ion-content>

<ion-footer-bar keyboard-attach>
<ion-footer-bar>
<p class="mma-chat-footer-note" ng-if="isAppOffline()">{{ 'mma.mod_chat.mustbeonlinetosendmessages' | translate }}</p>
<form ng-if="!isAppOffline() && polling && loaded" class="mma-chat-send-form" ng-submit="sendMessage(newMessage.text);">
<div class="mma-chat-input-inset item-input-inset">
Expand Down
22 changes: 3 additions & 19 deletions www/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,32 +191,16 @@ angular.module('mm.core', ['pascalprecht.translate'])
$window.addEventListener('native.keyboardshow', function(e) {
$mmEvents.trigger(mmCoreEventKeyboardShow, e);

if (ionic.Platform.isIOS() && document.activeElement && document.activeElement.tagName != 'BODY') {
if ($mmUtil.closest(document.activeElement, 'ion-footer-bar[keyboard-attach]')) {
// Input element is in a footer with keyboard-attach directive, nothing to be done.
return;
}

if (ionic.Platform.isIOS()) {
// In iOS the user can select elements outside of the view using previous/next. Check if it's the case.
if ($mmUtil.isElementOutsideOfScreen(document.activeElement)) {
// Focused element is outside of the screen. Scroll so the element is seen.
var position = $mmUtil.getElementXY(document.activeElement),
delegateHandle = $mmUtil.closest(document.activeElement, '*[delegate-handle]'),
scrollView;

var position = $mmUtil.getElementXY(document.activeElement);
if (position) {
if ($window && $window.innerHeight) {
// Put the input in the middle of screen aprox, not in top.
position[1] = position[1] - $window.innerHeight * 0.5;
}

// Get the right scroll delegate to use.
delegateHandle = delegateHandle && delegateHandle.getAttribute('delegate-handle');
scrollView = typeof delegateHandle == 'string' ?
$ionicScrollDelegate.$getByHandle(delegateHandle) : $ionicScrollDelegate;

// Scroll to the position.
scrollView.scrollTo(position[0], position[1]);
$ionicScrollDelegate.scrollTo(position[0], position[1]);
}
}
}
Expand Down

0 comments on commit 3ddeddb

Please sign in to comment.