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.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/UserPreferences.js b/frontend/beta/js/Clipperz/PM/DataModel/UserPreferences.js index dc73ce1..9e80b3a 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/UserPreferences.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/UserPreferences.js | |||
@@ -1,152 +1,149 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | it and/or modify it under the terms of the GNU Affero General Public |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
31 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
32 | 29 | ||
33 | 30 | ||
34 | //############################################################################# | 31 | //############################################################################# |
35 | 32 | ||
36 | Clipperz.PM.DataModel.UserPreferences = function(args) { | 33 | Clipperz.PM.DataModel.UserPreferences = function(args) { |
37 | args = args || {}; | 34 | args = args || {}; |
38 | 35 | ||
39 | this._user = args['user']; delete args['user']; | 36 | this._user = args['user']; delete args['user']; |
40 | this._config = args; | 37 | this._config = args; |
41 | 38 | ||
42 | return this; | 39 | return this; |
43 | } | 40 | } |
44 | 41 | ||
45 | Clipperz.PM.DataModel.UserPreferences.prototype = MochiKit.Base.update(null, { | 42 | Clipperz.PM.DataModel.UserPreferences.prototype = MochiKit.Base.update(null, { |
46 | 43 | ||
47 | //------------------------------------------------------------------------- | 44 | //------------------------------------------------------------------------- |
48 | 45 | ||
49 | 'config': function() { | 46 | 'config': function() { |
50 | return this._config; | 47 | return this._config; |
51 | }, | 48 | }, |
52 | 49 | ||
53 | //------------------------------------------------------------------------- | 50 | //------------------------------------------------------------------------- |
54 | 51 | ||
55 | 'user': function() { | 52 | 'user': function() { |
56 | return this._user; | 53 | return this._user; |
57 | }, | 54 | }, |
58 | 55 | ||
59 | //------------------------------------------------------------------------- | 56 | //------------------------------------------------------------------------- |
60 | 57 | ||
61 | 'updateWithData': function(someValues) { | 58 | 'updateWithData': function(someValues) { |
62 | var currentLanguage; | 59 | var currentLanguage; |
63 | 60 | ||
64 | //MochiKit.Logging.logDebug(">>> Clipperz.PM.DataModel.UserPreferences.updateWithData: " + Clipperz.Base.serializeJSON(someValues)); | 61 | //MochiKit.Logging.logDebug(">>> Clipperz.PM.DataModel.UserPreferences.updateWithData: " + Clipperz.Base.serializeJSON(someValues)); |
65 | currentLanguage = this.preferredLanguage(); | 62 | currentLanguage = this.preferredLanguage(); |
66 | 63 | ||
67 | MochiKit.Base.update(this._config, someValues); | 64 | MochiKit.Base.update(this._config, someValues); |
68 | 65 | ||
69 | if (this.preferredLanguage() != currentLanguage) { | 66 | if (this.preferredLanguage() != currentLanguage) { |
70 | Clipperz.PM.Strings.Languages.setSelectedLanguage(this.preferredLanguage()); | 67 | Clipperz.PM.Strings.Languages.setSelectedLanguage(this.preferredLanguage()); |
71 | } else { | 68 | } else { |
72 | //MochiKit.Logging.logDebug("### keepping the browser selected language: " + Clipperz.PM.Strings.selectedLanguage); | 69 | //MochiKit.Logging.logDebug("### keepping the browser selected language: " + Clipperz.PM.Strings.selectedLanguage); |
73 | } | 70 | } |
74 | 71 | ||
75 | return this; | 72 | return this; |
76 | }, | 73 | }, |
77 | 74 | ||
78 | //------------------------------------------------------------------------- | 75 | //------------------------------------------------------------------------- |
79 | 76 | ||
80 | 'configValue': function(aConfigName, aDefaultValue) { | 77 | 'configValue': function(aConfigName, aDefaultValue) { |
81 | var result; | 78 | var result; |
82 | 79 | ||
83 | //MochiKit.Logging.logDebug(">>> UserPreferences.configValue - config: " + Clipperz.Base.serializeJSON(this.config())); | 80 | //MochiKit.Logging.logDebug(">>> UserPreferences.configValue - config: " + Clipperz.Base.serializeJSON(this.config())); |
84 | if (typeof(this.config()[aConfigName]) == 'undefined') { | 81 | if (typeof(this.config()[aConfigName]) == 'undefined') { |
85 | result = aDefaultValue; | 82 | result = aDefaultValue; |
86 | } else { | 83 | } else { |
87 | result = this.config()[aConfigName]; | 84 | result = this.config()[aConfigName]; |
88 | } | 85 | } |
89 | //MochiKit.Logging.logDebug("<<< UserPreferences.configValue"); | 86 | //MochiKit.Logging.logDebug("<<< UserPreferences.configValue"); |
90 | 87 | ||
91 | return result; | 88 | return result; |
92 | }, | 89 | }, |
93 | 90 | ||
94 | 'setConfigValue': function(aConfigName, aValue) { | 91 | 'setConfigValue': function(aConfigName, aValue) { |
95 | var result; | 92 | var result; |
96 | 93 | ||
97 | if (aValue != this.configValue(aConfigName)) { | 94 | if (aValue != this.configValue(aConfigName)) { |
98 | if (aValue == null) { | 95 | if (aValue == null) { |
99 | delete this.config()[aConfigName] | 96 | delete this.config()[aConfigName] |
100 | } else { | 97 | } else { |
101 | this.config()[aConfigName] = aValue; | 98 | this.config()[aConfigName] = aValue; |
102 | } | 99 | } |
103 | 100 | ||
104 | Clipperz.NotificationCenter.notify(this.user(), 'updatedSection', 'preferences', true); | 101 | Clipperz.NotificationCenter.notify(this.user(), 'updatedSection', 'preferences', true); |
105 | 102 | ||
106 | result = true; | 103 | result = true; |
107 | } else { | 104 | } else { |
108 | result = false; | 105 | result = false; |
109 | } | 106 | } |
110 | 107 | ||
111 | return result; | 108 | return result; |
112 | }, | 109 | }, |
113 | 110 | ||
114 | //------------------------------------------------------------------------- | 111 | //------------------------------------------------------------------------- |
115 | 112 | ||
116 | 'useSafeEditMode': function() { | 113 | 'useSafeEditMode': function() { |
117 | return this.configValue('useSafeEditMode', true); | 114 | return this.configValue('useSafeEditMode', true); |
118 | }, | 115 | }, |
119 | 116 | ||
120 | 'setUseSafeEditMode': function(aValue) { | 117 | 'setUseSafeEditMode': function(aValue) { |
121 | this.setConfigValue('useSafeEditMode', aValue); | 118 | this.setConfigValue('useSafeEditMode', aValue); |
122 | }, | 119 | }, |
123 | 120 | ||
124 | //------------------------------------------------------------------------- | 121 | //------------------------------------------------------------------------- |
125 | 122 | ||
126 | 'preferredLanguage': function() { | 123 | 'preferredLanguage': function() { |
127 | return this.configValue('preferredLanguage', null); | 124 | return this.configValue('preferredLanguage', null); |
128 | }, | 125 | }, |
129 | 126 | ||
130 | 'setPreferredLanguage': function(aValue) { | 127 | 'setPreferredLanguage': function(aValue) { |
131 | if (this.setConfigValue('preferredLanguage', aValue)) { | 128 | if (this.setConfigValue('preferredLanguage', aValue)) { |
132 | Clipperz.PM.Strings.Languages.setSelectedLanguage(this.preferredLanguage()); | 129 | Clipperz.PM.Strings.Languages.setSelectedLanguage(this.preferredLanguage()); |
133 | } | 130 | } |
134 | }, | 131 | }, |
135 | 132 | ||
136 | //------------------------------------------------------------------------- | 133 | //------------------------------------------------------------------------- |
137 | 134 | ||
138 | 'shouldShowDonationPanel': function() { | 135 | 'shouldShowDonationPanel': function() { |
139 | return this.configValue('shouldShowDonationPanel', true); | 136 | return this.configValue('shouldShowDonationPanel', true); |
140 | }, | 137 | }, |
141 | 138 | ||
142 | 'setShouldShowDonationPanel': function(aValue) { | 139 | 'setShouldShowDonationPanel': function(aValue) { |
143 | this.setConfigValue('shouldShowDonationPanel', aValue); | 140 | this.setConfigValue('shouldShowDonationPanel', aValue); |
144 | }, | 141 | }, |
145 | 142 | ||
146 | //------------------------------------------------------------------------- | 143 | //------------------------------------------------------------------------- |
147 | 144 | ||
148 | 'disableUnsecureFaviconLoadingForIE': function() { | 145 | 'disableUnsecureFaviconLoadingForIE': function() { |
149 | return this.configValue('disableUnsecureFaviconLoadingForIE', false); | 146 | return this.configValue('disableUnsecureFaviconLoadingForIE', false); |
150 | }, | 147 | }, |
151 | 148 | ||
152 | 'setDisableUnsecureFaviconLoadingForIE': function(aValue) { | 149 | 'setDisableUnsecureFaviconLoadingForIE': function(aValue) { |