Browse Source

Refactored automatic settings opener to open only once after user settings were loaded by adding the userSettingsLoaded event to appData service.

pull/154/head
Simon Eisenmann 11 years ago
parent
commit
f8b20ecb10
  1. 1
      static/js/controllers/mediastreamcontroller.js
  2. 16
      static/js/directives/settings.js
  3. 2
      static/js/directives/usability.js
  4. 14
      static/js/services/appdata.js

1
static/js/controllers/mediastreamcontroller.js

@ -273,6 +273,7 @@ define(['jquery', 'underscore', 'angular', 'bigscreen', 'moment', 'sjcl', 'moder @@ -273,6 +273,7 @@ define(['jquery', 'underscore', 'angular', 'bigscreen', 'moment', 'sjcl', 'moder
} else {
$scope.loadedUser = false;
}
appData.e.triggerHandler("userSettingsLoaded", [$scope.loadedUser, $scope.user]);
$scope.reset();
};

16
static/js/directives/settings.js

@ -45,10 +45,11 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t @@ -45,10 +45,11 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t
return ["$compile", "mediaStream", function($compile, mediaStream) {
var controller = ['$scope', 'desktopNotify', 'mediaSources', 'safeApply', 'availableLanguages', 'translation', 'localStorage', 'userSettingsData', 'constraints', function($scope, desktopNotify, mediaSources, safeApply, availableLanguages, translation, localStorage, userSettingsData, constraints) {
var controller = ['$scope', 'desktopNotify', 'mediaSources', 'safeApply', 'availableLanguages', 'translation', 'localStorage', 'userSettingsData', 'constraints', 'appData', function($scope, desktopNotify, mediaSources, safeApply, availableLanguages, translation, localStorage, userSettingsData, constraints, appData) {
$scope.layout.settings = false;
$scope.showAdvancedSettings = true;
$scope.autoshowSettings = true;
$scope.rememberSettings = true;
$scope.desktopNotify = desktopNotify;
$scope.mediaSources = mediaSources;
@ -154,6 +155,19 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t @@ -154,6 +155,19 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t
}
});
appData.e.on("userSettingsLoaded", function(event, loaded) {
if ($scope.autoshowSettings) {
$scope.autoshowSettings = false;
if (!loaded) {
$scope.layout.settings = true;
}
}
});
appData.e.on("authenticationChanged", function() {
$scope.autoshowSettings = true;
});
constraints.e.on("refresh", function(event, constraints) {
var settings = $scope.master.settings;

2
static/js/directives/usability.js

@ -88,14 +88,12 @@ define(['jquery', 'underscore', 'text!partials/usability.html'], function($, _, @@ -88,14 +88,12 @@ define(['jquery', 'underscore', 'text!partials/usability.html'], function($, _,
$scope.$on("room.joined", function(event) {
if (complete) {
$scope.layout.settings = !$scope.loadedUser;
ctrl.setInfo("ok");
}
});
$scope.$on("room.left", function(event) {
if (complete) {
$scope.layout.settings = false;
ctrl.setInfo("ok");
}
});

14
static/js/services/appdata.js

@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
define(["jquery"], function($) {
// appData.e events:
// subscribe these events with appData.e.on(eventname, function() {}).
// Subscribe these events with appData.e.on(eventname, function() {}).
//
// - authenticationChanged(event, userid, suserid)
// userid (string) : Public user id of the authenticated user.
@ -39,11 +39,17 @@ define(["jquery"], function($) { @@ -39,11 +39,17 @@ define(["jquery"], function($) {
// status (string) : Status id (connected, waiting, ...)
//
// - authorizing(event, flag)
// flag (bool) : True if authorizing, else false.
// flag (bool) : True if authorizing phase, else false.
//
// appData properties:
// - userSettingsLoaded(event, loaded, user_settings)
// loaded (bool) : True if something was loaded, else false.
// user_settings (map) : User map which was loaded.
//
// - language (string): ISO language code of active language
// Other appData properties:
//
// - language (string) : ISO language code of active language.
// - id (string) : Random string generated on app startup.
// - flags (map) : Flag table.
// appData
return ["randomGen", "$window", function(randomGen, $window) {

Loading…
Cancel
Save