summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PasswordTooltip.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Web/Components/PasswordTooltip.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/UI/Web/Components/PasswordTooltip.js164
1 files changed, 164 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PasswordTooltip.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PasswordTooltip.js
new file mode 100644
index 0000000..79c8d4f
--- a/dev/null
+++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PasswordTooltip.js
@@ -0,0 +1,164 @@
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
29Clipperz.Base.module('Clipperz.PM.UI.Common.Components');
30
31Clipperz.PM.UI.Web.Components.PasswordTooltip = function(args) {
32 args = args || {};
33
34 Clipperz.PM.UI.Web.Components.PasswordTooltip.superclass.constructor.apply(this, arguments);
35
36 this._referenceElement = args.referenceElement|| Clipperz.Base.exception.raise('MandatoryParameter');
37 this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter');
38
39 this._boxDimensions = null;
40 this._isVisible = false;
41
42 this.renderSelf();
43
44 return this;
45}
46
47//=============================================================================
48
49Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.PasswordTooltip, Clipperz.PM.UI.Common.Components.BaseComponent, {
50
51 //-------------------------------------------------------------------------
52
53 'toString': function () {
54 return "Clipperz.PM.UI.Web.Components.PasswordTooltip component";
55 },
56
57 //-------------------------------------------------------------------------
58
59 'referenceElement': function () {
60 return this._referenceElement;
61 },
62
63 //-------------------------------------------------------------------------
64
65 'text': function () {
66 return this._text;
67 },
68
69 'setText': function (aValue) {
70 this._text = aValue;
71 },
72
73 //-------------------------------------------------------------------------
74
75 'isVisible': function () {
76 return this._isVisible;
77 },
78
79 'setIsVisible': function (aValue) {
80 this._isVisible = aValue;
81 },
82
83 //-------------------------------------------------------------------------
84
85 'renderSelf': function() {
86 this.append(MochiKit.DOM.getElement('Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'), {tag:'div', id:this.getId('tooltip'), cls:'passwordTooltip', children:[
87 {tag:'div', id:this.getId('body'), cls:'passwordTooltip_body', children:[
88 {tag:'div', cls:'passwordTooltip_text', children:[
89 {tag:'span', html:this.text()}
90 ]},
91 {tag:'div', id:this.getId('footer'), cls:'passwordTooltip_footer'}
92 ]},
93 {tag:'div', id:this.getId('arrow'), cls:'passwordTooltip_arrow'}
94 ]});
95
96 this._boxDimensions = MochiKit.Style.getElementDimensions(this.getId('body'));
97 // this._boxDimensions.h += MochiKit.Style.getElementDimensions(this.getId('footer')).h;
98
99 MochiKit.Style.hideElement(this.displayElement());
100 MochiKit.Signal.connect(this.element(), 'onmouseenter', this, 'show');
101 MochiKit.Signal.connect(this.element(), 'onmouseleave', this, 'hide');
102 },
103
104 //-----------------------------------------------------
105
106 'displayElement': function() {
107 return this.getElement('tooltip');
108 },
109
110 //-------------------------------------------------------------------------
111
112 'boxDimensions': function () {
113 return this._boxDimensions;
114 },
115
116 //-------------------------------------------------------------------------
117
118 'show': function () {
119 var elementSizeAndPosition;
120 var arrowPosition;
121 var bodyPosition;
122
123 if (this.isVisible() == false) {
124 arrowPosition = {};
125 bodyPosition = {};
126
127 this.setIsVisible(true);
128 elementSizeAndPosition = Clipperz.Style.getSizeAndPosition(this.element());
129
130 MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px');
131 bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2);
132 bodyPosition.y = elementSizeAndPosition.position.y - this.boxDimensions().h - 13;
133
134 arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2);
135 arrowPosition.y = elementSizeAndPosition.position.y - 13;
136
137 MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition);
138 MochiKit.Style.setElementPosition(this.getId('arrow'), arrowPosition);
139 MochiKit.Visual.appear(this.displayElement(), {duration:0.4});
140 }
141 },
142
143 'hide': function () {
144 if (this.isVisible() == true) {
145 MochiKit.Visual.fade(this.displayElement(), {duration:0.4});
146 this.setIsVisible(false);
147 }
148 },
149
150 //-------------------------------------------------------------------------
151/*
152 'shouldRemoveElementWhenClearningUp': function () {
153 return false;
154 },
155*/
156 //-------------------------------------------------------------------------
157 __syntaxFix__: "syntax fix"
158});
159
160Clipperz.PM.UI.Web.Components.PasswordTooltip.initTooltips = function () {
161 Clipperz.DOM.Helper.insertBefore(MochiKit.DOM.currentDocument().body.childNodes[0], {tag:'div', id:'Clipperz_PM_UI_Web_Components_PasswordTooltip_wrapperNode'});
162}
163
164MochiKit.DOM.addLoadEvent(Clipperz.PM.UI.Web.Components.PasswordTooltip.initTooltips);