Browse Source

Make chat use new style layout object.

pull/16/head
Simon Eisenmann 11 years ago
parent
commit
d50a377a33
  1. 12
      src/styles/components/_chat.scss
  2. 11
      static/js/directives/chat.js
  3. 2
      static/partials/chat.html
  4. 2
      static/partials/chatroom.html

12
src/styles/components/_chat.scss

@ -28,7 +28,10 @@ pointer-events: none;
z-index:45; z-index:45;
overflow:hidden; overflow:hidden;
} }
#chat.maximized { .withChat #chat .chatpane {
left:0px;
}
.withChat.withChatMaximized #chat {
left:0px; left:0px;
width:auto; width:auto;
.chatpane { .chatpane {
@ -39,7 +42,7 @@ width:auto;
height:100%; height:100%;
position:absolute; position:absolute;
top:0px; top:0px;
left:0px; left:260px;
bottom:0px; bottom:0px;
right:0px; right:0px;
width:260px; width:260px;
@ -49,9 +52,6 @@ width:260px;
-o-transition: left 200ms ease-in-out; -o-transition: left 200ms ease-in-out;
transition: left 200ms ease-in-out; transition: left 200ms ease-in-out;
} }
.chatpane.slideright {
left:260px;
}
.chat { .chat {
position:absolute; position:absolute;
pointer-events: auto; pointer-events: auto;
@ -69,7 +69,7 @@ display:block;
} }
.chat .chatheader { .chat .chatheader {
background: $componentbg; background: $componentbg;
padding:6px 4px 4px 8px; padding:8px 4px 0px 8px;
border-top: 1px solid $bordercolor; border-top: 1px solid $bordercolor;
border-bottom: 1px solid $bordercolor; border-bottom: 1px solid $bordercolor;
font-size:0.8em; font-size:0.8em;

11
static/js/directives/chat.js

@ -28,6 +28,7 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
var controller = ['$scope', '$element', '$attrs', function($scope, $element, $attrs) { var controller = ['$scope', '$element', '$attrs', function($scope, $element, $attrs) {
$scope.layout.chat = false; $scope.layout.chat = false;
$scope.layout.chatMaximized = false;
var rooms = {}; var rooms = {};
@ -115,7 +116,7 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
if (!subscope) { if (!subscope) {
console.log("Create new chatroom", id); console.log("Create new chatroom", id);
controller.visibleRooms.push(id); controller.visibleRooms.push(id);
subscope = controller.rooms[id] = scope.$new(true); subscope = controller.rooms[id] = scope.$new();
translation.inject(subscope); translation.inject(subscope);
subscope.id = id; subscope.id = id;
subscope.isgroupchat = id === group_chat_id ? true : false; subscope.isgroupchat = id === group_chat_id ? true : false;
@ -147,7 +148,7 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
subscope.$broadcast("seen"); subscope.$broadcast("seen");
} }
}; };
subscope.toggleMax = function() { subscope.toggle = function() {
scope.toggleMax(); scope.toggleMax();
}; };
subscope.sendChat = function(to, message, status, mid, noloop) { subscope.sendChat = function(to, message, status, mid, noloop) {
@ -306,6 +307,9 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
} }
if (!controller.visibleRooms.length) { if (!controller.visibleRooms.length) {
scope.showRoom(group_chat_id, {title: translation._("Group chat")}, {restore: true, noenable: true}); scope.showRoom(group_chat_id, {title: translation._("Group chat")}, {restore: true, noenable: true});
if (id === group_chat_id) {
scope.layout.chat = false;
}
} }
}; };
scope.killRoom = function(id) { scope.killRoom = function(id) {
@ -320,8 +324,7 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
}, 0); }, 0);
}; };
scope.toggleMax = function() { scope.toggleMax = function() {
//TODO(longsleep): Angularize this. scope.layout.chatMaximized = !scope.layout.chatMaximized;
iElement.parent().toggleClass("maximized");
}; };
scope.$on("room", function(event, room) { scope.$on("room", function(event, room) {

2
static/partials/chat.html

@ -1 +1 @@
<div class="chatpane" ng-class="{slideright: !layout.chat}"></div> <div class="chatpane"></div>

2
static/partials/chatroom.html

@ -1,5 +1,5 @@
<div ng-controller="ChatroomController" class="chat room-{{index}}" ng-class="{'newmessage': newmessage, 'visible': visible, 'chat-p2p': 'p2pstate', 'with_pictures': isgroupchat}"> <div ng-controller="ChatroomController" class="chat room-{{index}}" ng-class="{'newmessage': newmessage, 'visible': visible, 'chat-p2p': 'p2pstate', 'with_pictures': isgroupchat}">
<div class="chatheader"><span ng-show="p2pstate" class="fa fa-exchange" title="{{_('Peer to peer')}}"/><span>{{settings.title}} {{id|displayName}}</span> <div class="ctrl"><i ng-click="toggleMax()" class="fa fa-expand"></i><i title="{{_('Close chat')}}" ng-show="id" ng-click="hide()" class="fa fa-times"></i></div></div> <div class="chatheader"><span ng-show="p2pstate" class="fa fa-exchange" title="{{_('Peer to peer')}}"/><span>{{settings.title}} {{id|displayName}}</span> <div class="ctrl"><i ng-hide="layout.chatMaximized" ng-click="toggle()" class="fa fa-expand"></i><i ng-show="layout.chatMaximized" ng-click="toggle()" class="fa fa-compress"></i><i title="{{_('Close chat')}}" ng-click="hide()" class="fa fa-times"></i></div></div>
<div class="outputbox"> <div class="outputbox">
<div class="output nicescroll"></div> <div class="output nicescroll"></div>
</div> </div>

Loading…
Cancel
Save