Merge pull request #1010 from tinchou/master
Fixes #1000: message box not focused on a computer with touch enabled.
This commit is contained in:
commit
a2527db6a1
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
angular.module('myApp.directives', ['myApp.filters'])
|
angular.module('myApp.directives', ['myApp.filters'])
|
||||||
|
|
||||||
|
.constant('shouldFocusOnInteraction', !Config.Navigator.mobile)
|
||||||
|
|
||||||
.directive('myHead', function() {
|
.directive('myHead', function() {
|
||||||
return {
|
return {
|
||||||
restrict: 'AE',
|
restrict: 'AE',
|
||||||
@ -1427,8 +1429,7 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
.directive('mySendForm', function (_, $timeout, $compile, $modalStack, $http, $interpolate, Storage, AppStickersManager, AppDocsManager, ErrorService) {
|
.directive('mySendForm', function (_, $timeout, $compile, $modalStack, $http, $interpolate, Storage, AppStickersManager, AppDocsManager, ErrorService, shouldFocusOnInteraction) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
link: link,
|
link: link,
|
||||||
scope: {
|
scope: {
|
||||||
@ -1570,7 +1571,7 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
if (composerEmojiPanel) {
|
if (composerEmojiPanel) {
|
||||||
composerEmojiPanel.update();
|
composerEmojiPanel.update();
|
||||||
}
|
}
|
||||||
}, Config.Navigator.touch ? 100 : 0);
|
}, shouldFocusOnInteraction ? 0 : 100);
|
||||||
return cancelEvent(e);
|
return cancelEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1601,7 +1602,7 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
$('body').on('dragenter dragleave dragover drop', onDragDropEvent);
|
$('body').on('dragenter dragleave dragover drop', onDragDropEvent);
|
||||||
$(document).on('paste', onPasteEvent);
|
$(document).on('paste', onPasteEvent);
|
||||||
|
|
||||||
if (!Config.Navigator.touch) {
|
if (shouldFocusOnInteraction) {
|
||||||
$scope.$on('ui_peer_change', focusField);
|
$scope.$on('ui_peer_change', focusField);
|
||||||
$scope.$on('ui_history_focus', focusField);
|
$scope.$on('ui_history_focus', focusField);
|
||||||
$scope.$on('ui_history_change', focusField);
|
$scope.$on('ui_history_change', focusField);
|
||||||
@ -1621,7 +1622,7 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
composer.setValue($scope.draftMessage.text || '');
|
composer.setValue($scope.draftMessage.text || '');
|
||||||
updateHeight();
|
updateHeight();
|
||||||
}
|
}
|
||||||
if (!Config.Navigator.touch || options && options.focus) {
|
if (shouldFocusOnInteraction || options && options.focus) {
|
||||||
composer.focus();
|
composer.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1635,7 +1636,7 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
$scope.$on('ui_peer_reply', function () {
|
$scope.$on('ui_peer_reply', function () {
|
||||||
onContentLoaded(function () {
|
onContentLoaded(function () {
|
||||||
$scope.$emit('ui_editor_resize');
|
$scope.$emit('ui_editor_resize');
|
||||||
if (!Config.Navigator.touch) {
|
if (shouldFocusOnInteraction) {
|
||||||
composer.focus();
|
composer.focus();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -1649,7 +1650,7 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
updateValue();
|
updateValue();
|
||||||
});
|
});
|
||||||
$scope.$on('ui_message_send', function () {
|
$scope.$on('ui_message_send', function () {
|
||||||
if (!Config.Navigator.touch) {
|
if (shouldFocusOnInteraction) {
|
||||||
focusField();
|
focusField();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1740,7 +1741,7 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
fileSelects.off('change');
|
fileSelects.off('change');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!Config.Navigator.touch) {
|
if (shouldFocusOnInteraction) {
|
||||||
focusField();
|
focusField();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2275,10 +2276,10 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
.directive('myFocused', function(){
|
.directive('myFocused', function(shouldFocusOnInteraction) {
|
||||||
return {
|
return {
|
||||||
link: function($scope, element, attrs) {
|
link: function($scope, element, attrs) {
|
||||||
if (Config.Navigator.touch) {
|
if (!shouldFocusOnInteraction) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@ -2288,11 +2289,11 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
.directive('myFocusOn', function(){
|
.directive('myFocusOn', function(shouldFocusOnInteraction) {
|
||||||
return {
|
return {
|
||||||
link: function($scope, element, attrs) {
|
link: function($scope, element, attrs) {
|
||||||
$scope.$on(attrs.myFocusOn, function () {
|
$scope.$on(attrs.myFocusOn, function () {
|
||||||
if (Config.Navigator.touch) {
|
if (!shouldFocusOnInteraction) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
onContentLoaded(function () {
|
onContentLoaded(function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user