From 14a40c1039a83faabcd2a0d6991b025674373926 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Sat, 12 Oct 2013 16:09:02 -0400 Subject: [PATCH] ui: scroll to bottom when receiving activeBufferChanged signal Triggers the ui manipulation code when the rootScope receives the signal. Supports multiple ways of changing the buffer (clicking, shortcuts, etc.) without having to duplicate this code. --- js/websockets.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/js/websockets.js b/js/websockets.js index 8ed3648..a55da9a 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -430,6 +430,13 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } + $rootScope.$on('activeBufferChanged', function() { + $rootScope.scrollToBottom(); + document.getElementById('sendMessage').focus(); + var ab = models.getActiveBuffer(); + $rootScope.pageTitle = ab.shortName + ' | ' + ab.title; + }); + $scope.buffers = models.model.buffers; $scope.activeBuffer = models.getActiveBuffer @@ -451,11 +458,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.setActiveBuffer = function(key) { models.setActiveBuffer(key); - $rootScope.scrollToBottom(); - document.getElementById('sendMessage').focus(); - var ab = models.getActiveBuffer(); - $rootScope.pageTitle = ab.shortName + ' | ' + ab.title; - }; $rootScope.scrollToBottom = function() {