Browse Source

Refactored room events.

Signed-off-by: Simon Eisenmann <simon@struktur.de>
pull/3/head
Simon Eisenmann 12 years ago committed by Simon Eisenmann
parent
commit
67de408100
  1. 23
      static/js/directives/chat.js
  2. 8
      static/js/directives/usability.js
  3. 8
      static/js/services/mediastream.js

23
static/js/directives/chat.js

@ -20,7 +20,7 @@
*/ */
define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'], function(_, templateChat, templateChatroom) { define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'], function(_, templateChat, templateChatroom) {
return ["$compile", "safeDisplayName", "mediaStream", "safeApply", "desktopNotify", "translation", "playSound", "fileUpload", "randomGen", "buddyData", function($compile, safeDisplayName, mediaStream, safeApply, desktopNotify, translation, playSound, fileUpload, randomGen, buddyData) { return ["$compile", "safeDisplayName", "mediaStream", "safeApply", "desktopNotify", "translation", "playSound", "fileUpload", "randomGen", "buddyData", "$timeout", function($compile, safeDisplayName, mediaStream, safeApply, desktopNotify, translation, playSound, fileUpload, randomGen, buddyData, $timeout) {
var displayName = safeDisplayName; var displayName = safeDisplayName;
var group_chat_id = ""; var group_chat_id = "";
@ -272,7 +272,11 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
controller.visibleRooms.push(id); controller.visibleRooms.push(id);
subscope.index = index; subscope.index = index;
subscope.visible = true; subscope.visible = true;
subscope.minimized = false; if (options.minimized) {
subscope.minimized = true;
} else {
subscope.minimized = false;
}
} }
} }
if (options.autofocus && subscope.visible) { if (options.autofocus && subscope.visible) {
@ -309,10 +313,19 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
return; return;
} }
delete controller.rooms[id]; delete controller.rooms[id];
subscope.$destroy(); $timeout(function() {
subscope.$destroy();
}, 0);
}; };
// Show default room.
scope.showRoom(group_chat_id, {title: translation._("Group chat")}); scope.$on("room", function(event, room) {
if (room) {
scope.showRoom(group_chat_id, {title: translation._("Group chat")}, {restore: true, minimized: true});
} else {
scope.hideRoom(group_chat_id);
}
});
}; };
}; };

8
static/js/directives/usability.js

@ -24,7 +24,7 @@ define(['jquery', 'underscore', 'text!partials/usability.html'], function($, _,
return ["mediaStream", function(mediaStream) { return ["mediaStream", function(mediaStream) {
var controller = ['$scope', "mediaStream", "safeApply", "$rootScope", "$timeout", function($scope, mediaStream, safeApply, $rootScope, $timeout) { var controller = ['$scope', "mediaStream", "safeApply", "$timeout", function($scope, mediaStream, safeApply, $timeout) {
$scope.roomdata = {}; $scope.roomdata = {};
@ -81,7 +81,7 @@ define(['jquery', 'underscore', 'text!partials/usability.html'], function($, _,
if ($scope.connect) { if ($scope.connect) {
console.log("Connecting ..."); console.log("Connecting ...");
ctrl.setInfo("checking"); ctrl.setInfo("checking");
setTimeout(function() { $timeout(function() {
if (pending) { if (pending) {
safeApply($scope, function() { safeApply($scope, function() {
ctrl.setInfo("usermedia"); ctrl.setInfo("usermedia");
@ -92,14 +92,14 @@ define(['jquery', 'underscore', 'text!partials/usability.html'], function($, _,
} }
}); });
$rootScope.$on("roomStatus", function(event, status) { $scope.$on("room", function(event, room) {
//console.log("roomStatus", status); //console.log("roomStatus", status);
if (complete) { if (complete) {
if (initializer !== null) { if (initializer !== null) {
$timeout.cancel(initializer); $timeout.cancel(initializer);
initializer = null; initializer = null;
} }
ctrl.setInfo(status ? "room" : "noroom"); ctrl.setInfo(room ? "room" : "noroom");
} }
}); });

8
static/js/services/mediastream.js

@ -70,6 +70,8 @@ define([
var ready = false; var ready = false;
$rootScope.version = version; $rootScope.version = version;
$rootScope.roomid = null;
$rootScope.roomstatus = false;
connector.e.on("closed error", _.bind(function(event, options) { connector.e.on("closed error", _.bind(function(event, options) {
var opts = $.extend({}, options); var opts = $.extend({}, options);
@ -122,6 +124,12 @@ define([
$rootScope.roomid = room; $rootScope.roomid = room;
}); });
$rootScope.$on("roomStatus", function(event, status) {
$rootScope.roomstatus = status ? true : false;
var room = status ? $rootScope.roomid : null;
$rootScope.$broadcast("room", room);
});
visibility.afterPrerendering(function() { visibility.afterPrerendering(function() {
// Hide loader when we are visible. // Hide loader when we are visible.

Loading…
Cancel
Save