Merge pull request #185 from cormier/fix-input-bar

Fix input bar
This commit is contained in:
David Cormier 2014-02-25 10:01:29 -05:00
commit 67d1e40013
3 changed files with 15 additions and 11 deletions

View file

@ -1,6 +1,6 @@
<form class="form form-horizontal" ng-submit="sendMessage()"> <form class="form form-horizontal" ng-submit="sendMessage()">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control monospace" autocomplete="off" > <input id="{{inputId}}" type="text" class="form-control monospace" autocomplete="off" >
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default btn-primary">Send</button> <button class="btn btn-default btn-primary">Send</button>
</span> </span>

View file

@ -349,7 +349,7 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel
</div> </div>
<div id="footer" ng-show="connected"> <div id="footer" ng-show="connected">
<div class="navbar navbar-inverse navbar-fixed-bottom" ng-class="{'withnicklist': showNicklist, 'withsidebar': showSidebar}"> <div class="navbar navbar-inverse navbar-fixed-bottom" ng-class="{'withnicklist': showNicklist, 'withsidebar': showSidebar}">
<div input-bar></div> <div input-bar input-id="sendMessage"></div>
</div> </div>
</body> </body>
</html> </html>

View file

@ -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,20 +1014,17 @@ weechat.directive('inputBar', function() {
return { return {
templateUrl: 'directives/input.html', templateUrl: 'directives/input.html',
scope: {
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
*/ */
@ -1067,7 +1071,7 @@ weechat.directive('inputBar', function() {
}; };
// Handle key presses in the input bar // Handle key presses in the input bar
$scope.handleKeyPress = function($event) { $rootScope.handleKeyPress = function($event) {
// don't do anything if not connected // don't do anything if not connected
if (!$rootScope.connected) { if (!$rootScope.connected) {
return true; return true;