Focus input bar when not on mobile

This improves the UX on desktop while avoiding the virtual keyboard
popping up on touch devices
This commit is contained in:
Felix Eckhofer 2014-02-24 10:47:17 +01:00
parent 41bdb90a5e
commit 7a003f8227
1 changed files with 9 additions and 9 deletions

View File

@ -486,7 +486,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}); });
} }
var mobile_cutoff = 968; $scope.mobile_cutoff = 968;
$rootScope.countWatchers = function () { $rootScope.countWatchers = function () {
var root = $(document.getElementsByTagName('body')); var root = $(document.getElementsByTagName('body'));
@ -663,7 +663,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// If we are on mobile chhange some defaults // If we are on mobile chhange some defaults
// We use 968 px as the cutoff, which should match the value in glowingbear.css // We use 968 px as the cutoff, which should match the value in glowingbear.css
if (document.body.clientWidth < mobile_cutoff) { if (document.body.clientWidth < $scope.mobile_cutoff) {
$scope.nonicklist = true; $scope.nonicklist = true;
$scope.noembed = true; $scope.noembed = true;
$scope.notimestamp = true; $scope.notimestamp = true;
@ -671,13 +671,13 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Open and close panels while on mobile devices through swiping // Open and close panels while on mobile devices through swiping
$scope.swipeSidebar = function() { $scope.swipeSidebar = function() {
if (document.body.clientWidth < mobile_cutoff) { if (document.body.clientWidth < $scope.mobile_cutoff) {
$scope.showSidebar = !$scope.showSidebar; $scope.showSidebar = !$scope.showSidebar;
} }
}; };
$scope.openNick = function() { $scope.openNick = function() {
if (document.body.clientWidth < mobile_cutoff) { if (document.body.clientWidth < $scope.mobile_cutoff) {
if($scope.nonicklist) { if($scope.nonicklist) {
$scope.nonicklist = false; $scope.nonicklist = false;
} }
@ -685,7 +685,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}; };
$scope.closeNick = function() { $scope.closeNick = function() {
if (document.body.clientWidth < mobile_cutoff) { if (document.body.clientWidth < $scope.mobile_cutoff) {
if(!$scope.nonicklist) { if(!$scope.nonicklist) {
$scope.nonicklist = true; $scope.nonicklist = true;
} }
@ -718,7 +718,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$scope.setActiveBuffer = function(bufferId, key) { $scope.setActiveBuffer = function(bufferId, key) {
// If we are on mobile we need to collapse the menu on sidebar clicks // If we are on mobile we need to collapse the menu on sidebar clicks
// We use 968 px as the cutoff, which should match the value in glowingbear.css // We use 968 px as the cutoff, which should match the value in glowingbear.css
if (document.body.clientWidth < mobile_cutoff) { if (document.body.clientWidth < $scope.mobile_cutoff) {
$scope.showSidebar = false; $scope.showSidebar = false;
} }
return models.setActiveBuffer(bufferId, key); return models.setActiveBuffer(bufferId, key);
@ -1001,11 +1001,11 @@ weechat.directive('inputBar', function() {
models) { models) {
// Focuses itself when active buffer is changed // Focuses itself when active buffer is changed
/*
$rootScope.$on('activeBufferChanged', function() { $rootScope.$on('activeBufferChanged', function() {
angular.element('#sendMessage').focus(); if (document.body.clientWidth >= $scope.mobile_cutoff) {
angular.element('#sendMessage').focus();
}
}); });
*/
$scope.completeNick = function() { $scope.completeNick = function() {
// input DOM node // input DOM node