Move activeBufferChanged listener to WeechatCtrl

I don't believe that the inputBar directive should know about the
mobile cutoff we have set for GB. We should aim to make it as
reusable as possible
This commit is contained in:
David Cormier 2014-02-25 09:14:08 -05:00
parent c04b6e64f6
commit 4451bff60d
1 changed files with 9 additions and 8 deletions

View File

@ -497,6 +497,13 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$scope.mobile_cutoff = 968;
// Focuses itself when active buffer is changed
$rootScope.$on('activeBufferChanged', function() {
if (document.body.clientWidth >= $scope.mobile_cutoff) {
$('#sendMessage').focus();
}
});
$rootScope.countWatchers = function () {
var root = $(document.getElementsByTagName('body'));
var watchers = [];
@ -1007,23 +1014,17 @@ weechat.directive('inputBar', function() {
return {
templateUrl: 'directives/input.html',
scope: {
inputId: '@inputId',
},
controller: function($rootScope,
$scope,
$element,
connection,
models) {
// Focuses itself when active buffer is changed
$rootScope.$on('activeBufferChanged', function() {
if (document.body.clientWidth >= $scope.mobile_cutoff) {
angular.element('#sendMessage').focus();
}
});
/*
* Returns the input element
*/