Browse Source

Only safe user settings if form is dirty.

pull/108/head
Simon Eisenmann 12 years ago
parent
commit
665618c6a7
  1. 10
      static/js/directives/settings.js
  2. 2
      static/partials/settings.html

10
static/js/directives/settings.js

@ -52,9 +52,10 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t @@ -52,9 +52,10 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t
});
$scope.saveSettings = function() {
var form = $scope.settingsform;
if (form.$valid && form.$dirty) {
var user = $scope.user;
$scope.update(user);
$scope.layout.settings = false;
if ($scope.rememberSettings) {
userSettingsData.save(user);
localStorage.setItem("mediastream-language", user.settings.language || "");
@ -63,10 +64,17 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t @@ -63,10 +64,17 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t
localStorage.removeItem("mediastream-language");
localStorage.removeItem("mediastream-access-code");
}
form.$setPristine();
}
$scope.layout.settings = false;
};
$scope.cancelSettings = function() {
var form = $scope.settingsform;
$scope.reset();
if (form.$dirty) {
form.$setPristine();
}
$scope.layout.settings = false;
};

2
static/partials/settings.html

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
<div class="settings nicescroll">
<div class="version">{{version}}</div>
<div class="form-horizontal" on-enter="saveSettings(user)" on-escape="reset()"
<div ng-form="settingsform" class="form-horizontal" on-enter="saveSettings(user)" on-escape="cancelSettings()"
<fieldset>
<settings-profile>

Loading…
Cancel
Save