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
l-merge-prefix
David Cormier 12 years ago
parent c04b6e64f6
commit 4451bff60d
  1. 17
      js/glowingbear.js

@ -497,6 +497,13 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$scope.mobile_cutoff = 968; $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 () { $rootScope.countWatchers = function () {
var root = $(document.getElementsByTagName('body')); var root = $(document.getElementsByTagName('body'));
var watchers = []; var watchers = [];
@ -1007,23 +1014,17 @@ weechat.directive('inputBar', function() {
return { return {
templateUrl: 'directives/input.html', templateUrl: 'directives/input.html',
scope: { scope: {
inputId: '@inputId', inputId: '@inputId',
}, },
controller: function($rootScope, controller: function($rootScope,
$scope, $scope,
$element, $element,
connection, connection,
models) { 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 * Returns the input element
*/ */

Loading…
Cancel
Save