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/YUI/IBLayoutRegion.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/YUI/IBLayoutRegion.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/YUI/IBLayoutRegion.js | 249 |
1 files changed, 249 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/YUI/IBLayoutRegion.js b/frontend/beta/js/Clipperz/YUI/IBLayoutRegion.js new file mode 100644 index 0000000..2fd4377 --- a/dev/null +++ b/frontend/beta/js/Clipperz/YUI/IBLayoutRegion.js | |||
@@ -0,0 +1,249 @@ | |||
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.YUI) == 'undefined') { Clipperz.YUI = {}; } | ||
31 | |||
32 | |||
33 | Clipperz.YUI.IBLayoutRegion = function(aManager, aName, aConfig) { | ||
34 | this._configuration = aConfig; | ||
35 | |||
36 | //Clipperz.YUI.IBLayoutRegion.superclass.constructor.call(); | ||
37 | Clipperz.YUI.IBLayoutRegion.superclass.constructor.call(this, aManager, aConfig, aName); | ||
38 | }; | ||
39 | |||
40 | YAHOO.extendX(Clipperz.YUI.IBLayoutRegion, YAHOO.ext.LayoutRegion, { | ||
41 | |||
42 | 'toString': function() { | ||
43 | return "IBLayoutRegion (" + this.name() + ")"; | ||
44 | }, | ||
45 | |||
46 | //----------------------------------------------------- | ||
47 | |||
48 | 'name': function() { | ||
49 | return this.position; | ||
50 | }, | ||
51 | |||
52 | //----------------------------------------------------- | ||
53 | |||
54 | 'manager': function() { | ||
55 | return this.mgr; | ||
56 | }, | ||
57 | |||
58 | 'configuration': function() { | ||
59 | return this._configuration; | ||
60 | }, | ||
61 | |||
62 | //----------------------------------------------------- | ||
63 | |||
64 | 'getAttributeValue': function(anAttribute) { | ||
65 | var result; | ||
66 | |||
67 | switch(anAttribute) { | ||
68 | case "top": | ||
69 | result = this.element().getTop(); | ||
70 | break; | ||
71 | case "left": | ||
72 | result = this.element().getLeft(); | ||
73 | break; | ||
74 | case "bottom": | ||
75 | result = this.element().getBottom(); | ||
76 | break; | ||
77 | case "right": | ||
78 | result = this.element().getRight(); | ||
79 | break; | ||
80 | case "height": | ||
81 | result = this.element().getHeight(); | ||
82 | break; | ||
83 | case "width": | ||
84 | result = this.element().getWidth(); | ||
85 | break; | ||
86 | } | ||
87 | //MochiKit.Logging.logDebug("--- " + this.name() + " [" + anAttribute + "] = " + result); | ||
88 | |||
89 | return result; | ||
90 | }, | ||
91 | |||
92 | //----------------------------------------------------- | ||
93 | |||
94 | 'normalizeConfigureValue': function(aConfigurationValue) { | ||
95 | var result; | ||
96 | |||
97 | //MochiKit.Logging.logDebug("--- normalizeConfigureValue - " + aConfigurationValue); | ||
98 | if (typeof(aConfigurationValue) == 'number') { | ||
99 | result = aConfigurationValue; | ||
100 | } else if (aConfigurationValue == 'auto') { | ||
101 | result = aConfigurationValue; | ||
102 | } else { | ||
103 | var splitValues; | ||
104 | var referenceValue; | ||
105 | var deltaValue; | ||
106 | var targetRegion; | ||
107 | var targetAttribute; | ||
108 | |||
109 | splitValues = aConfigurationValue.split('+'); | ||
110 | referenceValue = Clipperz.Base.trim(splitValues[0]); | ||
111 | deltaValue = Clipperz.Base.trim(splitValues[1] || ""); | ||
112 | |||
113 | splitValues = referenceValue.split('.'); | ||
114 | targetRegion = splitValues[0]; | ||
115 | targetAttribute = splitValues[1]; | ||
116 | |||
117 | //MochiKit.Logging.logDebug("> " + aConfigurationValue); | ||
118 | //MochiKit.Logging.logDebug(">> manager: " + this.manager()); | ||
119 | //MochiKit.Logging.logDebug(">> targetRegion: " + targetRegion); | ||
120 | //MochiKit.Logging.logDebug(">>> " + this.manager().getRegion(targetRegion)); | ||
121 | targetValue = this.manager().getRegion(targetRegion).getAttributeValue(targetAttribute); | ||
122 | //MochiKit.Logging.logDebug(">>>> " + targetRegion + "." + targetAttribute + " + " + deltaValue + " = " + targetValue); | ||
123 | |||
124 | result = targetValue + (deltaValue - 0); | ||
125 | |||
126 | //MochiKit.Logging.logDebug("<<< " + aConfigurationValue + " = " + result); | ||
127 | } | ||
128 | |||
129 | return result; | ||
130 | }, | ||
131 | |||
132 | 'normalizedConfiguration': function(aConfiguration) { | ||
133 | varresult; | ||
134 | varkey; | ||
135 | |||
136 | result = {}; | ||
137 | |||
138 | //MochiKit.Logging.logDebug("--- normalizedConfiguration - keys: " + Clipperz.Base.serializeJSON(MochiKit.Base.keys(aConfiguration))); | ||
139 | for (key in aConfiguration) { | ||
140 | if ((key == 'top') || (key == 'bottom') || (key == 'left') || (key == 'rigth') || (key == 'width') || (key == 'height')) { | ||
141 | result[key] = this.normalizeConfigureValue(aConfiguration[key]); | ||
142 | } else { | ||
143 | result[key] = aConfiguration[key]; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | return result; | ||
148 | }, | ||
149 | |||
150 | //----------------------------------------------------- | ||
151 | |||
152 | 'element': function() { | ||
153 | return this.el; | ||
154 | }, | ||
155 | |||
156 | //----------------------------------------------------- | ||
157 | /* | ||
158 | 'hide': function() { | ||
159 | MochiKit.Logging.logDebug(">>> IBLayoutManager.hide()") | ||
160 | Clipperz.YUI.IBLayoutRegion.superclass.hide.call(this); | ||
161 | }, | ||
162 | */ | ||
163 | //----------------------------------------------------- | ||
164 | /* | ||
165 | 'add': function(aPanel) { | ||
166 | Clipperz.YUI.IBLayoutRegion.superclass.add.call(this, aPanel); | ||
167 | aPanel.el.fitToParent(true); | ||
168 | }, | ||
169 | */ | ||
170 | //----------------------------------------------------- | ||
171 | |||
172 | 'updateBox': function(aBox) { | ||
173 | //MochiKit.Logging.logDebug(">>> IBLayoutRegion.updateBox - " + aBox); | ||
174 | Clipperz.YUI.IBLayoutRegion.superclass.updateBox.call(this, aBox); | ||
175 | }, | ||
176 | |||
177 | //----------------------------------------------------- | ||
178 | |||
179 | 'layout': function() { | ||
180 | vartop, left, bottom, right, width, height; | ||
181 | varelement; | ||
182 | var config; | ||
183 | var windowSize; | ||
184 | var containerSize; | ||
185 | |||
186 | //MochiKit.Logging.logDebug(">>> IBLayoutRegion.layout - " + this); | ||
187 | config = this.normalizedConfiguration(this.configuration()); | ||
188 | element = this.element(); | ||
189 | // containerSize = this.manager().getSize(true); | ||
190 | containerSize = this.manager().getSize(false); | ||
191 | windowSize = {width: YAHOO.util.Dom.getViewportWidth(), height: YAHOO.util.Dom.getViewportHeight()}; | ||
192 | |||
193 | // element.setStyle("position", "absolute"); | ||
194 | // element.setStyle("overflow", "none"); | ||
195 | |||
196 | if (typeof(config.top) == 'number') { | ||
197 | top = config.top; | ||
198 | |||
199 | if (typeof(config.bottom) == 'number') { | ||
200 | height = containerSize.height - top - config.bottom; | ||
201 | } else if (typeof(config.height) == 'number') { | ||
202 | height = config.height; | ||
203 | } else { | ||
204 | //??? | ||
205 | } | ||
206 | } else { | ||
207 | if ((typeof(config.bottom) == 'number') && (typeof(config.height) == 'number')) { | ||
208 | top = containerSize.height - (config.height + config.bottom); | ||
209 | height = config.height; | ||
210 | } else if ((config.bottom == 'auto') && (typeof(config.height) == 'number')) { | ||
211 | top = ((containerSize.height - config.height) / 2); | ||
212 | height = config.height; | ||
213 | } | ||
214 | } | ||
215 | |||
216 | if (typeof(config.left) == 'number') { | ||
217 | left = config.left; | ||
218 | |||
219 | if (typeof(config.right) == 'number') { | ||
220 | width = (containerSize.width - left - config.right); | ||
221 | } else if (typeof(config.width) == 'number') { | ||
222 | width = config.width; | ||
223 | } else { | ||
224 | //??? | ||
225 | } | ||
226 | } else { | ||
227 | if ((typeof(config.right) == 'number') && (typeof(config.width) == 'number')) { | ||
228 | left = containerSize.width - (config.width + config.right); | ||
229 | width = config.width; | ||
230 | } else if ((config.right == 'auto') && (typeof(config.width) == 'number')) { | ||
231 | left = ((containerSize.width - config.width) / 2); | ||
232 | width = config.width; | ||
233 | } | ||
234 | } | ||
235 | //MochiKit.Logging.logDebug("--- setting position (top: " + top + ", left: " + left + ", width: " + width + ", height: " + height + ")"); | ||
236 | element.setTop(top); | ||
237 | element.setLeft(left); | ||
238 | element.setWidth(width); | ||
239 | element.setHeight(height); | ||
240 | |||
241 | if (this.activePanel != null) { | ||
242 | this.activePanel.setSize(width, height); | ||
243 | } | ||
244 | //MochiKit.Logging.logDebug("<<< IBLayoutRegion.layout"); | ||
245 | }, | ||
246 | |||
247 | //----------------------------------------------------- | ||
248 | __syntaxFix__: '__syntaxFix__' | ||
249 | }); | ||