Browse Source

Automatically focus chat input when activating a room, implementing a part of #246

pull/248/head
Simon Eisenmann 10 years ago
parent
commit
d007b69c68
  1. 19
      static/js/directives/chat.js
  2. 2
      static/partials/chat.html

19
static/js/directives/chat.js

@ -415,11 +415,6 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro @@ -415,11 +415,6 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
pane.append(clonedElement);
$scope.element = clonedElement;
$scope.visible = true;
if (options.autofocus) {
_.defer(function() {
$scope.$broadcast("focus");
});
}
var sendFiles = function(files) {
_.each(files, function(f) {
@ -461,14 +456,11 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro @@ -461,14 +456,11 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
subscope.enabled = true;
}
}
if (options.autofocus && subscope.visible) {
subscope.$broadcast("focus");
}
}
if (!options.noactivate) {
scope.activateRoom(subscope.id, true);
scope.activateRoom(subscope.id, true, !!options.autofocus);
}
if (options.restore && !options.noenable) {
@ -524,7 +516,7 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro @@ -524,7 +516,7 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
scope.layout.chatMaximized = !scope.layout.chatMaximized;
};
scope.activateRoom = function(id, active) {
scope.activateRoom = function(id, active, autofocus) {
var subscope = controller.rooms[id];
if (!subscope) {
return;
@ -555,6 +547,13 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro @@ -555,6 +547,13 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
if (flip) {
pane.toggleClass("flip");
}
if (active && autofocus) {
_.defer(function() {
if (scope.layout.chat) {
subscope.$broadcast("focus");
}
});
}
};
scope.deactivateRoom = function() {

2
static/partials/chat.html

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
<div class="chatheader"><div class="chatstatusicon" ng-click="activateRoom(currentRoom.id, true)"><i class="fa fa-angle-right"></i> <i class="fa fa fa-comments-o"></i></div><div class="chatheadertitle"><span>{{_("Chat sessions")}}</span></div> <div class="ctrl"><i ng-show="layout.chatMaximized" ng-click="toggleMax()" class="fa fa-compress"></i></div></div>
<div class="chatbody">
<div class="list-group nicescroll">
<a ng-repeat="room in getVisibleRooms()" ng-click="activateRoom(room.id, true)" class="list-group-item" ng-class="{newmessage: room.pending, disabled: !room.enabled}">
<a ng-repeat="room in getVisibleRooms()" ng-click="activateRoom(room.id, true, true)" class="list-group-item" ng-class="{newmessage: room.pending, disabled: !room.enabled}">
<span class="badge" ng-show="room.pending">{{room.pending}}</span>
<span ng-if="room.id !== ''">{{room.id|displayName}}</span>
<span ng-if="room.id === ''">{{_("Room chat")}} {{currentRoomName}}</span>

Loading…
Cancel
Save