Browse Source

Moved welcome form to own directive and removed obsolete controller.

pull/156/head
Simon Eisenmann 11 years ago
parent
commit
824a6e28e9
  1. 4
      static/js/controllers/controllers.js
  2. 27
      static/js/controllers/roomchangecontroller.js
  3. 6
      static/js/directives/directives.js
  4. 29
      static/js/directives/page.js
  5. 1
      static/js/directives/roombar.js
  6. 75
      static/js/directives/welcome.js
  7. 10
      static/js/services/rooms.js
  8. 2
      static/partials/page/welcome.html

4
static/js/controllers/controllers.js

@ -26,16 +26,14 @@ define([
'controllers/mediastreamcontroller', 'controllers/mediastreamcontroller',
'controllers/statusmessagecontroller', 'controllers/statusmessagecontroller',
'controllers/chatroomcontroller', 'controllers/chatroomcontroller',
'controllers/roomchangecontroller',
'controllers/usersettingscontroller', 'controllers/usersettingscontroller',
'controllers/contactsmanagercontroller', 'controllers/contactsmanagercontroller',
'controllers/contactsmanagereditcontroller'], function(_, MediastreamController, StatusmessageController, ChatroomController, RoomchangeController, UsersettingsController, ContactsmanagerController, ContactsmanagereditController) { 'controllers/contactsmanagereditcontroller'], function(_, MediastreamController, StatusmessageController, ChatroomController, UsersettingsController, ContactsmanagerController, ContactsmanagereditController) {
var controllers = { var controllers = {
MediastreamController: MediastreamController, MediastreamController: MediastreamController,
StatusmessageController: StatusmessageController, StatusmessageController: StatusmessageController,
ChatroomController: ChatroomController, ChatroomController: ChatroomController,
RoomchangeController: RoomchangeController,
UsersettingsController: UsersettingsController, UsersettingsController: UsersettingsController,
ContactsmanagerController: ContactsmanagerController, ContactsmanagerController: ContactsmanagerController,
ContactsmanagereditController: ContactsmanagereditController ContactsmanagereditController: ContactsmanagereditController

27
static/js/controllers/roomchangecontroller.js

@ -1,27 +0,0 @@
/*
* Spreed WebRTC.
* Copyright (C) 2013-2014 struktur AG
*
* This file is part of Spreed WebRTC.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
"use strict";
define([], function() {
return ["$scope", "rooms", function($scope, rooms) {
$scope.joinRoomByName = rooms.joinByName;
}];
});

6
static/js/directives/directives.js

@ -46,7 +46,8 @@ define([
'directives/presentation', 'directives/presentation',
'directives/youtubevideo', 'directives/youtubevideo',
'directives/bfi', 'directives/bfi',
'directives/title'], function(_, onEnter, onEscape, statusMessage, buddyList, buddyPictureCapture, buddyPictureUpload, settings, chat, audioVideo, usability, audioLevel, fileInfo, screenshare, roomBar, socialShare, page, contactRequest, defaultDialog, pdfcanvas, odfcanvas, presentation, youtubevideo, bfi, title) { 'directives/title',
'directives/welcome'], function(_, onEnter, onEscape, statusMessage, buddyList, buddyPictureCapture, buddyPictureUpload, settings, chat, audioVideo, usability, audioLevel, fileInfo, screenshare, roomBar, socialShare, page, contactRequest, defaultDialog, pdfcanvas, odfcanvas, presentation, youtubevideo, bfi, title, welcome) {
var directives = { var directives = {
onEnter: onEnter, onEnter: onEnter,
@ -72,7 +73,8 @@ define([
presentation: presentation, presentation: presentation,
youtubevideo: youtubevideo, youtubevideo: youtubevideo,
bfi: bfi, bfi: bfi,
title: title title: title,
welcome: welcome
}; };
var initialize = function(angModule) { var initialize = function(angModule) {

29
static/js/directives/page.js

@ -23,47 +23,24 @@
define(['text!partials/page.html', 'text!partials/page/welcome.html'], function(template, welcome) { define(['text!partials/page.html', 'text!partials/page/welcome.html'], function(template, welcome) {
return ["$templateCache", "$timeout", "rooms", function($templateCache, $timeout, rooms) { return ["$templateCache", "$timeout", "rooms", function($templateCache, $timeout, rooms) {
$templateCache.put('page/welcome.html', welcome); $templateCache.put('page/welcome.html', welcome);
var link = function($scope, $element, attrs) { var link = function($scope, $element, attrs) {
$scope.randomRoom = rooms.randomRoom;
$scope.$on("room.joined", function(event) { $scope.$on("room.joined", function(event) {
// Show no page when joined a room.
$scope.page = null; $scope.page = null;
}); });
$scope.$on("room.random", function(ev, roomdata) { $scope.$on("room.random", function(ev, roomdata) {
// Show welcome page on room random events.
$scope.page = "page/welcome.html"; $scope.page = "page/welcome.html";
$scope.roomdata = roomdata;
$timeout(function() {
$element.find(".roomdata-link-input:visible:enabled:first").focus();
});
});
$scope.roomdataInput = {
name: ""
};
$scope.roomdata = {};
$scope.$watch("roomdata.name", function(name) {
$scope.roomdata.link = rooms.link({Name: name});
}, true);
$scope.$watch("roomdataInput.name", function(name) {
if (name === "") {
$scope.randomRoom();
} else {
$scope.roomdata.name = name;
}
}); });
}; };
return { return {
restrict: 'E', restrict: 'E',
replace: true, replace: true,
template: template, template: template,
controller: "RoomchangeController",
link: link link: link
}; };
}]; }];

1
static/js/directives/roombar.js

@ -81,7 +81,6 @@ define(['underscore', 'angular', 'text!partials/roombar.html'], function(_, angu
replace: true, replace: true,
scope: true, scope: true,
template: template, template: template,
controller: "RoomchangeController",
link: link link: link
} }

75
static/js/directives/welcome.js

@ -0,0 +1,75 @@
/*
* Spreed WebRTC.
* Copyright (C) 2013-2014 struktur AG
*
* This file is part of Spreed WebRTC.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
"use strict";
define([], function() {
// welcome
return ["rooms", "$timeout", function(rooms, $timeout) {
function link($scope, $element) {
//console.log("xxx welcome", $scope.$id, $element);
$scope.randomRoom = rooms.randomRoom;
$scope.joinRoomByName = rooms.joinByName;
var roomdata = rooms.getRandomRoom();
if (roomdata) {
$scope.roomdata = {name: roomdata.name}
} else {
$scope.roomdata = {};
}
$scope.roomdataInput = {
name: ""
};
$scope.$watch("roomdata.name", function(name) {
$scope.roomdata.link = rooms.link({Name: name});
}, true);
$scope.$watch("roomdataInput.name", function(name) {
if (name === "") {
$scope.randomRoom();
} else {
$scope.roomdata.name = name;
}
});
$scope.$on("room.random", function(event, roomdata) {
$scope.roomdata = {name: roomdata.name};
$scope.roomdataInput.name = "";
});
$timeout(function() {
$element.find(".roomdata-link-input:visible:enabled:first").focus();
});
}
return {
restrict: 'EA',
link: link
}
}];
});

10
static/js/services/rooms.js

@ -31,6 +31,7 @@ define([
var requestedRoomName = ""; var requestedRoomName = "";
var helloedRoomName = null; var helloedRoomName = null;
var currentRoom = null; var currentRoom = null;
var randomRoom = null;
var joinFailed = function(error) { var joinFailed = function(error) {
setCurrentRoom(null); setCurrentRoom(null);
@ -179,13 +180,18 @@ define([
if (!data.name) { if (!data.name) {
data.name = ""; data.name = "";
} }
$rootScope.$broadcast('room.random', {name: data.name}); randomRoom = {name: data.name};
$rootScope.$broadcast('room.random', randomRoom);
}). }).
error(function() { error(function() {
console.error("Failed to retrieve random room data."); console.error("Failed to retrieve random room data.");
$rootScope.$broadcast('room.random', {}); randomRoom = {};
$rootScope.$broadcast('room.random', randomRoom);
}); });
}, },
getRandomRoom: function() {
return randomRoom;
},
joinByName: function(name, replace) { joinByName: function(name, replace) {
name = $window.encodeURIComponent(name); name = $window.encodeURIComponent(name);
name = name.replace(/^%40/, "@"); name = name.replace(/^%40/, "@");

2
static/partials/page/welcome.html

@ -1,4 +1,4 @@
<div class="welcome container-fluid"> <div welcome class="welcome container-fluid">
<div class="welcome-logo"></div> <div class="welcome-logo"></div>
<div class="welcome-container"> <div class="welcome-container">
<h1>{{_("Enter a room name")}}</h1> <h1>{{_("Enter a room name")}}</h1>

Loading…
Cancel
Save