summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/DataModel/UserPreferences.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/UserPreferences.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/UserPreferences.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/UserPreferences.js b/frontend/beta/js/Clipperz/PM/DataModel/UserPreferences.js
index 919289d..d44ad89 100644
--- a/frontend/beta/js/Clipperz/PM/DataModel/UserPreferences.js
+++ b/frontend/beta/js/Clipperz/PM/DataModel/UserPreferences.js
@@ -1,195 +1,193 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer to http://www.clipperz.com.
9 8
10* Clipperz Community Edition is free software: you can redistribute 9* Clipperz is free software: you can redistribute it and/or modify it
11 it and/or modify it under the terms of the GNU Affero General Public 10 under the terms of the GNU Affero General Public License as published
12 License as published by the Free Software Foundation, either version 11 by the Free Software Foundation, either version 3 of the License, or
13 3 of the License, or (at your option) any later version. 12 (at your option) any later version.
14 13
15* Clipperz Community Edition is distributed in the hope that it will 14* Clipperz is distributed in the hope that it will be useful, but
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 15 WITHOUT ANY WARRANTY; without even the implied warranty of
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 17 See the GNU Affero General Public License for more details.
19 18
20* You should have received a copy of the GNU Affero General Public 19* You should have received a copy of the GNU Affero General Public
21 License along with Clipperz Community Edition. If not, see 20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
22 <http://www.gnu.org/licenses/>.
23 21
24*/ 22*/
25 23
26if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 24if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
27if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } 25if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
28if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } 26if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
29 27
30 28
31//############################################################################# 29//#############################################################################
32 30
33Clipperz.PM.DataModel.UserPreferences = function(args) { 31Clipperz.PM.DataModel.UserPreferences = function(args) {
34 args = args || {}; 32 args = args || {};
35 33
36 this._user = args['user']; delete args['user']; 34 this._user = args['user']; delete args['user'];
37 this._config = args; 35 this._config = args;
38 36
39 return this; 37 return this;
40} 38}
41 39
42Clipperz.PM.DataModel.UserPreferences.prototype = MochiKit.Base.update(null, { 40Clipperz.PM.DataModel.UserPreferences.prototype = MochiKit.Base.update(null, {
43 41
44 //------------------------------------------------------------------------- 42 //-------------------------------------------------------------------------
45 43
46 'config': function() { 44 'config': function() {
47 return this._config; 45 return this._config;
48 }, 46 },
49 47
50 //------------------------------------------------------------------------- 48 //-------------------------------------------------------------------------
51 49
52 'user': function() { 50 'user': function() {
53 return this._user; 51 return this._user;
54 }, 52 },
55 53
56 //------------------------------------------------------------------------- 54 //-------------------------------------------------------------------------
57 55
58 'updateWithData': function(someValues) { 56 'updateWithData': function(someValues) {
59 var currentLanguage; 57 var currentLanguage;
60 58
61//MochiKit.Logging.logDebug(">>> Clipperz.PM.DataModel.UserPreferences.updateWithData: " + Clipperz.Base.serializeJSON(someValues)); 59//MochiKit.Logging.logDebug(">>> Clipperz.PM.DataModel.UserPreferences.updateWithData: " + Clipperz.Base.serializeJSON(someValues));
62 currentLanguage = this.preferredLanguage(); 60 currentLanguage = this.preferredLanguage();
63 61
64 MochiKit.Base.update(this._config, someValues); 62 MochiKit.Base.update(this._config, someValues);
65 63
66 if (this.preferredLanguage() != currentLanguage) { 64 if (this.preferredLanguage() != currentLanguage) {
67 Clipperz.PM.Strings.Languages.setSelectedLanguage(this.preferredLanguage()); 65 Clipperz.PM.Strings.Languages.setSelectedLanguage(this.preferredLanguage());
68 } else { 66 } else {
69//MochiKit.Logging.logDebug("### keepping the browser selected language: " + Clipperz.PM.Strings.selectedLanguage); 67//MochiKit.Logging.logDebug("### keepping the browser selected language: " + Clipperz.PM.Strings.selectedLanguage);
70 } 68 }
71 69
72 return this; 70 return this;
73 }, 71 },
74 72
75 //------------------------------------------------------------------------- 73 //-------------------------------------------------------------------------
76 74
77 'configValue': function(aConfigName, aDefaultValue) { 75 'configValue': function(aConfigName, aDefaultValue) {
78 var result; 76 var result;
79 77
80//MochiKit.Logging.logDebug(">>> UserPreferences.configValue - config: " + Clipperz.Base.serializeJSON(this.config())); 78//MochiKit.Logging.logDebug(">>> UserPreferences.configValue - config: " + Clipperz.Base.serializeJSON(this.config()));
81 if (typeof(this.config()[aConfigName]) == 'undefined') { 79 if (typeof(this.config()[aConfigName]) == 'undefined') {
82 result = aDefaultValue; 80 result = aDefaultValue;
83 } else { 81 } else {
84 result = this.config()[aConfigName]; 82 result = this.config()[aConfigName];
85 } 83 }
86//MochiKit.Logging.logDebug("<<< UserPreferences.configValue"); 84//MochiKit.Logging.logDebug("<<< UserPreferences.configValue");
87 85
88 return result; 86 return result;
89 }, 87 },
90 88
91 'setConfigValue': function(aConfigName, aValue) { 89 'setConfigValue': function(aConfigName, aValue) {
92 var result; 90 var result;
93 91
94 if (aValue != this.configValue(aConfigName)) { 92 if (aValue != this.configValue(aConfigName)) {
95 if (aValue == null) { 93 if (aValue == null) {
96 delete this.config()[aConfigName] 94 delete this.config()[aConfigName]
97 } else { 95 } else {
98 this.config()[aConfigName] = aValue; 96 this.config()[aConfigName] = aValue;
99 } 97 }
100 98
101 Clipperz.NotificationCenter.notify(this.user(), 'updatedSection', 'preferences', true); 99 Clipperz.NotificationCenter.notify(this.user(), 'updatedSection', 'preferences', true);
102 100
103 result = true; 101 result = true;
104 } else { 102 } else {
105 result = false; 103 result = false;
106 } 104 }
107 105
108 return result; 106 return result;
109 }, 107 },
110 108
111 //------------------------------------------------------------------------- 109 //-------------------------------------------------------------------------
112 110
113 'useSafeEditMode': function() { 111 'useSafeEditMode': function() {
114 return this.configValue('useSafeEditMode', true); 112 return this.configValue('useSafeEditMode', true);
115 }, 113 },
116 114
117 'setUseSafeEditMode': function(aValue) { 115 'setUseSafeEditMode': function(aValue) {
118 this.setConfigValue('useSafeEditMode', aValue); 116 this.setConfigValue('useSafeEditMode', aValue);
119 }, 117 },
120 118
121 //------------------------------------------------------------------------- 119 //-------------------------------------------------------------------------
122 120
123 'preferredLanguage': function() { 121 'preferredLanguage': function() {
124 return this.configValue('preferredLanguage', null); 122 return this.configValue('preferredLanguage', null);
125 }, 123 },
126 124
127 'setPreferredLanguage': function(aValue) { 125 'setPreferredLanguage': function(aValue) {
128 if (this.setConfigValue('preferredLanguage', aValue)) { 126 if (this.setConfigValue('preferredLanguage', aValue)) {
129 Clipperz.PM.Strings.Languages.setSelectedLanguage(this.preferredLanguage()); 127 Clipperz.PM.Strings.Languages.setSelectedLanguage(this.preferredLanguage());
130 } 128 }
131 }, 129 },
132 130
133 //------------------------------------------------------------------------- 131 //-------------------------------------------------------------------------
134 132
135 'shouldShowDonationPanel': function() { 133 'shouldShowDonationPanel': function() {
136 return this.configValue('shouldShowDonationPanel', true); 134 return this.configValue('shouldShowDonationPanel', true);
137 }, 135 },
138 136
139 'setShouldShowDonationPanel': function(aValue) { 137 'setShouldShowDonationPanel': function(aValue) {
140 this.setConfigValue('shouldShowDonationPanel', aValue); 138 this.setConfigValue('shouldShowDonationPanel', aValue);
141 }, 139 },
142 140
143 //------------------------------------------------------------------------- 141 //-------------------------------------------------------------------------
144 142
145 'disableUnsecureFaviconLoadingForIE': function() { 143 'disableUnsecureFaviconLoadingForIE': function() {
146 return this.configValue('disableUnsecureFaviconLoadingForIE', false); 144 return this.configValue('disableUnsecureFaviconLoadingForIE', false);
147 }, 145 },
148 146
149 'setDisableUnsecureFaviconLoadingForIE': function(aValue) { 147 'setDisableUnsecureFaviconLoadingForIE': function(aValue) {
150 this.setConfigValue('disableUnsecureFaviconLoadingForIE', aValue); 148 this.setConfigValue('disableUnsecureFaviconLoadingForIE', aValue);
151 }, 149 },
152 150
153 //------------------------------------------------------------------------- 151 //-------------------------------------------------------------------------
154 152
155 'serializedData': function() { 153 'serializedData': function() {
156 return this.config(); 154 return this.config();
157 }, 155 },
158 156
159 //------------------------------------------------------------------------- 157 //-------------------------------------------------------------------------
160 158
161 'saveChanges': function(aReferenceElement) { 159 'saveChanges': function(aReferenceElement) {
162 vardeferredResult; 160 vardeferredResult;
163 161
164 deferredResult = new MochiKit.Async.Deferred(); 162 deferredResult = new MochiKit.Async.Deferred();
165 163
166 deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), 164 deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'),
167 { 165 {
168 title:"", //Clipperz.PM.Strings['accountPreferencesSavingPanelTitle_Step1'], 166 title:"", //Clipperz.PM.Strings['accountPreferencesSavingPanelTitle_Step1'],
169 text:"", //Clipperz.PM.Strings['accountPreferencesSavingPanelText_Step1'], 167 text:"", //Clipperz.PM.Strings['accountPreferencesSavingPanelText_Step1'],
170 width:240, 168 width:240,
171 showProgressBar:true, 169 showProgressBar:true,
172 showCloseButton:false 170 showCloseButton:false
173 }, 171 },
174 aReferenceElement 172 aReferenceElement
175 ); 173 );
176 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'account_savingPreferences_1'); 174 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'account_savingPreferences_1');
177 deferredResult.addCallback(MochiKit.Base.method(this.user(), 'encryptedData')); 175 deferredResult.addCallback(MochiKit.Base.method(this.user(), 'encryptedData'));
178 deferredResult.addCallback(function(res) { 176 deferredResult.addCallback(function(res) {
179 return {user:res}; 177 return {user:res};
180 }) 178 })
181 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'account_savingPreferences_2'); 179 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'account_savingPreferences_2');
182 // deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'updateData'); 180 // deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'updateData');
183 deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'saveChanges'); 181 deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'saveChanges');
184 deferredResult.addCallback(Clipperz.PM.Components.MessageBox().hide, YAHOO.ext.Element.get('main')); 182 deferredResult.addCallback(Clipperz.PM.Components.MessageBox().hide, YAHOO.ext.Element.get('main'));
185 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedPreferences', null); 183 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedPreferences', null);
186 184
187 deferredResult.callback(); 185 deferredResult.callback();
188 186
189 return deferredResult; 187 return deferredResult;
190 }, 188 },
191 189
192 //------------------------------------------------------------------------- 190 //-------------------------------------------------------------------------
193 __syntaxFix__: "syntax fix" 191 __syntaxFix__: "syntax fix"
194}); 192});
195 193