Diffstat (limited to 'frontend/gamma/js/Clipperz/PM') (more/less context) (ignore whitespace changes)
4 files changed, 34 insertions, 61 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/Proxy.js b/frontend/gamma/js/Clipperz/PM/Proxy.js index 9817eac..190bffd 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy.js | |||
@@ -49,121 +49,121 @@ Clipperz.PM.Proxy = function(args) { | |||
49 | Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, { | 49 | Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, { |
50 | 50 | ||
51 | 'toString': function() { | 51 | 'toString': function() { |
52 | return "Clipperz.PM.Proxy"; | 52 | return "Clipperz.PM.Proxy"; |
53 | }, | 53 | }, |
54 | 54 | ||
55 | //========================================================================= | 55 | //========================================================================= |
56 | 56 | ||
57 | 'shouldPayTolls': function() { | 57 | 'shouldPayTolls': function() { |
58 | return this._shouldPayTolls; | 58 | return this._shouldPayTolls; |
59 | }, | 59 | }, |
60 | 60 | ||
61 | //------------------------------------------------------------------------- | 61 | //------------------------------------------------------------------------- |
62 | 62 | ||
63 | 'tolls': function() { | 63 | 'tolls': function() { |
64 | return this._tolls; | 64 | return this._tolls; |
65 | }, | 65 | }, |
66 | 66 | ||
67 | //------------------------------------------------------------------------- | 67 | //------------------------------------------------------------------------- |
68 | 68 | ||
69 | 'payToll': function(aRequestType, someParameters) { | 69 | 'payToll': function(aRequestType, someParameters) { |
70 | vardeferredResult; | 70 | vardeferredResult; |
71 | 71 | ||
72 | //console.log(">>> Proxy.payToll", aRequestType, someParameters); | 72 | //console.log(">>> Proxy.payToll", aRequestType, someParameters); |
73 | if (this.shouldPayTolls()) { | 73 | if (this.shouldPayTolls()) { |
74 | deferredResult = new Clipperz.Async.Deferred("Proxy.payToll", {trace:false}); | 74 | deferredResult = new Clipperz.Async.Deferred("Proxy.payToll", {trace:false}); |
75 | 75 | ||
76 | if (this.tolls()[aRequestType].length == 0) { | 76 | if (this.tolls()[aRequestType].length == 0) { |
77 | deferredResult.addMethod(this, 'sendMessage', 'knock', {requestType:aRequestType}); | 77 | deferredResult.addMethod(this, 'sendMessage', 'knock', {requestType:aRequestType}); |
78 | deferredResult.addMethod(this, 'setTollCallback'); | 78 | deferredResult.addMethod(this, 'setTollCallback'); |
79 | } | 79 | } |
80 | deferredResult.addMethod(this.tolls()[aRequestType], 'pop'); | 80 | deferredResult.addMethod(this.tolls()[aRequestType], 'pop'); |
81 | deferredResult.addCallback(MochiKit.Base.methodcaller('deferredPay')); | 81 | deferredResult.addCallback(MochiKit.Base.methodcaller('deferredPay')); |
82 | deferredResult.addCallback(function(aToll) { | 82 | deferredResult.addCallback(function(aToll) { |
83 | var result; | 83 | var result; |
84 | 84 | ||
85 | result = { | 85 | result = { |
86 | parameters: someParameters, | 86 | parameters: someParameters, |
87 | toll: aToll | 87 | toll: aToll |
88 | } | 88 | } |
89 | 89 | ||
90 | return result; | 90 | return result; |
91 | }); | 91 | }); |
92 | 92 | ||
93 | deferredResult.callback(); | 93 | deferredResult.callback(); |
94 | } else { | 94 | } else { |
95 | deferredResult = MochiKit.Async.succeed({parameters:someParameters}); | 95 | deferredResult = MochiKit.Async.succeed({parameters:someParameters}); |
96 | } | 96 | } |
97 | //console.log("<<< Proxy.payToll"); | 97 | //console.log("<<< Proxy.payToll"); |
98 | 98 | ||
99 | return deferredResult; | 99 | return deferredResult; |
100 | }, | 100 | }, |
101 | 101 | ||
102 | //------------------------------------------------------------------------- | 102 | //------------------------------------------------------------------------- |
103 | 103 | ||
104 | 'addToll': function(aToll) { | 104 | 'addToll': function(aToll) { |
105 | //console.log(">>> Proxy.addToll", aToll); | 105 | //console.log(">>> Proxy.addToll", aToll); |
106 | this.tolls()[aToll.requestType()].push(aToll); | 106 | this.tolls()[aToll.requestType()].push(aToll); |
107 | //console.log("<<< Proxy.addToll"); | 107 | //console.log("<<< Proxy.addToll"); |
108 | }, | 108 | }, |
109 | 109 | ||
110 | //========================================================================= | 110 | //========================================================================= |
111 | 111 | ||
112 | 'setTollCallback': function(someParameters) { | 112 | 'setTollCallback': function(someParameters) { |
113 | //console.log(">>> Proxy.setTollCallback", someParameters); | 113 | //console.log(">>> Proxy.setTollCallback", someParameters); |
114 | if (typeof(someParameters['toll']) != 'undefined') { | 114 | if (typeof(someParameters['toll']) != 'undefined') { |
115 | //console.log("added a new toll", someParameters['toll']); | 115 | //console.log("added a new toll", someParameters['toll']); |
116 | this.addToll(new Clipperz.PM.Toll(someParameters['toll'])); | 116 | this.addToll(new Clipperz.PM.Toll(someParameters['toll'])); |
117 | } | 117 | } |
118 | //console.log("<<< Proxy.setTallCallback", someParameters['result']); | 118 | //console.log("<<< Proxy.setTallCallback", someParameters['result']); |
119 | return someParameters['result']; | 119 | return someParameters['result']; |
120 | }, | 120 | }, |
121 | 121 | ||
122 | //========================================================================= | 122 | //========================================================================= |
123 | 123 | ||
124 | 'registration': function (someParameters) { | 124 | 'registration': function (someParameters) { |
125 | return this.processMessage('registration', someParameters, 'REGISTER'); | 125 | return this.processMessage('registration', someParameters, 'REGISTER'); |
126 | }, | 126 | }, |
127 | 127 | ||
128 | 'handshake': function (someParameters) { | 128 | 'handshake': function (someParameters) { |
129 | return this.processMessage('handshake', someParameters, 'CONNECT'); | 129 | return this.processMessage('handshake', someParameters, 'CONNECT'); |
130 | }, | 130 | }, |
131 | 131 | ||
132 | 'message': function (someParameters) { | 132 | 'message': function (someParameters) { |
133 | return this.processMessage('message', someParameters, 'MESSAGE'); | 133 | return this.processMessage('message', someParameters, 'MESSAGE'); |
134 | }, | 134 | }, |
135 | 135 | ||
136 | 'logout': function (someParameters) { | 136 | 'logout': function (someParameters) { |
137 | return this.processMessage('logout', someParameters, 'MESSAGE'); | 137 | return this.processMessage('logout', someParameters, 'MESSAGE'); |
138 | }, | 138 | }, |
139 | 139 | ||
140 | //========================================================================= | 140 | //========================================================================= |
141 | 141 | ||
142 | 'processMessage': function (aFunctionName, someParameters, aRequestType) { | 142 | 'processMessage': function (aFunctionName, someParameters, aRequestType) { |
143 | vardeferredResult; | 143 | vardeferredResult; |
144 | 144 | ||
145 | deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:true}); | 145 | deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:false}); |
146 | deferredResult.addMethod(this, 'payToll', aRequestType); | 146 | deferredResult.addMethod(this, 'payToll', aRequestType); |
147 | deferredResult.addMethod(this, 'sendMessage', aFunctionName); | 147 | deferredResult.addMethod(this, 'sendMessage', aFunctionName); |
148 | deferredResult.addMethod(this, 'setTollCallback'); | 148 | deferredResult.addMethod(this, 'setTollCallback'); |
149 | deferredResult.callback(someParameters); | 149 | deferredResult.callback(someParameters); |
150 | 150 | ||
151 | return deferredResult; | 151 | return deferredResult; |
152 | }, | 152 | }, |
153 | 153 | ||
154 | //========================================================================= | 154 | //========================================================================= |
155 | 155 | ||
156 | 'sendMessage': function () { | 156 | 'sendMessage': function () { |
157 | throw Clipperz.Base.exception.AbstractMethod; | 157 | throw Clipperz.Base.exception.AbstractMethod; |
158 | }, | 158 | }, |
159 | 159 | ||
160 | //========================================================================= | 160 | //========================================================================= |
161 | 161 | ||
162 | 'isReadOnly': function () { | 162 | 'isReadOnly': function () { |
163 | return false; | 163 | return false; |
164 | }, | 164 | }, |
165 | 165 | ||
166 | //========================================================================= | 166 | //========================================================================= |
167 | __syntaxFix__: "syntax fix" | 167 | __syntaxFix__: "syntax fix" |
168 | 168 | ||
169 | }); | 169 | }); |
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js index 095e8ed..8df7e0e 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js | |||
@@ -9,205 +9,206 @@ refer to http://www.clipperz.com. | |||
9 | 9 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
11 | 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 |
12 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
13 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
14 | 14 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
19 | 19 | ||
20 | * 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 |
21 | License along with Clipperz Community Edition. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
22 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
23 | 23 | ||
24 | */ | 24 | */ |
25 | 25 | ||
26 | Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); | 26 | Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); |
27 | 27 | ||
28 | Clipperz.PM.UI.Common.Components.Tooltip = function(args) { | 28 | Clipperz.PM.UI.Common.Components.Tooltip = function(args) { |
29 | args = args || {}; | 29 | args = args || {}; |
30 | 30 | ||
31 | Clipperz.PM.UI.Common.Components.Tooltip.superclass.constructor.apply(this, arguments); | 31 | Clipperz.PM.UI.Common.Components.Tooltip.superclass.constructor.apply(this, arguments); |
32 | 32 | ||
33 | this._element = args.element|| Clipperz.Base.exception.raise('MandatoryParameter'); | 33 | this._element = args.element|| Clipperz.Base.exception.raise('MandatoryParameter'); |
34 | this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter'); | 34 | this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter'); |
35 | this._position = args.position || 'BELOW'; //'BELOW', 'ABOVE', 'LEFT', 'RIGHT' | 35 | this._position = args.position || 'BELOW'; //'BELOW', 'ABOVE', 'LEFT', 'RIGHT' |
36 | 36 | ||
37 | this._boxDimensions = null; | 37 | this._boxDimensions = null; |
38 | this._enabled = (typeof(args.enabled) == 'undefined' ? true : args.enabled); | 38 | this._enabled = (typeof(args.enabled) == 'undefined' ? true : args.enabled); |
39 | this._isVisible = false; | 39 | this._isVisible = false; |
40 | 40 | ||
41 | this.renderSelf(); | 41 | this.renderSelf(); |
42 | 42 | ||
43 | return this; | 43 | return this; |
44 | } | 44 | } |
45 | 45 | ||
46 | //============================================================================= | 46 | //============================================================================= |
47 | 47 | ||
48 | Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Tooltip, Clipperz.PM.UI.Common.Components.BaseComponent, { | 48 | Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Tooltip, Clipperz.PM.UI.Common.Components.BaseComponent, { |
49 | 49 | ||
50 | //------------------------------------------------------------------------- | 50 | //------------------------------------------------------------------------- |
51 | 51 | ||
52 | 'toString': function () { | 52 | 'toString': function () { |
53 | return "Clipperz.PM.UI.Common.Components.Tooltip component"; | 53 | return "Clipperz.PM.UI.Common.Components.Tooltip component"; |
54 | }, | 54 | }, |
55 | 55 | ||
56 | //------------------------------------------------------------------------- | 56 | //------------------------------------------------------------------------- |
57 | 57 | ||
58 | 'text': function () { | 58 | 'text': function () { |
59 | return this._text; | 59 | return this._text; |
60 | }, | 60 | }, |
61 | 61 | ||
62 | 'setText': function (aValue) { | 62 | 'setText': function (aValue) { |
63 | this._text = aValue; | 63 | this._text = aValue; |
64 | }, | 64 | }, |
65 | 65 | ||
66 | //------------------------------------------------------------------------- | 66 | //------------------------------------------------------------------------- |
67 | 67 | ||
68 | 'position': function () { | 68 | 'position': function () { |
69 | return this._position; | 69 | return this._position; |
70 | }, | 70 | }, |
71 | 71 | ||
72 | 'setPosition': function (aValue) { | 72 | 'setPosition': function (aValue) { |
73 | this._position = aValue; | 73 | this._position = aValue; |
74 | }, | 74 | }, |
75 | 75 | ||
76 | //------------------------------------------------------------------------- | 76 | //------------------------------------------------------------------------- |
77 | 77 | ||
78 | 'enabled': function () { | 78 | 'enabled': function () { |
79 | return this._enabled; | 79 | return this._enabled; |
80 | }, | 80 | }, |
81 | 81 | ||
82 | 'setIsEnabled': function (aValue) { | 82 | 'setIsEnabled': function (aValue) { |
83 | this._enabled = aValue; | 83 | this._enabled = aValue; |
84 | }, | 84 | }, |
85 | 85 | ||
86 | //------------------------------------------------------------------------- | 86 | //------------------------------------------------------------------------- |
87 | 87 | ||
88 | 'isVisible': function () { | 88 | 'isVisible': function () { |
89 | return this._isVisible; | 89 | return this._isVisible; |
90 | }, | 90 | }, |
91 | 91 | ||
92 | 'setIsVisible': function (aValue) { | 92 | 'setIsVisible': function (aValue) { |
93 | this._isVisible = aValue; | 93 | this._isVisible = aValue; |
94 | }, | 94 | }, |
95 | 95 | ||
96 | //------------------------------------------------------------------------- | 96 | //------------------------------------------------------------------------- |
97 | 97 | ||
98 | 'renderSelf': function() { | 98 | 'renderSelf': function() { |
99 | // this.append(this.element(), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ | 99 | // this.append(this.element(), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ |
100 | // this.append(MochiKit.DOM.currentDocument().body, {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ | 100 | // this.append(MochiKit.DOM.currentDocument().body, {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ |
101 | this.append(MochiKit.DOM.getElement('Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ | 101 | this.append(MochiKit.DOM.getElement('Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ |
102 | {tag:'div', id:this.getId('body'), cls:'tooltip_body', children:[ | 102 | {tag:'div', id:this.getId('body'), cls:'tooltip_body', children:[ |
103 | {tag:'div', cls:'tooltip_text', children:[ | 103 | {tag:'div', cls:'tooltip_text', children:[ |
104 | {tag:'span', html:this.text()} | 104 | {tag:'span', html:this.text()} |
105 | ]}, | 105 | ]}//, |
106 | {tag:'div', id:this.getId('footer'), cls:'tooltip_footer'} | 106 | // {tag:'div', id:this.getId('footer'), cls:'tooltip_footer'} |
107 | ]}, | 107 | ]}, |
108 | {tag:'div', id:this.getId('arrow'), cls:'tooltip_arrow'} | 108 | {tag:'div', id:this.getId('arrow'), cls:'tooltip_arrow'} |
109 | ]}); | 109 | ]}); |
110 | 110 | ||
111 | this._boxDimensions = MochiKit.Style.getElementDimensions(this.getId('body')); | 111 | this._boxDimensions = MochiKit.Style.getElementDimensions(this.getId('body')); |
112 | // this._boxDimensions.h += MochiKit.Style.getElementDimensions(this.getId('footer')).h; | 112 | // this._boxDimensions.h += MochiKit.Style.getElementDimensions(this.getId('footer')).h; |
113 | 113 | ||
114 | MochiKit.Style.hideElement(this.displayElement()); | 114 | MochiKit.Style.hideElement(this.displayElement()); |
115 | MochiKit.Signal.connect(this.element(), 'onmouseenter', this, 'show'); | 115 | MochiKit.Signal.connect(this.element(), 'onmouseenter', this, 'show'); |
116 | MochiKit.Signal.connect(this.element(), 'onmouseleave', this, 'hide'); | 116 | MochiKit.Signal.connect(this.element(), 'onmouseleave', this, 'hide'); |
117 | }, | 117 | }, |
118 | 118 | ||
119 | //----------------------------------------------------- | 119 | //----------------------------------------------------- |
120 | 120 | ||
121 | 'displayElement': function() { | 121 | 'displayElement': function() { |
122 | return this.getElement('tooltip'); | 122 | return this.getElement('tooltip'); |
123 | }, | 123 | }, |
124 | 124 | ||
125 | //------------------------------------------------------------------------- | 125 | //------------------------------------------------------------------------- |
126 | 126 | ||
127 | 'boxDimensions': function () { | 127 | 'boxDimensions': function () { |
128 | return this._boxDimensions; | 128 | return this._boxDimensions; |
129 | }, | 129 | }, |
130 | 130 | ||
131 | //------------------------------------------------------------------------- | 131 | //------------------------------------------------------------------------- |
132 | 132 | ||
133 | 'show': function () { | 133 | 'show': function () { |
134 | var elementSizeAndPosition; | 134 | var elementSizeAndPosition; |
135 | var arrowPosition; | 135 | var arrowPosition; |
136 | var bodyPosition; | 136 | var bodyPosition; |
137 | 137 | ||
138 | if (this.isVisible() == false) { | 138 | if (this.isVisible() == false) { |
139 | arrowPosition = {}; | 139 | arrowPosition = {}; |
140 | bodyPosition = {}; | 140 | bodyPosition = {}; |
141 | 141 | ||
142 | this.setIsVisible(true); | 142 | this.setIsVisible(true); |
143 | elementSizeAndPosition = Clipperz.Style.getSizeAndPosition(this.element()); | 143 | elementSizeAndPosition = Clipperz.Style.getSizeAndPosition(this.element()); |
144 | //console.log("ELEMENT SIZE AND POSITION", Clipperz.Base.serializeJSON(elementSizeAndPosition)); | 144 | //console.log("ELEMENT SIZE AND POSITION", Clipperz.Base.serializeJSON(elementSizeAndPosition)); |
145 | //console.log("BOX DIMENSIONS", Clipperz.Base.serializeJSON(this.boxDimensions())); | 145 | //console.log("BOX DIMENSIONS", Clipperz.Base.serializeJSON(this.boxDimensions())); |
146 | switch (this.position()) { | 146 | switch (this.position()) { |
147 | case 'ABOVE': | 147 | case 'ABOVE': |
148 | //console.log("ABOVE"); | 148 | //console.log("ABOVE"); |
149 | MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); | 149 | // MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); |
150 | bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); | 150 | bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); |
151 | bodyPosition.y = elementSizeAndPosition.position.y - this.boxDimensions().h - 13; | 151 | bodyPosition.y = elementSizeAndPosition.position.y - this.boxDimensions().h - 13; |
152 | 152 | ||
153 | arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); | 153 | // arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); |
154 | arrowPosition.y = elementSizeAndPosition.position.y - 13; | 154 | // arrowPosition.y = elementSizeAndPosition.position.y - 13; |
155 | break; | 155 | break; |
156 | case 'BELOW': | 156 | case 'BELOW': |
157 | //console.log("BELOW"); | 157 | //console.log("BELOW"); |
158 | MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); | 158 | // MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); |
159 | bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); | 159 | bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); |
160 | bodyPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h + 13; | 160 | bodyPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h + 13; |
161 | 161 | ||
162 | arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); | 162 | // arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); |
163 | arrowPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h; | 163 | // arrowPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h; |
164 | break; | 164 | break; |
165 | case 'LEFT': | 165 | case 'LEFT': |
166 | //console.log("LEFT"); | 166 | //console.log("LEFT"); |
167 | MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); | 167 | // MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); |
168 | bodyPosition.x = elementSizeAndPosition.position.x - this.boxDimensions().w - 13; | 168 | bodyPosition.x = elementSizeAndPosition.position.x - this.boxDimensions().w - 13; |
169 | bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); | 169 | bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); |
170 | 170 | ||
171 | arrowPosition.x = elementSizeAndPosition.position.x -13; | 171 | // arrowPosition.x = elementSizeAndPosition.position.x -13; |
172 | arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); | 172 | // arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); |
173 | break; | 173 | break; |
174 | case 'RIGHT': | 174 | case 'RIGHT': |
175 | //console.log("RIGHT"); | 175 | //console.log("RIGHT"); |
176 | MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); | 176 | // MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); |
177 | bodyPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w + 13; | 177 | bodyPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w + 13; |
178 | bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); | 178 | bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); |
179 | 179 | ||
180 | arrowPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w; | 180 | // arrowPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w; |
181 | arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); | 181 | // arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | //console.log("X: " + bodyPosition.x + ", Y: " + bodyPosition.y); | 184 | //console.log("X: " + bodyPosition.x + ", Y: " + bodyPosition.y); |
185 | 185 | ||
186 | MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition); | 186 | MochiKit.Style.setElementPosition(this.getId('tooltip'), bodyPosition); |
187 | MochiKit.Style.setElementPosition(this.getId('arrow'), arrowPosition); | 187 | // MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition); |
188 | // MochiKit.Style.setElementPosition(this.getId('arrow'), arrowPosition); | ||
188 | MochiKit.Visual.appear(this.displayElement(), {duration:0.4}); | 189 | MochiKit.Visual.appear(this.displayElement(), {duration:0.4}); |
189 | } | 190 | } |
190 | }, | 191 | }, |
191 | 192 | ||
192 | 'hide': function () { | 193 | 'hide': function () { |
193 | if (this.isVisible() == true) { | 194 | if (this.isVisible() == true) { |
194 | MochiKit.Visual.fade(this.displayElement(), {duration:0.4}); | 195 | MochiKit.Visual.fade(this.displayElement(), {duration:0.4}); |
195 | this.setIsVisible(false); | 196 | this.setIsVisible(false); |
196 | } | 197 | } |
197 | }, | 198 | }, |
198 | 199 | ||
199 | //------------------------------------------------------------------------- | 200 | //------------------------------------------------------------------------- |
200 | /* | 201 | /* |
201 | 'shouldRemoveElementWhenClearningUp': function () { | 202 | 'shouldRemoveElementWhenClearningUp': function () { |
202 | return false; | 203 | return false; |
203 | }, | 204 | }, |
204 | */ | 205 | */ |
205 | //------------------------------------------------------------------------- | 206 | //------------------------------------------------------------------------- |
206 | __syntaxFix__: "syntax fix" | 207 | __syntaxFix__: "syntax fix" |
207 | }); | 208 | }); |
208 | 209 | ||
209 | Clipperz.PM.UI.Common.Components.Tooltip.initTooltips = function () { | 210 | Clipperz.PM.UI.Common.Components.Tooltip.initTooltips = function () { |
210 | Clipperz.DOM.Helper.insertBefore(MochiKit.DOM.currentDocument().body.childNodes[0], {tag:'div', id:'Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'}); | 211 | Clipperz.DOM.Helper.insertBefore(MochiKit.DOM.currentDocument().body.childNodes[0], {tag:'div', id:'Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'}); |
211 | } | 212 | } |
212 | 213 | ||
213 | MochiKit.DOM.addLoadEvent(Clipperz.PM.UI.Common.Components.Tooltip.initTooltips); | 214 | MochiKit.DOM.addLoadEvent(Clipperz.PM.UI.Common.Components.Tooltip.initTooltips); |
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js index 389d876..a10ba4f 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js | |||
@@ -1,200 +1,178 @@ | |||
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 Community Edition. | 5 | This file is part of Clipperz Community Edition. |
6 | Clipperz Community Edition is an online password manager. | 6 | Clipperz Community Edition is an online password manager. |
7 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 8 | refer to http://www.clipperz.com. |
9 | 9 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
11 | 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 |
12 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
13 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
14 | 14 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
19 | 19 | ||
20 | * 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 |
21 | License along with Clipperz Community Edition. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
22 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
23 | 23 | ||
24 | */ | 24 | */ |
25 | 25 | ||
26 | Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); | 26 | Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); |
27 | 27 | ||
28 | Clipperz.PM.UI.Web.Components.LoginForm = function(args) { | 28 | Clipperz.PM.UI.Web.Components.LoginForm = function(args) { |
29 | args = args || {}; | 29 | args = args || {}; |
30 | 30 | ||
31 | this._autocomplete = args.autocomplete || 'off'; | 31 | this._autocomplete = args.autocomplete || 'off'; |
32 | 32 | ||
33 | Clipperz.PM.UI.Web.Components.LoginForm.superclass.constructor.apply(this, arguments); | 33 | Clipperz.PM.UI.Web.Components.LoginForm.superclass.constructor.apply(this, arguments); |
34 | 34 | ||
35 | this._slots = { | 35 | this._slots = { |
36 | 'passphraseEntropy':this.getId('passphraseEntropy') | 36 | 'passphraseEntropy':this.getId('passphraseEntropy') |
37 | }; | 37 | }; |
38 | 38 | ||
39 | return this; | 39 | return this; |
40 | } | 40 | } |
41 | 41 | ||
42 | //============================================================================= | 42 | //============================================================================= |
43 | 43 | ||
44 | Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, { | 44 | Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, { |
45 | 45 | ||
46 | //------------------------------------------------------------------------- | 46 | //------------------------------------------------------------------------- |
47 | 47 | ||
48 | 'toString': function () { | 48 | 'toString': function () { |
49 | return "Clipperz.PM.UI.Web.Components.LoginForm component"; | 49 | return "Clipperz.PM.UI.Web.Components.LoginForm component"; |
50 | }, | 50 | }, |
51 | 51 | ||
52 | 'autocomplete': function () { | 52 | 'autocomplete': function () { |
53 | return this._autocomplete; | 53 | return this._autocomplete; |
54 | }, | 54 | }, |
55 | 55 | ||
56 | //------------------------------------------------------------------------- | 56 | //------------------------------------------------------------------------- |
57 | 57 | ||
58 | 'renderSelf': function() { | 58 | 'renderSelf': function() { |
59 | this.append(this.element(), {tag:'div', id:'loginBox', children:[ | 59 | this.append(this.element(), {tag:'div', id:'loginBox', children:[ |
60 | {tag:'div', cls:'header'}, | 60 | {tag:'div', cls:'header'}, |
61 | {tag:'div', cls:'body', id:this.getId('body'), children:[ | 61 | {tag:'div', cls:'body', id:this.getId('body'), children:[ |
62 | {tag:'div', id:this.getId('loginForm'), children:[ | 62 | {tag:'div', id:this.getId('loginForm'), children:[ |
63 | {tag:'div', children:[ | 63 | {tag:'div', children:[ |
64 | {tag:'h4', html:'Login'}, | 64 | {tag:'h4', html:'Login'}, |
65 | // {tag:'form', cls:'loginForm', autocomplete:this.autocomplete(), children:[ | 65 | // {tag:'form', cls:'loginForm', autocomplete:this.autocomplete(), children:[ |
66 | {tag:'form', id:this.getId('form'), cls:'loginForm', children:[ | 66 | {tag:'form', id:this.getId('form'), cls:'loginForm', children:[ |
67 | {tag:'label', html:'username', 'for':this.getId('usernameField')}, | 67 | {tag:'label', html:'username', 'for':this.getId('usernameField')}, |
68 | {tag:'input', id:this.getId('usernameField'), type:'text', cls:'username'/*, value:'joe'*/}, | 68 | {tag:'input', id:this.getId('usernameField'), type:'text', cls:'username'}, |
69 | {tag:'ul', id:this.getId('passwordOptions'), children:[ | 69 | {tag:'label', html:'passphrase / OTP', 'for':this.getId('passphraseField')}, |
70 | {tag:'li', id:this.getId('passphraseOption'), children:[ | 70 | {tag:'input', id:this.getId('passphraseField'), type:'password', cls:'password'}, |
71 | {tag:'label', html:'passphrase / OTP', 'for':this.getId('passphraseField')}, | ||
72 | {tag:'input', id:this.getId('passphraseField'), type:'password', cls:'password'/*, value:'clipperz'*/} | ||
73 | ]} //, | ||
74 | /* | ||
75 | {tag:'li', id:this.getId('otpOption'), children:[ | ||
76 | {tag:'label', html:'one-time password', 'for':this.getId('otpField_1')}, | ||
77 | {tag:'input', id:this.getId('otpField_1'), type:'text', cls:'otp', value:'abcd-efgh'}, | ||
78 | {tag:'input', id:this.getId('otpField_2'), type:'text', cls:'otp', value:'abcd-efgh'}, | ||
79 | {tag:'input', id:this.getId('otpField_3'), type:'text', cls:'otp', value:'abcd-efgh'}, | ||
80 | {tag:'input', id:this.getId('otpField_4'), type:'text', cls:'otp', value:'abcd-efgh'} | ||
81 | ]} | ||
82 | */ | ||
83 | ]}, | ||
84 | // {tag:'input', id:this.getId('otpCheckbox'), type:'checkbox', cls:'checkbox'}, | ||
85 | // {tag:'label', html:'use a one-time passphrase', 'for':this.getId('otpCheckbox'), cls:'checkbox'}, | ||
86 | 71 | ||
87 | {tag:'div', cls:'translations', children:[ | 72 | {tag:'div', cls:'translations', children:[ |
88 | {tag:'h4', html:'choose your language'}, | 73 | {tag:'h4', html:'choose your language'}, |
89 | {tag:'ul', children:[ | 74 | {tag:'ul', children:[ |
90 | {tag:'li', cls:'selected', html:'english'}, | 75 | {tag:'li', cls:'selected', html:'english'}, |
91 | {tag:'li', html:'italiano'}, | 76 | {tag:'li', html:'italiano'}, |
92 | {tag:'li', html:'dutch'}, | 77 | {tag:'li', html:'dutch'}, |
93 | {tag:'li', html:'french'}, | 78 | {tag:'li', html:'french'}, |
94 | {tag:'li', html:'spanish'}, | 79 | {tag:'li', html:'spanish'}, |
95 | {tag:'li', html:'chinese'}, | 80 | {tag:'li', html:'chinese'}, |
96 | {tag:'li', html:'japanese'}, | 81 | {tag:'li', html:'japanese'}, |
97 | {tag:'li', html:'portugal'}, | 82 | {tag:'li', html:'portugal'}, |
98 | {tag:'li', html:'arabic'} | 83 | {tag:'li', html:'arabic'} |
99 | ]} | 84 | ]} |
100 | ]}, | 85 | ]}, |
101 | 86 | ||
102 | {tag:'input', id:this.getId('submitButton'), type:'submit', value:'login', cls:'submit'} | 87 | {tag:'input', id:this.getId('submitButton'), type:'submit', value:'login', cls:'submit'} |
103 | ]} | 88 | ]} |
104 | ]} | 89 | ]} |
105 | ]} | 90 | ]} |
106 | ]}, | 91 | ]}, |
107 | {tag:'div', cls:'footer'} | 92 | {tag:'div', cls:'footer'} |
108 | ]}); | 93 | ]}); |
109 | 94 | ||
110 | if (this.autocomplete() == 'off') { | 95 | if (this.autocomplete() == 'off') { |
111 | MochiKit.DOM.updateNodeAttributes(this.getElement('form'), {autocomplete:'off'}); | 96 | MochiKit.DOM.updateNodeAttributes(this.getElement('form'), {autocomplete:'off'}); |
112 | } | 97 | } |
113 | 98 | ||
114 | // Clipperz.Style.setBackgroundGradient(this.getElement('body'), {from:"#ff9955", to:"#ff6622"}) | 99 | // Clipperz.Style.setBackgroundGradient(this.getElement('body'), {from:"#ff9955", to:"#ff6622"}) |
115 | 100 | ||
116 | // this.setEntropyDisplay(new Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay(this.getElement('passphraseField'))); | 101 | // this.setEntropyDisplay(new Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay(this.getElement('passphraseField'))); |
117 | 102 | ||
118 | // MochiKit.Signal.connect(this.getId('otpCheckbox'), 'onclick', this, 'togglePasswordFields'); | 103 | // MochiKit.Signal.connect(this.getId('otpCheckbox'), 'onclick', this, 'togglePasswordFields'); |
119 | // this.showPassphraseField(); | 104 | // this.showPassphraseField(); |
120 | 105 | ||
121 | this.getElement('usernameField').focus(); | 106 | this.getElement('usernameField').focus(); |
122 | 107 | ||
123 | MochiKit.Signal.connect(this.getElement('loginForm'), 'onsubmit', this, 'loginEventHandler'); | 108 | MochiKit.Signal.connect(this.getElement('loginForm'), 'onsubmit', this, 'loginEventHandler'); |
124 | }, | 109 | }, |
125 | 110 | ||
126 | //----------------------------------------------------------------------------- | 111 | //----------------------------------------------------------------------------- |
127 | /* | 112 | /* |
128 | 'togglePasswordFields': function(anEvent) { | 113 | 'togglePasswordFields': function(anEvent) { |
129 | var shouldUseOTP; | 114 | var shouldUseOTP; |
130 | 115 | ||
131 | shouldUseOTP = this.getElement('otpCheckbox').checked; | 116 | shouldUseOTP = this.getElement('otpCheckbox').checked; |
132 | 117 | ||
133 | if (shouldUseOTP == false) { | 118 | if (shouldUseOTP == false) { |
134 | this.showPassphraseField(); | 119 | this.showPassphraseField(); |
135 | } else { | 120 | } else { |
136 | this.showOTPFields(); | 121 | this.showOTPFields(); |
137 | } | 122 | } |
138 | }, | 123 | }, |
139 | */ | 124 | */ |
140 | //----------------------------------------------------------------------------- | 125 | //----------------------------------------------------------------------------- |
141 | /* | 126 | /* |
142 | 'showPassphraseField': function() { | 127 | 'showPassphraseField': function() { |
143 | this.showElement('passphraseOption'); | 128 | this.showElement('passphraseOption'); |
144 | this.hideElement('otpOption'); | 129 | this.hideElement('otpOption'); |
145 | }, | 130 | }, |
146 | */ | 131 | */ |
147 | //----------------------------------------------------------------------------- | 132 | //----------------------------------------------------------------------------- |
148 | 133 | ||
149 | 'focusOnPassphraseField': function () { | 134 | 'focusOnPassphraseField': function () { |
150 | this.getElement('passphraseField').focus(); | 135 | this.getElement('passphraseField').focus(); |
151 | this.getElement('passphraseField').select(); | 136 | this.getElement('passphraseField').select(); |
152 | }, | 137 | }, |
153 | 138 | ||
154 | //----------------------------------------------------------------------------- | 139 | //----------------------------------------------------------------------------- |
155 | /* | 140 | /* |
156 | 'showOTPFields': function() { | 141 | 'showOTPFields': function() { |
157 | this.hideElement('passphraseOption'); | 142 | this.hideElement('passphraseOption'); |
158 | this.showElement('otpOption'); | 143 | this.showElement('otpOption'); |
159 | }, | 144 | }, |
160 | */ | 145 | */ |
161 | //------------------------------------------------------------------------- | 146 | //------------------------------------------------------------------------- |
162 | 147 | ||
163 | 'loginEventHandler': function(anEvent) { | 148 | 'loginEventHandler': function(anEvent) { |
164 | varusername; | 149 | // varusername; |
165 | var passphrase; | 150 | // var passphrase; |
166 | // var shouldUseOTP; | ||
167 | // var otp; | ||
168 | var signalArguments; | 151 | var signalArguments; |
169 | 152 | ||
170 | anEvent.preventDefault(); | 153 | anEvent.preventDefault(); |
171 | 154 | ||
172 | username = this.getElement('usernameField').value; | 155 | // username = this.getElement('usernameField').value; |
173 | passphrase = this.getElement('passphraseField').value; | 156 | // passphrase = this.getElement('passphraseField').value; |
174 | // otp =this.getElement('otpField_1').value + | 157 | |
175 | // this.getElement('otpField_2').value + | 158 | // signalArguments = {username:username}; |
176 | // this.getElement('otpField_3').value + | 159 | // signalArguments.passphrase = passphrase; |
177 | // this.getElement('otpField_4').value; | 160 | |
178 | // shouldUseOTP = this.getElement('otpCheckbox').checked; | 161 | signalArguments = { |
179 | 162 | 'username': this.getElement('usernameField').value, | |
180 | signalArguments = {username:username}; | 163 | 'passphrase':this.getElement('passphraseField').value |
181 | 164 | }; | |
182 | // if (shouldUseOTP) { | ||
183 | // signalArguments.otp = otp; | ||
184 | // } else { | ||
185 | signalArguments.passphrase = passphrase; | ||
186 | // } | ||
187 | 165 | ||
188 | MochiKit.Signal.signal(this, 'doLogin', signalArguments); | 166 | MochiKit.Signal.signal(this, 'doLogin', signalArguments); |
189 | }, | 167 | }, |
190 | 168 | ||
191 | //------------------------------------------------------------------------- | 169 | //------------------------------------------------------------------------- |
192 | 170 | ||
193 | 'submitButtonElement': function() { | 171 | 'submitButtonElement': function() { |
194 | return this.getElement('submitButton'); | 172 | return this.getElement('submitButton'); |
195 | }, | 173 | }, |
196 | 174 | ||
197 | //------------------------------------------------------------------------- | 175 | //------------------------------------------------------------------------- |
198 | 176 | ||
199 | __syntaxFix__: "syntax fix" | 177 | __syntaxFix__: "syntax fix" |
200 | }); | 178 | }); |
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js index d0b378c..a57152d 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js | |||
@@ -1,202 +1,196 @@ | |||
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 Community Edition. | 5 | This file is part of Clipperz Community Edition. |
6 | Clipperz Community Edition is an online password manager. | 6 | Clipperz Community Edition is an online password manager. |
7 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 8 | refer to http://www.clipperz.com. |
9 | 9 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
11 | 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 |
12 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
13 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
14 | 14 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
19 | 19 | ||
20 | * 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 |
21 | License along with Clipperz Community Edition. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
22 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
23 | 23 | ||
24 | */ | 24 | */ |
25 | 25 | ||
26 | Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); | 26 | Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); |
27 | 27 | ||
28 | Clipperz.PM.UI.Web.Controllers.LoginController = function(args) { | 28 | Clipperz.PM.UI.Web.Controllers.LoginController = function(args) { |
29 | this._args = args || {}; | 29 | this._args = args || {}; |
30 | 30 | ||
31 | this._loginPage = null; | 31 | this._loginPage = null; |
32 | 32 | ||
33 | this._newUserWizardController = null; | 33 | this._newUserWizardController = null; |
34 | this._newUserCreationComponent = null; | 34 | this._newUserCreationComponent = null; |
35 | 35 | ||
36 | return this; | 36 | return this; |
37 | } | 37 | } |
38 | 38 | ||
39 | MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.LoginController.prototype, { | 39 | MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.LoginController.prototype, { |
40 | 40 | ||
41 | 'toString': function() { | 41 | 'toString': function() { |
42 | return "Clipperz.PM.UI.Web.Controllers.LoginController"; | 42 | return "Clipperz.PM.UI.Web.Controllers.LoginController"; |
43 | }, | 43 | }, |
44 | 44 | ||
45 | 'args': function () { | 45 | 'args': function () { |
46 | return this._args; | 46 | return this._args; |
47 | }, | 47 | }, |
48 | 48 | ||
49 | //----------------------------------------------------------------------------- | 49 | //----------------------------------------------------------------------------- |
50 | 50 | ||
51 | 'loginPage': function() { | 51 | 'loginPage': function() { |
52 | if (this._loginPage == null) { | 52 | if (this._loginPage == null) { |
53 | this._loginPage = new Clipperz.PM.UI.Web.Components.LoginPage(); | 53 | this._loginPage = new Clipperz.PM.UI.Web.Components.LoginPage(); |
54 | 54 | ||
55 | MochiKit.Signal.connect(this._loginPage, 'createNewAccountClick', this, 'handleCreateNewAccountClick') | 55 | MochiKit.Signal.connect(this._loginPage, 'createNewAccountClick', this, 'handleCreateNewAccountClick') |
56 | } | 56 | } |
57 | 57 | ||
58 | return this._loginPage; | 58 | return this._loginPage; |
59 | }, | 59 | }, |
60 | 60 | ||
61 | //----------------------------------------------------------------------------- | 61 | //----------------------------------------------------------------------------- |
62 | 62 | ||
63 | 'run': function(args) { | 63 | 'run': function(args) { |
64 | varslot; | 64 | varslot; |
65 | varloginPage; | 65 | varloginPage; |
66 | varloginForm; | 66 | varloginForm; |
67 | 67 | ||
68 | slot = args.slot; | 68 | slot = args.slot; |
69 | 69 | ||
70 | loginForm =new Clipperz.PM.UI.Web.Components.LoginForm({'autocomplete': this.args()['autocomplete']}); | 70 | loginForm =new Clipperz.PM.UI.Web.Components.LoginForm({'autocomplete': this.args()['autocomplete']}); |
71 | 71 | ||
72 | slot.setContent(this.loginPage()); | 72 | slot.setContent(this.loginPage()); |
73 | this.loginPage().slotNamed('loginForm').setContent(loginForm); | 73 | this.loginPage().slotNamed('loginForm').setContent(loginForm); |
74 | 74 | ||
75 | MochiKit.Signal.connect(loginForm, 'doLogin', MochiKit.Base.method(this, 'doLogin', loginForm)); | 75 | MochiKit.Signal.connect(loginForm, 'doLogin', MochiKit.Base.method(this, 'doLogin', loginForm)); |
76 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'doLogin', MochiKit.Base.method(this, 'doLogin', loginForm)); | 76 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'doLogin', MochiKit.Base.method(this, 'doLogin', loginForm)); |
77 | }, | 77 | }, |
78 | 78 | ||
79 | //----------------------------------------------------------------------------- | 79 | //----------------------------------------------------------------------------- |
80 | 80 | ||
81 | 'doLogin': function(aLoginForm, anEvent) { | 81 | 'doLogin': function(aLoginForm, anEvent) { |
82 | var deferredResult; | 82 | var deferredResult; |
83 | varparameters; | 83 | varparameters; |
84 | // varshouldUseOTP; | ||
85 | var loginProgress; | 84 | var loginProgress; |
86 | varuser; | 85 | varuser; |
87 | var getPassphraseDelegate; | 86 | var getPassphraseDelegate; |
88 | 87 | ||
89 | parameters = anEvent; | 88 | parameters = anEvent; |
90 | // shouldUseOTP = (typeof(parameters.passphrase) == 'undefined'); | ||
91 | 89 | ||
92 | getPassphraseDelegate = MochiKit.Base.partial(MochiKit.Async.succeed, parameters.passphrase); | 90 | getPassphraseDelegate = MochiKit.Base.partial(MochiKit.Async.succeed, parameters.passphrase); |
93 | user = new Clipperz.PM.DataModel.User({'username':parameters.username, 'getPassphraseFunction':MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'getPassphrase')}); | 91 | user = new Clipperz.PM.DataModel.User({'username':parameters.username, 'getPassphraseFunction':MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'getPassphrase')}); |
94 | 92 | ||
95 | loginProgress = new Clipperz.PM.UI.Web.Components.LoginProgress(); | 93 | loginProgress = new Clipperz.PM.UI.Web.Components.LoginProgress(); |
96 | 94 | ||
97 | deferredResult = new Clipperz.Async.Deferred("LoginController.doLogin", {trace:false}); | 95 | deferredResult = new Clipperz.Async.Deferred("LoginController.doLogin", {trace:false}); |
98 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':4}); | 96 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':4}); |
99 | deferredResult.addMethod(Clipperz.PM.RunTime.mainController, 'setPassphraseDelegate', getPassphraseDelegate); | 97 | deferredResult.addMethod(Clipperz.PM.RunTime.mainController, 'setPassphraseDelegate', getPassphraseDelegate); |
100 | deferredResult.addMethod(loginProgress, 'deferredShowModal', {deferredObject:deferredResult, openFromElement:aLoginForm.submitButtonElement()}); | 98 | deferredResult.addMethod(loginProgress, 'deferredShowModal', {deferredObject:deferredResult, openFromElement:aLoginForm.submitButtonElement()}); |
101 | deferredResult.addMethod(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection'); | 99 | deferredResult.addMethod(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection'); |
102 | // if (shouldUseOTP == false) { | 100 | deferredResult.addMethod(user, 'login'); |
103 | deferredResult.addMethod(user, 'login'); | ||
104 | // } else { | ||
105 | // deferredResult.addMethod(user, 'loginUsingOTP', parameters.username, parameters.otp); | ||
106 | // } | ||
107 | deferredResult.addCallback(function(aLoginProgress, res) { | 101 | deferredResult.addCallback(function(aLoginProgress, res) { |
108 | aLoginProgress.disableCancel(); | 102 | aLoginProgress.disableCancel(); |
109 | return res; | 103 | return res; |
110 | }, loginProgress); | 104 | }, loginProgress); |
111 | deferredResult.addCallback(function () { | 105 | deferredResult.addCallback(function () { |
112 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN',MochiKit.Base.method(loginProgress, 'deferredHideModalAndRemove', {closeToElement:MochiKit.DOM.currentDocument().body})); | 106 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN',MochiKit.Base.method(loginProgress, 'deferredHideModalAndRemove', {closeToElement:MochiKit.DOM.currentDocument().body})); |
113 | }) | 107 | }) |
114 | deferredResult.addMethod(this, 'userLoggedIn', user, loginProgress, aLoginForm); | 108 | deferredResult.addMethod(this, 'userLoggedIn', user, loginProgress, aLoginForm); |
115 | deferredResult.addErrback (MochiKit.Base.method(this, 'handleFailedLogin', loginProgress)); | 109 | deferredResult.addErrback (MochiKit.Base.method(this, 'handleFailedLogin', loginProgress)); |
116 | 110 | ||
117 | deferredResult.addErrback (MochiKit.Base.method(loginProgress, 'deferredHideModalAndRemove', {closeToElement:aLoginForm.submitButtonElement()})); | 111 | deferredResult.addErrback (MochiKit.Base.method(loginProgress, 'deferredHideModalAndRemove', {closeToElement:aLoginForm.submitButtonElement()})); |
118 | deferredResult.addErrbackPass (MochiKit.Base.method(aLoginForm, 'focusOnPassphraseField')); | 112 | deferredResult.addErrbackPass (MochiKit.Base.method(aLoginForm, 'focusOnPassphraseField')); |
119 | deferredResult.addBoth(MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'removePassphraseDelegate', getPassphraseDelegate)); | 113 | deferredResult.addBoth(MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'removePassphraseDelegate', getPassphraseDelegate)); |
120 | deferredResult.callback(); | 114 | deferredResult.callback(); |
121 | 115 | ||
122 | MochiKit.Signal.connect(loginProgress, 'cancelEvent', deferredResult, 'cancel'); | 116 | MochiKit.Signal.connect(loginProgress, 'cancelEvent', deferredResult, 'cancel'); |
123 | 117 | ||
124 | return deferredResult; | 118 | return deferredResult; |
125 | }, | 119 | }, |
126 | 120 | ||
127 | //----------------------------------------------------------------------------- | 121 | //----------------------------------------------------------------------------- |
128 | 122 | ||
129 | 'userLoggedIn': function(aUser) { | 123 | 'userLoggedIn': function(aUser) { |
130 | //Clipperz.log(">>> LoginController.userLoggedIn"); | 124 | //Clipperz.log(">>> LoginController.userLoggedIn"); |
131 | MochiKit.Signal.signal(this, 'userLoggedIn', {user: aUser}); | 125 | MochiKit.Signal.signal(this, 'userLoggedIn', {user: aUser}); |
132 | //Clipperz.log("<<< LoginController.userLoggedIn"); | 126 | //Clipperz.log("<<< LoginController.userLoggedIn"); |
133 | }, | 127 | }, |
134 | 128 | ||
135 | //========================================================================= | 129 | //========================================================================= |
136 | 130 | ||
137 | 'handleCreateNewAccountClick': function (aComponent) { | 131 | 'handleCreateNewAccountClick': function (aComponent) { |
138 | // return Clipperz.PM.DataModel.User.registerNewAccount("new", "user"); | 132 | // return Clipperz.PM.DataModel.User.registerNewAccount("new", "user"); |
139 | return Clipperz.Async.callbacks("LoginController.handleCreateNewAccountClick", [ | 133 | return Clipperz.Async.callbacks("LoginController.handleCreateNewAccountClick", [ |
140 | //' MochiKit.Base.method(this, 'newUserCreationComponent'), | 134 | //' MochiKit.Base.method(this, 'newUserCreationComponent'), |
141 | // MochiKit.Base.methodcaller('deferredShowModal', {openFromElement:aComponent}), | 135 | // MochiKit.Base.methodcaller('deferredShowModal', {openFromElement:aComponent}), |
142 | // MochiKit.Base.method(this.newUserWizardController(), 'run') | 136 | // MochiKit.Base.method(this.newUserWizardController(), 'run') |
143 | 137 | ||
144 | 138 | ||
145 | MochiKit.Base.method(this, 'newUserCreationComponent'), | 139 | MochiKit.Base.method(this, 'newUserCreationComponent'), |
146 | Clipperz.Async.forkAndJoin("Async.test succeedingForkedAndWaitDeferrer", [ | 140 | Clipperz.Async.forkAndJoin("Async.test succeedingForkedAndWaitDeferrer", [ |
147 | MochiKit.Base.method(this.newUserCreationComponent(), 'deferredShowModal', {openFromElement:aComponent, duration:0.5}), | 141 | MochiKit.Base.method(this.newUserCreationComponent(), 'deferredShowModal', {openFromElement:aComponent, duration:0.5}), |
148 | MochiKit.Base.method(this.newUserWizardController(), 'run') | 142 | MochiKit.Base.method(this.newUserWizardController(), 'run') |
149 | ], {trace:false}), | 143 | ], {trace:false}), |
150 | // MochiKit.Base.method(this.newUserCreationComponent(), 'enableCredentialsField') | 144 | // MochiKit.Base.method(this.newUserCreationComponent(), 'enableCredentialsField') |
151 | ], {trace:false}); | 145 | ], {trace:false}); |
152 | }, | 146 | }, |
153 | 147 | ||
154 | //----------------------------------------------------------------------------- | 148 | //----------------------------------------------------------------------------- |
155 | 149 | ||
156 | 'newUserWizardController': function () { | 150 | 'newUserWizardController': function () { |
157 | if (this._newUserWizardController == null) { | 151 | if (this._newUserWizardController == null) { |
158 | this._newUserWizardController = new Clipperz.PM.UI.Web.Controllers.NewUserWizardController({ | 152 | this._newUserWizardController = new Clipperz.PM.UI.Web.Controllers.NewUserWizardController({ |
159 | 'newUserCreationComponent': this.newUserCreationComponent() | 153 | 'newUserCreationComponent': this.newUserCreationComponent() |
160 | }) | 154 | }) |
161 | 155 | ||
162 | // MochiKit.Signal.connect(this._newUserWizardController, 'exit',this, 'handleHideNewUserCreationComponent'); | 156 | // MochiKit.Signal.connect(this._newUserWizardController, 'exit',this, 'handleHideNewUserCreationComponent'); |
163 | MochiKit.Signal.connect(this._newUserWizardController, 'done',this, 'handleCompleteNewUserCreationComponent'); | 157 | MochiKit.Signal.connect(this._newUserWizardController, 'done',this, 'handleCompleteNewUserCreationComponent'); |
164 | } | 158 | } |
165 | 159 | ||
166 | return this._newUserWizardController; | 160 | return this._newUserWizardController; |
167 | }, | 161 | }, |
168 | 162 | ||
169 | //------------------------------------------------------------------------- | 163 | //------------------------------------------------------------------------- |
170 | 164 | ||
171 | 'newUserCreationComponent': function () { | 165 | 'newUserCreationComponent': function () { |
172 | if (this._newUserCreationComponent == null) { | 166 | if (this._newUserCreationComponent == null) { |
173 | this._newUserCreationComponent = new Clipperz.PM.UI.Web.Components.NewUserCreationComponent(); | 167 | this._newUserCreationComponent = new Clipperz.PM.UI.Web.Components.NewUserCreationComponent(); |
174 | } | 168 | } |
175 | 169 | ||
176 | return this._newUserCreationComponent; | 170 | return this._newUserCreationComponent; |
177 | }, | 171 | }, |
178 | 172 | ||
179 | 'clearNewUserCreationComponent': function () { | 173 | 'clearNewUserCreationComponent': function () { |
180 | if (this._newUserCreationComponent != null) { | 174 | if (this._newUserCreationComponent != null) { |
181 | this._newUserCreationComponent.clear(); | 175 | this._newUserCreationComponent.clear(); |
182 | } | 176 | } |
183 | this._newUserCreationComponent = null; | 177 | this._newUserCreationComponent = null; |
184 | }, | 178 | }, |
185 | 179 | ||
186 | //------------------------------------------------------------------------- | 180 | //------------------------------------------------------------------------- |
187 | 181 | ||
188 | 'handleHideNewUserCreationComponent': function () { | 182 | 'handleHideNewUserCreationComponent': function () { |
189 | this.clearNewUserCreationComponent(); | 183 | this.clearNewUserCreationComponent(); |
190 | }, | 184 | }, |
191 | 185 | ||
192 | 'handleCompleteNewUserCreationComponent': function (someParameters) { | 186 | 'handleCompleteNewUserCreationComponent': function (someParameters) { |
193 | vardeferredResult; | 187 | vardeferredResult; |
194 | varuser; | 188 | varuser; |
195 | varnewUserCreationComponent; | 189 | varnewUserCreationComponent; |
196 | 190 | ||
197 | user = someParameters.user; | 191 | user = someParameters.user; |
198 | newUserCreationComponent = this.newUserCreationComponent(); | 192 | newUserCreationComponent = this.newUserCreationComponent(); |
199 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN',MochiKit.Base.method(newUserCreationComponent, 'deferredHideModal', {closeToElement:MochiKit.DOM.currentDocument().body})), | 193 | MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN',MochiKit.Base.method(newUserCreationComponent, 'deferredHideModal', {closeToElement:MochiKit.DOM.currentDocument().body})), |
200 | 194 | ||
201 | deferredResult = new Clipperz.Async.Deferred("LoginController.handleCompleteNewUserCreationComponent", {trace:false}); | 195 | deferredResult = new Clipperz.Async.Deferred("LoginController.handleCompleteNewUserCreationComponent", {trace:false}); |
202 | 196 | ||