Diffstat (limited to 'frontend/beta/js/Clipperz/YUI/IBLayoutRegion.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/YUI/IBLayoutRegion.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/YUI/IBLayoutRegion.js b/frontend/beta/js/Clipperz/YUI/IBLayoutRegion.js index f8e0cb1..11b7a6c 100644 --- a/frontend/beta/js/Clipperz/YUI/IBLayoutRegion.js +++ b/frontend/beta/js/Clipperz/YUI/IBLayoutRegion.js | |||
@@ -1,214 +1,212 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.YUI) == 'undefined') { Clipperz.YUI = {}; } | 25 | if (typeof(Clipperz.YUI) == 'undefined') { Clipperz.YUI = {}; } |
28 | 26 | ||
29 | 27 | ||
30 | Clipperz.YUI.IBLayoutRegion = function(aManager, aName, aConfig) { | 28 | Clipperz.YUI.IBLayoutRegion = function(aManager, aName, aConfig) { |
31 | this._configuration = aConfig; | 29 | this._configuration = aConfig; |
32 | 30 | ||
33 | //Clipperz.YUI.IBLayoutRegion.superclass.constructor.call(); | 31 | //Clipperz.YUI.IBLayoutRegion.superclass.constructor.call(); |
34 | Clipperz.YUI.IBLayoutRegion.superclass.constructor.call(this, aManager, aConfig, aName); | 32 | Clipperz.YUI.IBLayoutRegion.superclass.constructor.call(this, aManager, aConfig, aName); |
35 | }; | 33 | }; |
36 | 34 | ||
37 | YAHOO.extendX(Clipperz.YUI.IBLayoutRegion, YAHOO.ext.LayoutRegion, { | 35 | YAHOO.extendX(Clipperz.YUI.IBLayoutRegion, YAHOO.ext.LayoutRegion, { |
38 | 36 | ||
39 | 'toString': function() { | 37 | 'toString': function() { |
40 | return "IBLayoutRegion (" + this.name() + ")"; | 38 | return "IBLayoutRegion (" + this.name() + ")"; |
41 | }, | 39 | }, |
42 | 40 | ||
43 | //----------------------------------------------------- | 41 | //----------------------------------------------------- |
44 | 42 | ||
45 | 'name': function() { | 43 | 'name': function() { |
46 | return this.position; | 44 | return this.position; |
47 | }, | 45 | }, |
48 | 46 | ||
49 | //----------------------------------------------------- | 47 | //----------------------------------------------------- |
50 | 48 | ||
51 | 'manager': function() { | 49 | 'manager': function() { |
52 | return this.mgr; | 50 | return this.mgr; |
53 | }, | 51 | }, |
54 | 52 | ||
55 | 'configuration': function() { | 53 | 'configuration': function() { |
56 | return this._configuration; | 54 | return this._configuration; |
57 | }, | 55 | }, |
58 | 56 | ||
59 | //----------------------------------------------------- | 57 | //----------------------------------------------------- |
60 | 58 | ||
61 | 'getAttributeValue': function(anAttribute) { | 59 | 'getAttributeValue': function(anAttribute) { |
62 | var result; | 60 | var result; |
63 | 61 | ||
64 | switch(anAttribute) { | 62 | switch(anAttribute) { |
65 | case "top": | 63 | case "top": |
66 | result = this.element().getTop(); | 64 | result = this.element().getTop(); |
67 | break; | 65 | break; |
68 | case "left": | 66 | case "left": |
69 | result = this.element().getLeft(); | 67 | result = this.element().getLeft(); |
70 | break; | 68 | break; |
71 | case "bottom": | 69 | case "bottom": |
72 | result = this.element().getBottom(); | 70 | result = this.element().getBottom(); |
73 | break; | 71 | break; |
74 | case "right": | 72 | case "right": |
75 | result = this.element().getRight(); | 73 | result = this.element().getRight(); |
76 | break; | 74 | break; |
77 | case "height": | 75 | case "height": |
78 | result = this.element().getHeight(); | 76 | result = this.element().getHeight(); |
79 | break; | 77 | break; |
80 | case "width": | 78 | case "width": |
81 | result = this.element().getWidth(); | 79 | result = this.element().getWidth(); |
82 | break; | 80 | break; |
83 | } | 81 | } |
84 | //MochiKit.Logging.logDebug("--- " + this.name() + " [" + anAttribute + "] = " + result); | 82 | //MochiKit.Logging.logDebug("--- " + this.name() + " [" + anAttribute + "] = " + result); |
85 | 83 | ||
86 | return result; | 84 | return result; |
87 | }, | 85 | }, |
88 | 86 | ||
89 | //----------------------------------------------------- | 87 | //----------------------------------------------------- |
90 | 88 | ||
91 | 'normalizeConfigureValue': function(aConfigurationValue) { | 89 | 'normalizeConfigureValue': function(aConfigurationValue) { |
92 | var result; | 90 | var result; |
93 | 91 | ||
94 | //MochiKit.Logging.logDebug("--- normalizeConfigureValue - " + aConfigurationValue); | 92 | //MochiKit.Logging.logDebug("--- normalizeConfigureValue - " + aConfigurationValue); |
95 | if (typeof(aConfigurationValue) == 'number') { | 93 | if (typeof(aConfigurationValue) == 'number') { |
96 | result = aConfigurationValue; | 94 | result = aConfigurationValue; |
97 | } else if (aConfigurationValue == 'auto') { | 95 | } else if (aConfigurationValue == 'auto') { |
98 | result = aConfigurationValue; | 96 | result = aConfigurationValue; |
99 | } else { | 97 | } else { |
100 | var splitValues; | 98 | var splitValues; |
101 | var referenceValue; | 99 | var referenceValue; |
102 | var deltaValue; | 100 | var deltaValue; |
103 | var targetRegion; | 101 | var targetRegion; |
104 | var targetAttribute; | 102 | var targetAttribute; |
105 | 103 | ||
106 | splitValues = aConfigurationValue.split('+'); | 104 | splitValues = aConfigurationValue.split('+'); |
107 | referenceValue = Clipperz.Base.trim(splitValues[0]); | 105 | referenceValue = Clipperz.Base.trim(splitValues[0]); |
108 | deltaValue = Clipperz.Base.trim(splitValues[1] || ""); | 106 | deltaValue = Clipperz.Base.trim(splitValues[1] || ""); |
109 | 107 | ||
110 | splitValues = referenceValue.split('.'); | 108 | splitValues = referenceValue.split('.'); |
111 | targetRegion = splitValues[0]; | 109 | targetRegion = splitValues[0]; |
112 | targetAttribute = splitValues[1]; | 110 | targetAttribute = splitValues[1]; |
113 | 111 | ||
114 | //MochiKit.Logging.logDebug("> " + aConfigurationValue); | 112 | //MochiKit.Logging.logDebug("> " + aConfigurationValue); |
115 | //MochiKit.Logging.logDebug(">> manager: " + this.manager()); | 113 | //MochiKit.Logging.logDebug(">> manager: " + this.manager()); |
116 | //MochiKit.Logging.logDebug(">> targetRegion: " + targetRegion); | 114 | //MochiKit.Logging.logDebug(">> targetRegion: " + targetRegion); |
117 | //MochiKit.Logging.logDebug(">>> " + this.manager().getRegion(targetRegion)); | 115 | //MochiKit.Logging.logDebug(">>> " + this.manager().getRegion(targetRegion)); |
118 | targetValue = this.manager().getRegion(targetRegion).getAttributeValue(targetAttribute); | 116 | targetValue = this.manager().getRegion(targetRegion).getAttributeValue(targetAttribute); |
119 | //MochiKit.Logging.logDebug(">>>> " + targetRegion + "." + targetAttribute + " + " + deltaValue + " = " + targetValue); | 117 | //MochiKit.Logging.logDebug(">>>> " + targetRegion + "." + targetAttribute + " + " + deltaValue + " = " + targetValue); |
120 | 118 | ||
121 | result = targetValue + (deltaValue - 0); | 119 | result = targetValue + (deltaValue - 0); |
122 | 120 | ||
123 | //MochiKit.Logging.logDebug("<<< " + aConfigurationValue + " = " + result); | 121 | //MochiKit.Logging.logDebug("<<< " + aConfigurationValue + " = " + result); |
124 | } | 122 | } |
125 | 123 | ||
126 | return result; | 124 | return result; |
127 | }, | 125 | }, |
128 | 126 | ||
129 | 'normalizedConfiguration': function(aConfiguration) { | 127 | 'normalizedConfiguration': function(aConfiguration) { |
130 | varresult; | 128 | varresult; |
131 | varkey; | 129 | varkey; |
132 | 130 | ||
133 | result = {}; | 131 | result = {}; |
134 | 132 | ||
135 | //MochiKit.Logging.logDebug("--- normalizedConfiguration - keys: " + Clipperz.Base.serializeJSON(MochiKit.Base.keys(aConfiguration))); | 133 | //MochiKit.Logging.logDebug("--- normalizedConfiguration - keys: " + Clipperz.Base.serializeJSON(MochiKit.Base.keys(aConfiguration))); |
136 | for (key in aConfiguration) { | 134 | for (key in aConfiguration) { |
137 | if ((key == 'top') || (key == 'bottom') || (key == 'left') || (key == 'rigth') || (key == 'width') || (key == 'height')) { | 135 | if ((key == 'top') || (key == 'bottom') || (key == 'left') || (key == 'rigth') || (key == 'width') || (key == 'height')) { |
138 | result[key] = this.normalizeConfigureValue(aConfiguration[key]); | 136 | result[key] = this.normalizeConfigureValue(aConfiguration[key]); |
139 | } else { | 137 | } else { |
140 | result[key] = aConfiguration[key]; | 138 | result[key] = aConfiguration[key]; |
141 | } | 139 | } |
142 | } | 140 | } |
143 | 141 | ||
144 | return result; | 142 | return result; |
145 | }, | 143 | }, |
146 | 144 | ||
147 | //----------------------------------------------------- | 145 | //----------------------------------------------------- |
148 | 146 | ||
149 | 'element': function() { | 147 | 'element': function() { |
150 | return this.el; | 148 | return this.el; |
151 | }, | 149 | }, |
152 | 150 | ||
153 | //----------------------------------------------------- | 151 | //----------------------------------------------------- |
154 | /* | 152 | /* |
155 | 'hide': function() { | 153 | 'hide': function() { |
156 | MochiKit.Logging.logDebug(">>> IBLayoutManager.hide()") | 154 | MochiKit.Logging.logDebug(">>> IBLayoutManager.hide()") |
157 | Clipperz.YUI.IBLayoutRegion.superclass.hide.call(this); | 155 | Clipperz.YUI.IBLayoutRegion.superclass.hide.call(this); |
158 | }, | 156 | }, |
159 | */ | 157 | */ |
160 | //----------------------------------------------------- | 158 | //----------------------------------------------------- |
161 | /* | 159 | /* |
162 | 'add': function(aPanel) { | 160 | 'add': function(aPanel) { |
163 | Clipperz.YUI.IBLayoutRegion.superclass.add.call(this, aPanel); | 161 | Clipperz.YUI.IBLayoutRegion.superclass.add.call(this, aPanel); |
164 | aPanel.el.fitToParent(true); | 162 | aPanel.el.fitToParent(true); |
165 | }, | 163 | }, |
166 | */ | 164 | */ |
167 | //----------------------------------------------------- | 165 | //----------------------------------------------------- |
168 | 166 | ||
169 | 'updateBox': function(aBox) { | 167 | 'updateBox': function(aBox) { |
170 | //MochiKit.Logging.logDebug(">>> IBLayoutRegion.updateBox - " + aBox); | 168 | //MochiKit.Logging.logDebug(">>> IBLayoutRegion.updateBox - " + aBox); |
171 | Clipperz.YUI.IBLayoutRegion.superclass.updateBox.call(this, aBox); | 169 | Clipperz.YUI.IBLayoutRegion.superclass.updateBox.call(this, aBox); |
172 | }, | 170 | }, |
173 | 171 | ||
174 | //----------------------------------------------------- | 172 | //----------------------------------------------------- |
175 | 173 | ||
176 | 'layout': function() { | 174 | 'layout': function() { |
177 | vartop, left, bottom, right, width, height; | 175 | vartop, left, bottom, right, width, height; |
178 | varelement; | 176 | varelement; |
179 | var config; | 177 | var config; |
180 | var windowSize; | 178 | var windowSize; |
181 | var containerSize; | 179 | var containerSize; |
182 | 180 | ||
183 | //MochiKit.Logging.logDebug(">>> IBLayoutRegion.layout - " + this); | 181 | //MochiKit.Logging.logDebug(">>> IBLayoutRegion.layout - " + this); |
184 | config = this.normalizedConfiguration(this.configuration()); | 182 | config = this.normalizedConfiguration(this.configuration()); |
185 | element = this.element(); | 183 | element = this.element(); |
186 | // containerSize = this.manager().getSize(true); | 184 | // containerSize = this.manager().getSize(true); |
187 | containerSize = this.manager().getSize(false); | 185 | containerSize = this.manager().getSize(false); |
188 | windowSize = {width: YAHOO.util.Dom.getViewportWidth(), height: YAHOO.util.Dom.getViewportHeight()}; | 186 | windowSize = {width: YAHOO.util.Dom.getViewportWidth(), height: YAHOO.util.Dom.getViewportHeight()}; |
189 | 187 | ||
190 | // element.setStyle("position", "absolute"); | 188 | // element.setStyle("position", "absolute"); |
191 | // element.setStyle("overflow", "none"); | 189 | // element.setStyle("overflow", "none"); |
192 | 190 | ||
193 | if (typeof(config.top) == 'number') { | 191 | if (typeof(config.top) == 'number') { |
194 | top = config.top; | 192 | top = config.top; |
195 | 193 | ||
196 | if (typeof(config.bottom) == 'number') { | 194 | if (typeof(config.bottom) == 'number') { |
197 | height = containerSize.height - top - config.bottom; | 195 | height = containerSize.height - top - config.bottom; |
198 | } else if (typeof(config.height) == 'number') { | 196 | } else if (typeof(config.height) == 'number') { |
199 | height = config.height; | 197 | height = config.height; |
200 | } else { | 198 | } else { |
201 | //??? | 199 | //??? |
202 | } | 200 | } |
203 | } else { | 201 | } else { |
204 | if ((typeof(config.bottom) == 'number') && (typeof(config.height) == 'number')) { | 202 | if ((typeof(config.bottom) == 'number') && (typeof(config.height) == 'number')) { |
205 | top = containerSize.height - (config.height + config.bottom); | 203 | top = containerSize.height - (config.height + config.bottom); |
206 | height = config.height; | 204 | height = config.height; |
207 | } else if ((config.bottom == 'auto') && (typeof(config.height) == 'number')) { | 205 | } else if ((config.bottom == 'auto') && (typeof(config.height) == 'number')) { |
208 | top = ((containerSize.height - config.height) / 2); | 206 | top = ((containerSize.height - config.height) / 2); |
209 | height = config.height; | 207 | height = config.height; |
210 | } | 208 | } |
211 | } | 209 | } |
212 | 210 | ||
213 | if (typeof(config.left) == 'number') { | 211 | if (typeof(config.left) == 'number') { |
214 | left = config.left; | 212 | left = config.left; |