author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
commit | 541bb378ddece2eab135a8066a16994e94436dea (patch) (unidiff) | |
tree | ff160ea3e26f7fe07fcfd401387c5a0232ca715e /frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js | |
parent | 1bf431fd3d45cbdf4afa3e12afefe5d24f4d3bc7 (diff) | |
parent | ecad5e895831337216544e81f1a467e0c68c4a6a (diff) | |
download | clipperz-541bb378ddece2eab135a8066a16994e94436dea.zip clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.gz clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.bz2 |
Merge pull request #1 from gcsolaroli/master
First version of the restructured repository
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js | 192 |
1 files changed, 192 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js b/frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js new file mode 100644 index 0000000..b067a21 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js | |||
@@ -0,0 +1,192 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
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 | ||
11 | refer to http://www.clipperz.com | ||
12 | |||
13 | * Javascript Crypto Library is free software: you can redistribute | ||
14 | 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 | ||
16 | 3 of the License, or (at your option) any later version. | ||
17 | |||
18 | * Javascript Crypto Library is distributed in the hope that it will | ||
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
21 | See the GNU Affero General Public License for more details. | ||
22 | |||
23 | * You should have received a copy of the GNU Affero General Public | ||
24 | License along with Javascript Crypto Library. If not, see | ||
25 | <http://www.gnu.org/licenses/>. | ||
26 | |||
27 | */ | ||
28 | |||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | ||
32 | |||
33 | |||
34 | //############################################################################# | ||
35 | |||
36 | Clipperz.PM.DataModel.DirectLoginReference = function(args) { | ||
37 | args = args || {}; | ||
38 | |||
39 | //MochiKit.Logging.logDebug(">>> new DirectLoginReference: " + Clipperz.Base.serializeJSON(MochiKit.Base.keys(args))); | ||
40 | //MochiKit.Logging.logDebug(">>> new DirectLoginReference - record: " + args.record); | ||
41 | this._user = args.user; | ||
42 | |||
43 | if (args.directLogin != null) { | ||
44 | this._reference = args.directLogin.reference(); | ||
45 | this._recordReference = args.directLogin.record().reference(); | ||
46 | this._label = args.directLogin.label(); | ||
47 | this._favicon = args.directLogin.favicon() || null; | ||
48 | |||
49 | this._directLogin = args.directLogin; | ||
50 | this._record = args.directLogin.record(); | ||
51 | } else { | ||
52 | this._reference = args.reference; | ||
53 | this._recordReference = args.record; | ||
54 | this._label = args.label; | ||
55 | this._favicon = args.favicon || null; | ||
56 | |||
57 | this._directLogin = null; | ||
58 | this._record = null; | ||
59 | } | ||
60 | |||
61 | this._fixedFavicon = null; | ||
62 | |||
63 | return this; | ||
64 | } | ||
65 | |||
66 | Clipperz.PM.DataModel.DirectLoginReference.prototype = MochiKit.Base.update(null, { | ||
67 | |||
68 | 'user': function() { | ||
69 | return this._user; | ||
70 | }, | ||
71 | |||
72 | //------------------------------------------------------------------------- | ||
73 | |||
74 | 'reference': function() { | ||
75 | return this._reference; | ||
76 | }, | ||
77 | |||
78 | //------------------------------------------------------------------------- | ||
79 | |||
80 | 'synchronizeValues': function(aDirectLogin) { | ||
81 | this._label = aDirectLogin.label(); | ||
82 | this._favicon = aDirectLogin.favicon(); | ||
83 | }, | ||
84 | |||
85 | //------------------------------------------------------------------------- | ||
86 | |||
87 | 'label': function() { | ||
88 | return this._label; | ||
89 | }, | ||
90 | |||
91 | //------------------------------------------------------------------------- | ||
92 | |||
93 | 'recordReference': function() { | ||
94 | return this._recordReference; | ||
95 | }, | ||
96 | |||
97 | //------------------------------------------------------------------------- | ||
98 | |||
99 | 'record': function() { | ||
100 | //MochiKit.Logging.logDebug(">>> DirectLoginReference.record"); | ||
101 | if (this._record == null) { | ||
102 | this._record = this.user().records()[this.recordReference()]; | ||
103 | } | ||
104 | |||
105 | //MochiKit.Logging.logDebug("<<< DirectLoginReference.record"); | ||
106 | return this._record; | ||
107 | }, | ||
108 | |||
109 | //------------------------------------------------------------------------- | ||
110 | |||
111 | 'favicon': function() { | ||
112 | return this._favicon; | ||
113 | }, | ||
114 | |||
115 | //------------------------------------------------------------------------- | ||
116 | |||
117 | 'fixedFavicon': function() { | ||
118 | var result; | ||
119 | |||
120 | if (this._fixedFavicon == null) { | ||
121 | result = this.favicon(); | ||
122 | |||
123 | if (Clipperz_IEisBroken && (this.user().preferences().disableUnsecureFaviconLoadingForIE()) && (result.indexOf('https://') != 0)) { | ||
124 | result = Clipperz.PM.Strings['defaultFaviconUrl_IE']; | ||
125 | this.setFixedFavicon(result); | ||
126 | } | ||
127 | } else { | ||
128 | result = this._fixedFavicon; | ||
129 | } | ||
130 | |||
131 | return result; | ||
132 | }, | ||
133 | |||
134 | 'setFixedFavicon': function(aValue) { | ||
135 | this._fixedFavicon = aValue; | ||
136 | }, | ||
137 | |||
138 | //------------------------------------------------------------------------- | ||
139 | |||
140 | 'setupJumpPageWindow': function(aWindow) { | ||
141 | //MochiKit.Logging.logDebug(">>> DirectLoginReference.setupJumpPageWindow - " + aWindow); | ||
142 | try { | ||
143 | MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function() { | ||
144 | MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, | ||
145 | MochiKit.DOM.H1(null, "Loading " + this.label()) | ||
146 | ); | ||
147 | }, this)); | ||
148 | } catch(e) { | ||
149 | MochiKit.Logging.logDebug("EXCEPTION: " + e); | ||
150 | } | ||
151 | //MochiKit.Logging.logDebug("<<< DirectLoginReference.setupJumpPageWindow"); | ||
152 | }, | ||
153 | |||
154 | //------------------------------------------------------------------------- | ||
155 | |||
156 | 'deferredDirectLogin': function() { | ||
157 | var deferredResult; | ||
158 | |||
159 | //MochiKit.Logging.logDebug(">>> DirectLoginReference.deferredDirectLogin - " + this); | ||
160 | deferredResult = new MochiKit.Async.Deferred(); | ||
161 | //MochiKit.Logging.logDebug("--- DirectLoginReference.deferredDirectLogin - 1"); | ||
162 | deferredResult.addCallback(MochiKit.Base.method(this.record(), 'deferredData')); | ||
163 | //MochiKit.Logging.logDebug("--- DirectLoginReference.deferredDirectLogin - 2"); | ||
164 | deferredResult.addCallback(function(aRecord, aDirectLoginReference) { | ||
165 | return aRecord.directLogins()[aDirectLoginReference]; | ||
166 | }, this.record(), this.reference()); | ||
167 | //MochiKit.Logging.logDebug("--- DirectLoginReference.deferredDirectLogin - 3"); | ||
168 | deferredResult.callback(); | ||
169 | //MochiKit.Logging.logDebug("<<< DirectLoginReference.deferredDirectLogin"); | ||
170 | |||
171 | return deferredResult; | ||
172 | }, | ||
173 | |||
174 | //------------------------------------------------------------------------- | ||
175 | |||
176 | 'handleMissingFaviconImage': function(anEvent) { | ||
177 | //MochiKit.Logging.logDebug(">>> DirectLoginReference.handleMissingFaviconImage"); | ||
178 | anEvent.stop(); | ||
179 | MochiKit.Signal.disconnectAll(anEvent.src()); | ||
180 | this.setFixedFavicon(Clipperz.PM.Strings['defaultFaviconUrl']); | ||
181 | //MochiKit.Logging.logDebug("--- DirectLoginReference.handleMissingFaviconImage - fixedFavicon: " + this.fixedFavicon()); | ||
182 | //MochiKit.Logging.logDebug("--- DirectLoginReference.handleMissingFaviconImage - anEvent.src().src: " + anEvent.src().src); | ||
183 | // MochiKit.DOM.swapDOM(anEvent.src(), MochiKit.DOM.IMG({src:'this.fixedFavicon()'})); | ||
184 | anEvent.src().src = this.fixedFavicon(); | ||
185 | //MochiKit.Logging.logDebug("<<< DirectLoginReference.handleMissingFaviconImage"); | ||
186 | }, | ||
187 | |||
188 | //------------------------------------------------------------------------- | ||
189 | __syntaxFix__: "syntax fix" | ||
190 | |||
191 | }); | ||
192 | |||