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.
This commit is contained in:
David Cormier 2013-10-12 16:09:02 -04:00
parent fb0ce21fc5
commit 14a40c1039

View file

@ -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() {