summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js') (more/less context) (show whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js192
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
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer 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
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
31if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
32
33
34//#############################################################################
35
36Clipperz.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
66Clipperz.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