From 4451bff60d9d9971c5fa230de3743abb46d87ec1 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Tue, 25 Feb 2014 09:14:08 -0500 Subject: [PATCH] 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 --- js/glowingbear.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 7a3b2da..9ef90b0 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -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 */