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 | |
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') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/YUI/Collapser.js | 73 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/YUI/DomHelper.js | 465 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/YUI/DomQuery.js | 710 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/YUI/Drawer.js | 238 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/YUI/IBLayoutManager.js | 114 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/YUI/IBLayoutRegion.js | 249 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/YUI/MessageBox.js | 265 |
7 files changed, 2114 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/YUI/Collapser.js b/frontend/beta/js/Clipperz/YUI/Collapser.js new file mode 100644 index 0000000..5c0ac0f --- a/dev/null +++ b/frontend/beta/js/Clipperz/YUI/Collapser.js | |||
@@ -0,0 +1,73 @@ | |||
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 | //found on YUI-EXT forum (http://www.yui-ext.com/forum/viewtopic.php?t=683&highlight=accordion) | ||
33 | Clipperz.YUI.Collapser = function(clickEl, collapseEl, initiallyCollapsed) { | ||
34 | this.clickEl = getEl(clickEl); | ||
35 | this.collapseEl = getEl(collapseEl); | ||
36 | this.clickEl.addClass('collapser-expanded'); | ||
37 | if (initiallyCollapsed == true) { | ||
38 | this.afterCollapse(); | ||
39 | } | ||
40 | this.clickEl.mon('click', function(){ | ||
41 | this.collapsed === true ? this.expand() : this.collapse(); | ||
42 | }, this, true); | ||
43 | }; | ||
44 | |||
45 | Clipperz.YUI.Collapser.prototype = { | ||
46 | 'collapse': function(){ | ||
47 | this.collapseEl.clip(); | ||
48 | this.collapseEl.setHeight(1, true, .35, this.afterCollapse.createDelegate(this), YAHOO.util.Easing.easeOut); | ||
49 | this.clickEl.replaceClass('collapser-expanded','collapser-collapsed'); | ||
50 | }, | ||
51 | |||
52 | 'afterCollapse': function(){ | ||
53 | this.collapsed = true; | ||
54 | this.collapseEl.setDisplayed(false); | ||
55 | this.clickEl.replaceClass('collapser-expanded','collapser-collapsed'); | ||
56 | }, | ||
57 | |||
58 | 'expand': function(){ | ||
59 | this.collapseEl.setDisplayed(true); | ||
60 | this.collapseEl.autoHeight(true, .35, this.afterExpand.createDelegate(this), YAHOO.util.Easing.easeOut); | ||
61 | this.clickEl.replaceClass('collapser-collapsed','collapser-expanded'); | ||
62 | }, | ||
63 | |||
64 | 'afterExpand': function(){ | ||
65 | this.collapsed = false; | ||
66 | this.collapseEl.unclip(); | ||
67 | this.collapseEl.setStyle('height', ''); | ||
68 | this.clickEl.replaceClass('collapser-collapsed','collapser-expanded'); | ||
69 | }, | ||
70 | |||
71 | //----------------------------------------------------- | ||
72 | __syntaxFix__: '__syntaxFix__' | ||
73 | }; | ||
diff --git a/frontend/beta/js/Clipperz/YUI/DomHelper.js b/frontend/beta/js/Clipperz/YUI/DomHelper.js new file mode 100644 index 0000000..4f8acde --- a/dev/null +++ b/frontend/beta/js/Clipperz/YUI/DomHelper.js | |||
@@ -0,0 +1,465 @@ | |||
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.ext) == 'undefined') { Clipperz.ext = {}; } | ||
31 | |||
32 | /** | ||
33 | * @class Clipperz.YUI.DomHelper | ||
34 | * Utility class for working with DOM and/or Templates. It transparently supports using HTML fragments or DOM. | ||
35 | * For more information see <a href="http://www.jackslocum.com/yui/2006/10/06/domhelper-create-elements-using-dom-html-fragments-or-templates/">this blog post with examples</a>. | ||
36 | * @singleton | ||
37 | */ | ||
38 | Clipperz.YUI.DomHelper = new function(){ | ||
39 | /**@private*/ | ||
40 | var d = document; | ||
41 | var tempTableEl = null; | ||
42 | /** True to force the use of DOM instead of html fragments @type Boolean */ | ||
43 | this.useDom = false; | ||
44 | var emptyTags = /^(?:base|basefont|br|frame|hr|img|input|isindex|link|meta|nextid|range|spacer|wbr|audioscope|area|param|keygen|col|limittext|spot|tab|over|right|left|choose|atop|of)$/i; | ||
45 | /** | ||
46 | * Applies a style specification to an element | ||
47 | * @param {String/HTMLElement} el The element to apply styles to | ||
48 | * @param {String/Object/Function} styles A style specification string eg "width:100px", or object in the form {width:"100px"}, or | ||
49 | * a function which returns such a specification. | ||
50 | */ | ||
51 | this.applyStyles = function(el, styles){ | ||
52 | if(styles){ | ||
53 | var D = YAHOO.util.Dom; | ||
54 | if (typeof styles == "string"){ | ||
55 | var re = /\s?([a-z\-]*)\:([^;]*);?/gi; | ||
56 | var matches; | ||
57 | while ((matches = re.exec(styles)) != null){ | ||
58 | D.setStyle(el, matches[1], matches[2]); | ||
59 | } | ||
60 | }else if (typeof styles == "object"){ | ||
61 | for (var style in styles){ | ||
62 | D.setStyle(el, style, styles[style]); | ||
63 | } | ||
64 | }else if (typeof styles == "function"){ | ||
65 | Clipperz.YUI.DomHelper.applyStyles(el, styles.call()); | ||
66 | } | ||
67 | } | ||
68 | }; | ||
69 | |||
70 | // build as innerHTML where available | ||
71 | /** @ignore */ | ||
72 | var createHtml = function(o){ | ||
73 | var b = ''; | ||
74 | |||
75 | if(typeof(o['html']) != 'undefined') { | ||
76 | o['html'] = Clipperz.Base.sanitizeString(o['html']); | ||
77 | } else if (typeof(o['htmlString']) != 'undefined') { | ||
78 | o['html'] = o['htmlString']; | ||
79 | delete o.htmlString; | ||
80 | } | ||
81 | |||
82 | b += '<' + o.tag; | ||
83 | for(var attr in o){ | ||
84 | if(attr == 'tag' || attr == 'children' || attr == 'html' || typeof o[attr] == 'function') continue; | ||
85 | if(attr == 'style'){ | ||
86 | var s = o['style']; | ||
87 | if(typeof s == 'function'){ | ||
88 | s = s.call(); | ||
89 | } | ||
90 | if(typeof s == 'string'){ | ||
91 | b += ' style="' + s + '"'; | ||
92 | }else if(typeof s == 'object'){ | ||
93 | b += ' style="'; | ||
94 | for(var key in s){ | ||
95 | if(typeof s[key] != 'function'){ | ||
96 | b += key + ':' + s[key] + ';'; | ||
97 | } | ||
98 | } | ||
99 | b += '"'; | ||
100 | } | ||
101 | }else{ | ||
102 | if(attr == 'cls'){ | ||
103 | b += ' class="' + o['cls'] + '"'; | ||
104 | }else if(attr == 'htmlFor'){ | ||
105 | b += ' for="' + o['htmlFor'] + '"'; | ||
106 | }else{ | ||
107 | b += ' ' + attr + '="' + o[attr] + '"'; | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | if(emptyTags.test(o.tag)){ | ||
112 | b += ' />'; | ||
113 | }else{ | ||
114 | b += '>'; | ||
115 | if(o.children){ | ||
116 | for(var i = 0, len = o.children.length; i < len; i++) { | ||
117 | b += createHtml(o.children[i], b); | ||
118 | } | ||
119 | } | ||
120 | if(o.html){ | ||
121 | b += o.html; | ||
122 | } | ||
123 | b += '</' + o.tag + '>'; | ||
124 | } | ||
125 | return b; | ||
126 | } | ||
127 | |||
128 | // build as dom | ||
129 | /** @ignore */ | ||
130 | var createDom = function(o, parentNode){ | ||
131 | var el = d.createElement(o.tag); | ||
132 | var useSet = el.setAttribute ? true : false; // In IE some elements don't have setAttribute | ||
133 | for(var attr in o){ | ||
134 | if(attr == 'tag' || attr == 'children' || attr == 'html' || attr == 'style' || typeof o[attr] == 'function') continue; | ||
135 | if(attr=='cls'){ | ||
136 | el.className = o['cls']; | ||
137 | }else{ | ||
138 | if(useSet) el.setAttribute(attr, o[attr]); | ||
139 | else el[attr] = o[attr]; | ||
140 | } | ||
141 | } | ||
142 | Clipperz.YUI.DomHelper.applyStyles(el, o.style); | ||
143 | if(o.children){ | ||
144 | for(var i = 0, len = o.children.length; i < len; i++) { | ||
145 | createDom(o.children[i], el); | ||
146 | } | ||
147 | } | ||
148 | if(o.html){ | ||
149 | el.innerHTML = o.html; | ||
150 | } | ||
151 | if(parentNode){ | ||
152 | parentNode.appendChild(el); | ||
153 | } | ||
154 | return el; | ||
155 | }; | ||
156 | |||
157 | /** | ||
158 | * @ignore | ||
159 | * Nasty code for IE's broken table implementation | ||
160 | */ | ||
161 | var insertIntoTable = function(tag, where, el, html){ | ||
162 | if(!tempTableEl){ | ||
163 | tempTableEl = document.createElement('div'); | ||
164 | } | ||
165 | var node; | ||
166 | if(tag == 'table' || tag == 'tbody'){ | ||
167 | tempTableEl.innerHTML = '<table><tbody>'+html+'</tbody></table>'; | ||
168 | node = tempTableEl.firstChild.firstChild.firstChild; | ||
169 | }else{ | ||
170 | tempTableEl.innerHTML = '<table><tbody><tr>'+html+'</tr></tbody></table>'; | ||
171 | node = tempTableEl.firstChild.firstChild.firstChild.firstChild; | ||
172 | } | ||
173 | if(where == 'beforebegin'){ | ||
174 | el.parentNode.insertBefore(node, el); | ||
175 | return node; | ||
176 | }else if(where == 'afterbegin'){ | ||
177 | el.insertBefore(node, el.firstChild); | ||
178 | return node; | ||
179 | }else if(where == 'beforeend'){ | ||
180 | el.appendChild(node); | ||
181 | return node; | ||
182 | }else if(where == 'afterend'){ | ||
183 | el.parentNode.insertBefore(node, el.nextSibling); | ||
184 | return node; | ||
185 | } | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * Inserts an HTML fragment into the Dom | ||
190 | * @param {String} where Where to insert the html in relation to el - beforeBegin, afterBegin, beforeEnd, afterEnd. | ||
191 | * @param {HTMLElement} el The context element | ||
192 | * @param {String} html The HTML fragmenet | ||
193 | * @return {HTMLElement} The new node | ||
194 | */ | ||
195 | this.insertHtml = function(where, el, html){ | ||
196 | where = where.toLowerCase(); | ||
197 | if(el.insertAdjacentHTML){ | ||
198 | var tag = el.tagName.toLowerCase(); | ||
199 | if(tag == 'table' || tag == 'tbody' || tag == 'tr'){ | ||
200 | return insertIntoTable(tag, where, el, html); | ||
201 | } | ||
202 | switch(where){ | ||
203 | case 'beforebegin': | ||
204 | el.insertAdjacentHTML(where, html); | ||
205 | return el.previousSibling; | ||
206 | case 'afterbegin': | ||
207 | el.insertAdjacentHTML(where, html); | ||
208 | return el.firstChild; | ||
209 | case 'beforeend': | ||
210 | el.insertAdjacentHTML(where, html); | ||
211 | return el.lastChild; | ||
212 | case 'afterend': | ||
213 | el.insertAdjacentHTML(where, html); | ||
214 | return el.nextSibling; | ||
215 | } | ||
216 | throw 'Illegal insertion point -> "' + where + '"'; | ||
217 | } | ||
218 | var range = el.ownerDocument.createRange(); | ||
219 | var frag; | ||
220 | switch(where){ | ||
221 | case 'beforebegin': | ||
222 | range.setStartBefore(el); | ||
223 | frag = range.createContextualFragment(html); | ||
224 | el.parentNode.insertBefore(frag, el); | ||
225 | return el.previousSibling; | ||
226 | case 'afterbegin': | ||
227 | if(el.firstChild){ // faster | ||
228 | range.setStartBefore(el.firstChild); | ||
229 | }else{ | ||
230 | range.selectNodeContents(el); | ||
231 | range.collapse(true); | ||
232 | } | ||
233 | frag = range.createContextualFragment(html); | ||
234 | el.insertBefore(frag, el.firstChild); | ||
235 | return el.firstChild; | ||
236 | case 'beforeend': | ||
237 | if(el.lastChild){ | ||
238 | range.setStartAfter(el.lastChild); // faster | ||
239 | }else{ | ||
240 | range.selectNodeContents(el); | ||
241 | range.collapse(false); | ||
242 | } | ||
243 | frag = range.createContextualFragment(html); | ||
244 | el.appendChild(frag); | ||
245 | return el.lastChild; | ||
246 | case 'afterend': | ||
247 | range.setStartAfter(el); | ||
248 | frag = range.createContextualFragment(html); | ||
249 | el.parentNode.insertBefore(frag, el.nextSibling); | ||
250 | return el.nextSibling; | ||
251 | } | ||
252 | throw 'Illegal insertion point -> "' + where + '"'; | ||
253 | }; | ||
254 | |||
255 | /** | ||
256 | * Creates new Dom element(s) and inserts them before el | ||
257 | * @param {String/HTMLElement/Element} el The context element | ||
258 | * @param {Object} o The Dom object spec (and children) | ||
259 | * @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.ext.Element | ||
260 | * @return {HTMLElement} The new node | ||
261 | */ | ||
262 | this.insertBefore = function(el, o, returnElement){ | ||
263 | el = el.dom ? el.dom : YAHOO.util.Dom.get(el); | ||
264 | var newNode; | ||
265 | if(this.useDom){ | ||
266 | newNode = createDom(o, null); | ||
267 | el.parentNode.insertBefore(newNode, el); | ||
268 | }else{ | ||
269 | var html = createHtml(o); | ||
270 | newNode = this.insertHtml('beforeBegin', el, html); | ||
271 | } | ||
272 | return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode; | ||
273 | }; | ||
274 | |||
275 | /** | ||
276 | * Creates new Dom element(s) and inserts them after el | ||
277 | * @param {String/HTMLElement/Element} el The context element | ||
278 | * @param {Object} o The Dom object spec (and children) | ||
279 | * @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.ext.Element | ||
280 | * @return {HTMLElement} The new node | ||
281 | */ | ||
282 | this.insertAfter = function(el, o, returnElement){ | ||
283 | el = el.dom ? el.dom : YAHOO.util.Dom.get(el); | ||
284 | var newNode; | ||
285 | if(this.useDom){ | ||
286 | newNode = createDom(o, null); | ||
287 | el.parentNode.insertBefore(newNode, el.nextSibling); | ||
288 | }else{ | ||
289 | var html = createHtml(o); | ||
290 | newNode = this.insertHtml('afterEnd', el, html); | ||
291 | } | ||
292 | return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode; | ||
293 | }; | ||
294 | |||
295 | /** | ||
296 | * Creates new Dom element(s) and appends them to el | ||
297 | * @param {String/HTMLElement/Element} el The context element | ||
298 | * @param {Object} o The Dom object spec (and children) | ||
299 | * @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.ext.Element | ||
300 | * @return {HTMLElement} The new node | ||
301 | */ | ||
302 | this.append = function(el, o, returnElement){ | ||
303 | el = el.dom ? el.dom : YAHOO.util.Dom.get(el); | ||
304 | var newNode; | ||
305 | if(this.useDom){ | ||
306 | newNode = createDom(o, null); | ||
307 | el.appendChild(newNode); | ||
308 | }else{ | ||
309 | var html = createHtml(o); | ||
310 | newNode = this.insertHtml('beforeEnd', el, html); | ||
311 | } | ||
312 | return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode; | ||
313 | }; | ||
314 | |||
315 | /** | ||
316 | * Creates new Dom element(s) and overwrites the contents of el with them | ||
317 | * @param {String/HTMLElement/Element} el The context element | ||
318 | * @param {Object} o The Dom object spec (and children) | ||
319 | * @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.ext.Element | ||
320 | * @return {HTMLElement} The new node | ||
321 | */ | ||
322 | this.overwrite = function(el, o, returnElement){ | ||
323 | el = el.dom ? el.dom : YAHOO.util.Dom.get(el); | ||
324 | el.innerHTML = createHtml(o); | ||
325 | return returnElement ? YAHOO.ext.Element.get(el.firstChild, true) : el.firstChild; | ||
326 | }; | ||
327 | |||
328 | /** | ||
329 | * Creates a new Clipperz.YUI.DomHelper.Template from the Dom object spec | ||
330 | * @param {Object} o The Dom object spec (and children) | ||
331 | * @return {Clipperz.YUI.DomHelper.Template} The new template | ||
332 | */ | ||
333 | this.createTemplate = function(o){ | ||
334 | var html = createHtml(o); | ||
335 | return new Clipperz.YUI.DomHelper.Template(html); | ||
336 | }; | ||
337 | }(); | ||
338 | |||
339 | /** | ||
340 | * @class Clipperz.YUI.DomHelper.Template | ||
341 | * Represents an HTML fragment template. | ||
342 | * For more information see <a href="http://www.jackslocum.com/yui/2006/10/06/domhelper-create-elements-using-dom-html-fragments-or-templates/">this blog post with examples</a>. | ||
343 | * <br> | ||
344 | * <b>This class is also available as YAHOO.ext.Template</b>. | ||
345 | * @constructor | ||
346 | * @param {String/Array} html The HTML fragment or an array of fragments to join('') or multiple arguments to join('') | ||
347 | */ | ||
348 | Clipperz.YUI.DomHelper.Template = function(html){ | ||
349 | if(html instanceof Array){ | ||
350 | html = html.join(''); | ||
351 | }else if(arguments.length > 1){ | ||
352 | html = Array.prototype.join.call(arguments, ''); | ||
353 | } | ||
354 | /**@private*/ | ||
355 | this.html = html; | ||
356 | }; | ||
357 | Clipperz.YUI.DomHelper.Template.prototype = { | ||
358 | /** | ||
359 | * Returns an HTML fragment of this template with the specified values applied | ||
360 | * @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'}) | ||
361 | * @return {String} | ||
362 | */ | ||
363 | applyTemplate : function(values){ | ||
364 | if(this.compiled){ | ||
365 | return this.compiled(values); | ||
366 | } | ||
367 | var empty = ''; | ||
368 | var fn = function(match, index){ | ||
369 | if(typeof values[index] != 'undefined'){ | ||
370 | return values[index]; | ||
371 | }else{ | ||
372 | return empty; | ||
373 | } | ||
374 | } | ||
375 | return this.html.replace(this.re, fn); | ||
376 | }, | ||
377 | |||
378 | /** | ||
379 | * The regular expression used to match template variables | ||
380 | * @type RegExp | ||
381 | * @property | ||
382 | */ | ||
383 | re : /\{([\w|-]+)\}/g, | ||
384 | |||
385 | /** | ||
386 | * Compiles the template into an internal function, eliminating the RegEx overhead | ||
387 | */ | ||
388 | compile : function(){ | ||
389 | var body = ["this.compiled = function(values){ return ['"]; | ||
390 | body.push(this.html.replace(this.re, "', values['$1'], '")); | ||
391 | body.push("'].join('');};"); | ||
392 | eval(body.join('')); | ||
393 | return this; | ||
394 | }, | ||
395 | |||
396 | /** | ||
397 | * Applies the supplied values to the template and inserts the new node(s) before el | ||
398 | * @param {String/HTMLElement/Element} el The context element | ||
399 | * @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'}) | ||
400 | * @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.ext.Element | ||
401 | * @return {HTMLElement} The new node | ||
402 | */ | ||
403 | insertBefore: function(el, values, returnElement){ | ||
404 | el = el.dom ? el.dom : YAHOO.util.Dom.get(el); | ||
405 | var newNode = Clipperz.YUI.DomHelper.insertHtml('beforeBegin', el, this.applyTemplate(values)); | ||
406 | return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode; | ||
407 | }, | ||
408 | |||
409 | /** | ||
410 | * Applies the supplied values to the template and inserts the new node(s) after el | ||
411 | * @param {String/HTMLElement/Element} el The context element | ||
412 | * @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'}) | ||
413 | * @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.ext.Element | ||
414 | * @return {HTMLElement} The new node | ||
415 | */ | ||
416 | insertAfter : function(el, values, returnElement){ | ||
417 | el = el.dom ? el.dom : YAHOO.util.Dom.get(el); | ||
418 | var newNode = Clipperz.YUI.DomHelper.insertHtml('afterEnd', el, this.applyTemplate(values)); | ||
419 | return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode; | ||
420 | }, | ||
421 | |||
422 | /** | ||
423 | * Applies the supplied values to the template and append the new node(s) to el | ||
424 | * @param {String/HTMLElement/Element} el The context element | ||
425 | * @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'}) | ||
426 | * @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.ext.Element | ||
427 | * @return {HTMLElement} The new node | ||
428 | */ | ||
429 | append : function(el, values, returnElement){ | ||
430 | var sanitizedValues; | ||
431 | var key; | ||
432 | |||
433 | // sanitizedValues = MochiKit.Base.map(sanitizedValues) | ||
434 | //console.log("values", values); | ||
435 | sanitizedValues = {}; | ||
436 | for (key in values) { | ||
437 | sanitizedValues[key] = Clipperz.Base.sanitizeString(values[key]); | ||
438 | } | ||
439 | //console.log("sanitizedValues", sanitizedValues); | ||
440 | el = el.dom ? el.dom : YAHOO.util.Dom.get(el); | ||
441 | var newNode = Clipperz.YUI.DomHelper.insertHtml('beforeEnd', el, this.applyTemplate(sanitizedValues)); | ||
442 | return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode; | ||
443 | }, | ||
444 | |||
445 | /** | ||
446 | * Applies the supplied values to the template and overwrites the content of el with the new node(s) | ||
447 | * @param {String/HTMLElement/Element} el The context element | ||
448 | * @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'}) | ||
449 | * @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.ext.Element | ||
450 | * @return {HTMLElement} The new node | ||
451 | */ | ||
452 | overwrite : function(el, values, returnElement){ | ||
453 | el = el.dom ? el.dom : YAHOO.util.Dom.get(el); | ||
454 | el.innerHTML = ''; | ||
455 | var newNode = Clipperz.YUI.DomHelper.insertHtml('beforeEnd', el, this.applyTemplate(values)); | ||
456 | return returnElement ? YAHOO.ext.Element.get(newNode, true) : newNode; | ||
457 | } | ||
458 | }; | ||
459 | /** | ||
460 | * Alias for applyTemplate | ||
461 | * @method | ||
462 | */ | ||
463 | Clipperz.YUI.DomHelper.Template.prototype.apply = Clipperz.YUI.DomHelper.Template.prototype.applyTemplate; | ||
464 | |||
465 | YAHOO.ext.Template = Clipperz.YUI.DomHelper.Template; | ||
diff --git a/frontend/beta/js/Clipperz/YUI/DomQuery.js b/frontend/beta/js/Clipperz/YUI/DomQuery.js new file mode 100644 index 0000000..84aac08 --- a/dev/null +++ b/frontend/beta/js/Clipperz/YUI/DomQuery.js | |||
@@ -0,0 +1,710 @@ | |||
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 | /* | ||
30 | * yui-ext 0.40 | ||
31 | * Copyright(c) 2006, Jack Slocum. | ||
32 | */ | ||
33 | |||
34 | /** | ||
35 | * @class Ext.DomQuery | ||
36 | * Provides high performance selector/xpath processing by compiling queries into reusable functions. | ||
37 | * New pseudo classes and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in). | ||
38 | * @singleton | ||
39 | */ | ||
40 | Ext.DomQuery = function(){ | ||
41 | var cache = {}, simpleCache = {}, valueCache = {}; | ||
42 | var nonSpace = /\S/; | ||
43 | var trimRe = /^\s*(.*?)\s*$/; | ||
44 | var tplRe = /\{(\d+)\}/g; | ||
45 | var modeRe = /^(\s?[\/>]\s?|\s|$)/; | ||
46 | var clsRes = {}; | ||
47 | |||
48 | function child(p, index){ | ||
49 | var i = 0; | ||
50 | var n = p.firstChild; | ||
51 | while(n){ | ||
52 | if(n.nodeType == 1){ | ||
53 | i++; | ||
54 | if(i == index){ | ||
55 | return n; | ||
56 | } | ||
57 | } | ||
58 | n = n.nextSibling; | ||
59 | } | ||
60 | return null; | ||
61 | }; | ||
62 | |||
63 | function next(d){ | ||
64 | var n = d.nextSibling; | ||
65 | while(n && n.nodeType != 1){ | ||
66 | n = n.nextSibling; | ||
67 | } | ||
68 | return n; | ||
69 | }; | ||
70 | |||
71 | function prev(d){ | ||
72 | var n = d.previousSibling; | ||
73 | while(n && n.nodeType != 1){ | ||
74 | n = n.previousSibling; | ||
75 | } | ||
76 | return n; | ||
77 | }; | ||
78 | |||
79 | function clean(d){ | ||
80 | var n = d.firstChild, ni = -1; | ||
81 | while(n){ | ||
82 | var nx = n.nextSibling; | ||
83 | if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){ | ||
84 | d.removeChild(n); | ||
85 | }else{ | ||
86 | n.nodeIndex = ++ni; | ||
87 | } | ||
88 | n = nx; | ||
89 | } | ||
90 | return this; | ||
91 | }; | ||
92 | |||
93 | function byClassName(c, a, v){ | ||
94 | if(!v){ | ||
95 | return c; | ||
96 | } | ||
97 | var re = clsRes[v]; | ||
98 | if(!re){ | ||
99 | re = new RegExp('(?:^|\\s)(?:' + v + ')(?:\\s|$)'); | ||
100 | clsRes[v] = re; | ||
101 | } | ||
102 | var r = []; | ||
103 | for(var i = 0, ci; ci = c[i]; i++){ | ||
104 | if(re.test(ci.className)){ | ||
105 | r[r.length] = ci; | ||
106 | } | ||
107 | } | ||
108 | return r; | ||
109 | }; | ||
110 | |||
111 | function convert(c){ | ||
112 | if(c.slice){ | ||
113 | return c; | ||
114 | } | ||
115 | var r = []; | ||
116 | for(var i = 0, l = c.length; i < l; i++){ | ||
117 | r[r.length] = c[i]; | ||
118 | } | ||
119 | return r; | ||
120 | }; | ||
121 | |||
122 | function attrValue(n, attr){ | ||
123 | if(!n.tagName && typeof n.length != 'undefined'){ | ||
124 | n = n[0]; | ||
125 | } | ||
126 | if(!n){ | ||
127 | return null; | ||
128 | } | ||
129 | if(attr == 'for'){ | ||
130 | return n.htmlFor; | ||
131 | } | ||
132 | if(attr == 'class' || attr == 'className'){ | ||
133 | return n.className; | ||
134 | } | ||
135 | return n.getAttribute(attr) || n[attr]; | ||
136 | |||
137 | }; | ||
138 | |||
139 | function getNodes(ns, mode, tagName){ | ||
140 | var result = [], cs; | ||
141 | if(!ns){ | ||
142 | return result; | ||
143 | } | ||
144 | mode = mode ? mode.replace(trimRe, '$1') : ''; | ||
145 | tagName = tagName || '*'; | ||
146 | if(ns.tagName || ns == document){ | ||
147 | ns = [ns]; | ||
148 | } | ||
149 | if(mode != '/' && mode != '>'){ | ||
150 | for(var i = 0, ni; ni = ns[i]; i++){ | ||
151 | cs = ni.getElementsByTagName(tagName); | ||
152 | result = concat(result, cs); | ||
153 | } | ||
154 | }else{ | ||
155 | for(var i = 0, ni; ni = ns[i]; i++){ | ||
156 | var cn = ni.getElementsByTagName(tagName); | ||
157 | for(var j = 0, cj; cj = cn[j]; j++){ | ||
158 | if(cj.parentNode == ni){ | ||
159 | result[result.length] = cj; | ||
160 | } | ||
161 | } | ||
162 | } | ||
163 | |||
164 | } | ||
165 | return result; | ||
166 | }; | ||
167 | |||
168 | function concat(a, b){ | ||
169 | if(b.slice){ | ||
170 | return a.concat(b); | ||
171 | } | ||
172 | for(var i = 0, l = b.length; i < l; i++){ | ||
173 | a[a.length] = b[i]; | ||
174 | } | ||
175 | return a; | ||
176 | } | ||
177 | |||
178 | function byTag(cs, tagName){ | ||
179 | if(cs.tagName || cs == document){ | ||
180 | cs = [cs]; | ||
181 | } | ||
182 | if(!tagName){ | ||
183 | return cs; | ||
184 | } | ||
185 | var r = []; tagName = tagName.toLowerCase(); | ||
186 | for(var i = 0, ci; ci = cs[i]; i++){ | ||
187 | if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){ | ||
188 | r[r.length] = ci; | ||
189 | } | ||
190 | } | ||
191 | return r; | ||
192 | }; | ||
193 | |||
194 | function byId(cs, attr, id){ | ||
195 | if(cs.tagName || cs == document){ | ||
196 | cs = [cs]; | ||
197 | } | ||
198 | if(!id){ | ||
199 | return cs; | ||
200 | } | ||
201 | var r = []; | ||
202 | for(var i = 0, l = cs.length; i < l; i++){ | ||
203 | var ci = cs[i]; | ||
204 | if(ci && ci.id == id){ | ||
205 | r[r.length] = ci; | ||
206 | } | ||
207 | } | ||
208 | return r; | ||
209 | }; | ||
210 | |||
211 | function byAttribute(cs, attr, value, op, custom){ | ||
212 | var r = [], st = custom=='{'; | ||
213 | var f = Ext.DomQuery.operators[op]; | ||
214 | for(var i = 0, l = cs.length; i < l; i++){ | ||
215 | var a; | ||
216 | if(st){ | ||
217 | a = Ext.DomQuery.getStyle(cs[i], attr); | ||
218 | } | ||
219 | else if(attr == 'class' || attr == 'className'){ | ||
220 | a = cs[i].className; | ||
221 | }else if(attr == 'for'){ | ||
222 | a = cs[i].htmlFor; | ||
223 | }else{ | ||
224 | a = cs[i].getAttribute(attr); | ||
225 | } | ||
226 | if((f && f(a, value)) || (!f && a)){ | ||
227 | r[r.length] = cs[i]; | ||
228 | } | ||
229 | } | ||
230 | return r; | ||
231 | }; | ||
232 | |||
233 | function byPseudo(cs, name, value){ | ||
234 | return Ext.DomQuery.pseudos[name](cs, value); | ||
235 | }; | ||
236 | |||
237 | // This is for IE MSXML which does not support expandos. | ||
238 | // IE runs the same speed using setAttribute, however FF slows way down | ||
239 | // and Safari completely fails so they need to continue to use expandos. | ||
240 | // Branched at load time for faster execution. | ||
241 | var isIE = window.ActiveXObject; | ||
242 | var addAttr = isIE ? | ||
243 | function(n, a, v){ | ||
244 | n.setAttribute(a, v); | ||
245 | } : | ||
246 | function(n, a, v){ | ||
247 | n[a] = v; | ||
248 | }; | ||
249 | var getAttr = isIE ? | ||
250 | function(n, a){ | ||
251 | return n.getAttribute(a); | ||
252 | } : | ||
253 | function(n, a){ | ||
254 | return n[a]; | ||
255 | }; | ||
256 | var clearAttr = isIE ? | ||
257 | function(n, a){ | ||
258 | n.removeAttribute(a); | ||
259 | } : | ||
260 | function(n, a, v){ | ||
261 | delete n[a]; | ||
262 | }; | ||
263 | |||
264 | function nodup(cs){ | ||
265 | if(!cs.length){ | ||
266 | return cs; | ||
267 | } | ||
268 | addAttr(cs[0], '_nodup', true); | ||
269 | var r = [cs[0]]; | ||
270 | for(var i = 1, len = cs.length; i < len; i++){ | ||
271 | var c = cs[i]; | ||
272 | if(!getAttr(c, '_nodup')){ | ||
273 | addAttr(c, '_nodup', true); | ||
274 | r[r.length] = c; | ||
275 | } | ||
276 | } | ||
277 | for(var i = 0, len = cs.length; i < len; i++){ | ||
278 | clearAttr(cs[i], '_nodup'); | ||
279 | } | ||
280 | return r; | ||
281 | } | ||
282 | |||
283 | function quickDiff(c1, c2){ | ||
284 | if(!c1.length){ | ||
285 | return c2; | ||
286 | } | ||
287 | for(var i = 0, len = c1.length; i < len; i++){ | ||
288 | addAttr(c1[i], '_qdiff', true); | ||
289 | } | ||
290 | var r = []; | ||
291 | for(var i = 0, len = c2.length; i < len; i++){ | ||
292 | if(!getAttr(c2[i], '_qdiff')){ | ||
293 | r[r.length] = c2[i]; | ||
294 | } | ||
295 | } | ||
296 | for(var i = 0, len = c1.length; i < len; i++){ | ||
297 | clearAttr(c1[i], '_qdiff'); | ||
298 | } | ||
299 | return r; | ||
300 | } | ||
301 | |||
302 | function quickId(ns, mode, root, id){ | ||
303 | if(ns == root){ | ||
304 | var d = root.ownerDocument || root; | ||
305 | return d.getElementById(id); | ||
306 | } | ||
307 | ns = getNodes(ns, mode, '*'); | ||
308 | return byId(ns, null, id); | ||
309 | } | ||
310 | |||
311 | return { | ||
312 | getStyle : function(el, name){ | ||
313 | return YAHOO.util.Dom.getStyle(el, name); | ||
314 | }, | ||
315 | /** | ||
316 | * Compiles a selector/xpath query into a reusable function. The returned function | ||
317 | * takes one parameter "root" (optional), which is the context node from where the query should start. | ||
318 | * @param {String} selector The selector/xpath query | ||
319 | * @param {String} type (optional) Either 'select' (the default) or 'simple' for a simple selector match | ||
320 | * @return {Function} | ||
321 | */ | ||
322 | compile : function(path, type){ | ||
323 | // strip leading slashes | ||
324 | while(path.substr(0, 1)=='/'){ | ||
325 | path = path.substr(1); | ||
326 | } | ||
327 | type = type || 'select'; | ||
328 | |||
329 | var fn = ['var f = function(root){\n var mode; var n = root || document;\n']; | ||
330 | var q = path, mode, lq; | ||
331 | var tk = Ext.DomQuery.matchers; | ||
332 | var tklen = tk.length; | ||
333 | var mm; | ||
334 | while(q && lq != q){ | ||
335 | lq = q; | ||
336 | var tm = q.match(/^(#)?([\w-\*]+)/); | ||
337 | if(type == 'select'){ | ||
338 | if(tm){ | ||
339 | if(tm[1] == '#'){ | ||
340 | fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");'; | ||
341 | }else{ | ||
342 | fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");'; | ||
343 | } | ||
344 | q = q.replace(tm[0], ''); | ||
345 | }else{ | ||
346 | fn[fn.length] = 'n = getNodes(n, mode, "*");'; | ||
347 | } | ||
348 | }else{ | ||
349 | if(tm){ | ||
350 | if(tm[1] == '#'){ | ||
351 | fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");'; | ||
352 | }else{ | ||
353 | fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");'; | ||
354 | } | ||
355 | q = q.replace(tm[0], ''); | ||
356 | } | ||
357 | } | ||
358 | while(!(mm = q.match(modeRe))){ | ||
359 | var matched = false; | ||
360 | for(var j = 0; j < tklen; j++){ | ||
361 | var t = tk[j]; | ||
362 | var m = q.match(t.re); | ||
363 | if(m){ | ||
364 | fn[fn.length] = t.select.replace(tplRe, function(x, i){ | ||
365 | return m[i]; | ||
366 | }); | ||
367 | q = q.replace(m[0], ''); | ||
368 | matched = true; | ||
369 | break; | ||
370 | } | ||
371 | } | ||
372 | // prevent infinite loop on bad selector | ||
373 | if(!matched){ | ||
374 | throw 'Error parsing selector, parsing failed at "' + q + '"'; | ||
375 | } | ||
376 | } | ||
377 | if(mm[1]){ | ||
378 | fn[fn.length] = 'mode="'+mm[1]+'";'; | ||
379 | q = q.replace(mm[1], ''); | ||
380 | } | ||
381 | } | ||
382 | fn[fn.length] = 'return nodup(n);\n}'; | ||
383 | eval(fn.join('')); | ||
384 | return f; | ||
385 | }, | ||
386 | |||
387 | /** | ||
388 | * Selects a group of elements. | ||
389 | * @param {String} selector The selector/xpath query | ||
390 | * @param {Node} root (optional) The start of the query (defaults to document). | ||
391 | * @return {Array} | ||
392 | */ | ||
393 | select : function(path, root, type){ | ||
394 | if(!root || root == document){ | ||
395 | root = document; | ||
396 | } | ||
397 | if(typeof root == 'string'){ | ||
398 | root = document.getElementById(root); | ||
399 | } | ||
400 | var paths = path.split(','); | ||
401 | var results = []; | ||
402 | for(var i = 0, len = paths.length; i < len; i++){ | ||
403 | var p = paths[i].replace(trimRe, '$1'); | ||
404 | if(!cache[p]){ | ||
405 | cache[p] = Ext.DomQuery.compile(p); | ||
406 | if(!cache[p]){ | ||
407 | throw p + ' is not a valid selector'; | ||
408 | } | ||
409 | } | ||
410 | var result = cache[p](root); | ||
411 | if(result && result != document){ | ||
412 | results = results.concat(result); | ||
413 | } | ||
414 | } | ||
415 | return results; | ||
416 | }, | ||
417 | |||
418 | /** | ||
419 | * Selects a single element. | ||
420 | * @param {String} selector The selector/xpath query | ||
421 | * @param {Node} root (optional) The start of the query (defaults to document). | ||
422 | * @return {Element} | ||
423 | */ | ||
424 | selectNode : function(path, root){ | ||
425 | return Ext.DomQuery.select(path, root)[0]; | ||
426 | }, | ||
427 | |||
428 | /** | ||
429 | * Selects the value of a node, optionally replacing null with the defaultValue. | ||
430 | * @param {String} selector The selector/xpath query | ||
431 | * @param {Node} root (optional) The start of the query (defaults to document). | ||
432 | * @param {String} defaultValue | ||
433 | */ | ||
434 | selectValue : function(path, root, defaultValue){ | ||
435 | path = path.replace(trimRe, '$1'); | ||
436 | if(!valueCache[path]){ | ||
437 | valueCache[path] = Ext.DomQuery.compile(path, 'simple'); | ||
438 | } | ||
439 | var n = valueCache[path](root); | ||
440 | n = n[0] ? n[0] : n; | ||
441 | var v = (n && n.firstChild ? n.firstChild.nodeValue : null); | ||
442 | return (v === null ? defaultValue : v); | ||
443 | }, | ||
444 | |||
445 | /** | ||
446 | * Selects the value of a node, parsing integers and floats. | ||
447 | * @param {String} selector The selector/xpath query | ||
448 | * @param {Node} root (optional) The start of the query (defaults to document). | ||
449 | * @param {Number} defaultValue | ||
450 | * @return {Number} | ||
451 | */ | ||
452 | selectNumber : function(path, root, defaultValue){ | ||
453 | var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0); | ||
454 | return parseFloat(v); | ||
455 | }, | ||
456 | |||
457 | /** | ||
458 | * Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child) | ||
459 | * @param {String/HTMLElement/Array} el An element id, element or array of elements | ||
460 | * @param {String} selector The simple selector to test | ||
461 | * @return {Boolean} | ||
462 | */ | ||
463 | is : function(el, ss){ | ||
464 | if(typeof el == 'string'){ | ||
465 | el = document.getElementById(el); | ||
466 | } | ||
467 | var isArray = (el instanceof Array); | ||
468 | var result = Ext.DomQuery.filter(isArray ? el : [el], ss); | ||
469 | return isArray ? (result.length == el.length) : (result.length > 0); | ||
470 | }, | ||
471 | |||
472 | /** | ||
473 | * Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child) | ||
474 | * @param {Array} el An array of elements to filter | ||
475 | * @param {String} selector The simple selector to test | ||
476 | * @param {Boolean} nonMatches If true, it returns the elements that DON'T match | ||
477 | * the selector instead of the ones that match | ||
478 | * @return {Array} | ||
479 | */ | ||
480 | filter : function(els, ss, nonMatches){ | ||
481 | ss = ss.replace(trimRe, '$1'); | ||
482 | if(!simpleCache[ss]){ | ||
483 | simpleCache[ss] = Ext.DomQuery.compile(ss, 'simple'); | ||
484 | } | ||
485 | var result = simpleCache[ss](els); | ||
486 | return nonMatches ? quickDiff(result, els) : result; | ||
487 | }, | ||
488 | |||
489 | /** | ||
490 | * Collection of matching regular expressions and code snippets. | ||
491 | */ | ||
492 | matchers : [{ | ||
493 | re: /^\.([\w-]+)/, | ||
494 | select: 'n = byClassName(n, null, "{1}");' | ||
495 | }, { | ||
496 | re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/, | ||
497 | select: 'n = byPseudo(n, "{1}", "{2}");' | ||
498 | },{ | ||
499 | re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/, | ||
500 | select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");' | ||
501 | }, { | ||
502 | re: /^#([\w-]+)/, | ||
503 | select: 'n = byId(n, null, "{1}");' | ||
504 | },{ | ||
505 | re: /^@([\w-]+)/, | ||
506 | select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};' | ||
507 | } | ||
508 | ], | ||
509 | |||
510 | /** | ||
511 | * Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *= and %=. | ||
512 | * New operators can be added as long as the match the format <i>c</i>= where <i>c<i> is any character other than space, > <. | ||
513 | */ | ||
514 | operators : { | ||
515 | '=' : function(a, v){ | ||
516 | return a == v; | ||
517 | }, | ||
518 | '!=' : function(a, v){ | ||
519 | return a != v; | ||
520 | }, | ||
521 | '^=' : function(a, v){ | ||
522 | return a && a.substr(0, v.length) == v; | ||
523 | }, | ||
524 | '$=' : function(a, v){ | ||
525 | return a && a.substr(a.length-v.length) == v; | ||
526 | }, | ||
527 | '*=' : function(a, v){ | ||
528 | return a && a.indexOf(v) !== -1; | ||
529 | }, | ||
530 | '%=' : function(a, v){ | ||
531 | return (a % v) == 0; | ||
532 | } | ||
533 | }, | ||
534 | |||
535 | /** | ||
536 | * Collection of "pseudo class" processors. Each processor is passed the current nodeset (array) | ||
537 | * and the argument (if any) supplied in the selector. | ||
538 | */ | ||
539 | pseudos : { | ||
540 | 'first-child' : function(c){ | ||
541 | var r = []; | ||
542 | for(var i = 0, l = c.length; i < l; i++){ | ||
543 | var ci = c[i]; | ||
544 | if(!prev(ci)){ | ||
545 | r[r.length] = ci; | ||
546 | } | ||
547 | } | ||
548 | return r; | ||
549 | }, | ||
550 | |||
551 | 'last-child' : function(c){ | ||
552 | var r = []; | ||
553 | for(var i = 0, l = c.length; i < l; i++){ | ||
554 | var ci = c[i]; | ||
555 | if(!next(ci)){ | ||
556 | r[r.length] = ci; | ||
557 | } | ||
558 | } | ||
559 | return r; | ||
560 | }, | ||
561 | |||
562 | 'nth-child' : function(c, a){ | ||
563 | var r = []; | ||
564 | if(a != 'odd' && a != 'even'){ | ||
565 | for(var i = 0, ci; ci = c[i]; i++){ | ||
566 | var m = child(ci.parentNode, a); | ||
567 | if(m == ci){ | ||
568 | r[r.length] = m; | ||
569 | } | ||
570 | } | ||
571 | return r; | ||
572 | } | ||
573 | var p; | ||
574 | // first let's clean up the parent nodes | ||
575 | for(var i = 0, l = c.length; i < l; i++){ | ||
576 | var cp = c[i].parentNode; | ||
577 | if(cp != p){ | ||
578 | clean(cp); | ||
579 | p = cp; | ||
580 | } | ||
581 | } | ||
582 | // then lets see if we match | ||
583 | for(var i = 0, l = c.length; i < l; i++){ | ||
584 | var ci = c[i], m = false; | ||
585 | if(a == 'odd'){ | ||
586 | m = ((ci.nodeIndex+1) % 2 == 1); | ||
587 | }else if(a == 'even'){ | ||
588 | m = ((ci.nodeIndex+1) % 2 == 0); | ||
589 | } | ||
590 | if(m){ | ||
591 | r[r.length] = ci; | ||
592 | } | ||
593 | } | ||
594 | return r; | ||
595 | }, | ||
596 | |||
597 | 'only-child' : function(c){ | ||
598 | var r = []; | ||
599 | for(var i = 0, l = c.length; i < l; i++){ | ||
600 | var ci = c[i]; | ||
601 | if(!prev(ci) && !next(ci)){ | ||
602 | r[r.length] = ci; | ||
603 | } | ||
604 | } | ||
605 | return r; | ||
606 | }, | ||
607 | |||
608 | 'empty' : function(c){ | ||
609 | var r = []; | ||
610 | for(var i = 0, l = c.length; i < l; i++){ | ||
611 | var ci = c[i]; | ||
612 | if(!ci.firstChild){ | ||
613 | r[r.length] = ci; | ||
614 | } | ||
615 | } | ||
616 | return r; | ||
617 | }, | ||
618 | |||
619 | 'contains' : function(c, v){ | ||
620 | var r = []; | ||
621 | for(var i = 0, l = c.length; i < l; i++){ | ||
622 | var ci = c[i]; | ||
623 | if(ci.innerHTML.indexOf(v) !== -1){ | ||
624 | r[r.length] = ci; | ||
625 | } | ||
626 | } | ||
627 | return r; | ||
628 | }, | ||
629 | |||
630 | 'checked' : function(c){ | ||
631 | var r = []; | ||
632 | for(var i = 0, l = c.length; i < l; i++){ | ||
633 | if(c[i].checked == 'checked'){ | ||
634 | r[r.length] = c[i]; | ||
635 | } | ||
636 | } | ||
637 | return r; | ||
638 | }, | ||
639 | |||
640 | 'not' : function(c, ss){ | ||
641 | return Ext.DomQuery.filter(c, ss, true); | ||
642 | }, | ||
643 | |||
644 | 'odd' : function(c){ | ||
645 | return this['nth-child'](c, 'odd'); | ||
646 | }, | ||
647 | |||
648 | 'even' : function(c){ | ||
649 | return this['nth-child'](c, 'even'); | ||
650 | }, | ||
651 | |||
652 | 'nth' : function(c, a){ | ||
653 | return c[a-1]; | ||
654 | }, | ||
655 | |||
656 | 'first' : function(c){ | ||
657 | return c[0]; | ||
658 | }, | ||
659 | |||
660 | 'last' : function(c){ | ||
661 | return c[c.length-1]; | ||
662 | }, | ||
663 | |||
664 | 'has' : function(c, ss){ | ||
665 | var s = Ext.DomQuery.select; | ||
666 | var r = []; | ||
667 | for(var i = 0, ci; ci = c[i]; i++){ | ||
668 | if(s(ss, ci).length > 0){ | ||
669 | r[r.length] = ci; | ||
670 | } | ||
671 | } | ||
672 | return r; | ||
673 | }, | ||
674 | |||
675 | 'next' : function(c, ss){ | ||
676 | var is = Ext.DomQuery.is; | ||
677 | var r = []; | ||
678 | for(var i = 0, ci; ci = c[i]; i++){ | ||
679 | var n = next(ci); | ||
680 | if(n && is(n, ss)){ | ||
681 | r[r.length] = ci; | ||
682 | } | ||
683 | } | ||
684 | return r; | ||
685 | }, | ||
686 | |||
687 | 'prev' : function(c, ss){ | ||
688 | var is = Ext.DomQuery.is; | ||
689 | var r = []; | ||
690 | for(var i = 0, ci; ci = c[i]; i++){ | ||
691 | var n = prev(ci); | ||
692 | if(n && is(n, ss)){ | ||
693 | r[r.length] = ci; | ||
694 | } | ||
695 | } | ||
696 | return r; | ||
697 | } | ||
698 | } | ||
699 | }; | ||
700 | }(); | ||
701 | |||
702 | /** | ||
703 | * Selects an array of DOM nodes by CSS/XPath selector. Shorthand of {@link Ext.DomQuery#select} | ||
704 | * @param {String} path The selector/xpath query | ||
705 | * @param {Node} root (optional) The start of the query (defaults to document). | ||
706 | * @return {Array} | ||
707 | * @member Ext | ||
708 | * @method query | ||
709 | */ | ||
710 | Ext.query = Ext.DomQuery.select; | ||
diff --git a/frontend/beta/js/Clipperz/YUI/Drawer.js b/frontend/beta/js/Clipperz/YUI/Drawer.js new file mode 100644 index 0000000..394912e --- a/dev/null +++ b/frontend/beta/js/Clipperz/YUI/Drawer.js | |||
@@ -0,0 +1,238 @@ | |||
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.Drawer = function(anElement, aRegion) { | ||
34 | this._status = 'slideIn'; | ||
35 | |||
36 | this._element = YAHOO.ext.Element.get(anElement); | ||
37 | this._region = aRegion || null; | ||
38 | |||
39 | this._collapsedElement = this.element().getChildrenByClassName("drawer-collapsed")[0]; | ||
40 | this._contentElement = this.element().getChildrenByClassName("drawer-content")[0]; | ||
41 | |||
42 | |||
43 | this._wholeCollapedElement = this.enhanceCollapsedElement(); | ||
44 | this._wholeCollapedElement.setWidth(this.region().element().getWidth()); | ||
45 | this._wholeCollapedElement.setHeight(this.region().element().getHeight()); | ||
46 | |||
47 | this._contentWrapper = this.enhanceContentElement(); | ||
48 | this._contentElementActor = new YAHOO.ext.Actor(this.contentWrapper().dom); | ||
49 | this.contentElementActor().hide(); | ||
50 | |||
51 | this._contentWidth = 200; | ||
52 | }; | ||
53 | |||
54 | YAHOO.extendX(Clipperz.YUI.Drawer, YAHOO.ext.util.Observable, { | ||
55 | |||
56 | 'element': function() { | ||
57 | return this._element; | ||
58 | }, | ||
59 | |||
60 | //----------------------------------------------------- | ||
61 | |||
62 | 'status': function() { | ||
63 | return this._status; | ||
64 | }, | ||
65 | |||
66 | 'setStatus': function(aValue) { | ||
67 | this._status = aValue; | ||
68 | }, | ||
69 | |||
70 | //----------------------------------------------------- | ||
71 | |||
72 | 'collapsedElement': function() { | ||
73 | return this._collapsedElement; | ||
74 | }, | ||
75 | |||
76 | //----------------------------------------------------- | ||
77 | |||
78 | 'contentElement': function() { | ||
79 | return this._contentElement; | ||
80 | }, | ||
81 | |||
82 | //----------------------------------------------------- | ||
83 | |||
84 | 'contentElementActor': function() { | ||
85 | return this._contentElementActor; | ||
86 | }, | ||
87 | |||
88 | //----------------------------------------------------- | ||
89 | |||
90 | 'contentWrapper': function() { | ||
91 | return this._contentWrapper; | ||
92 | }, | ||
93 | |||
94 | //----------------------------------------------------- | ||
95 | |||
96 | 'contentWidth': function() { | ||
97 | return this._contentWidth; | ||
98 | }, | ||
99 | |||
100 | //----------------------------------------------------- | ||
101 | |||
102 | 'region': function() { | ||
103 | return this._region; | ||
104 | }, | ||
105 | |||
106 | //----------------------------------------------------- | ||
107 | |||
108 | 'enhanceCollapsedElement': function() { | ||
109 | varwrapper; | ||
110 | var link; | ||
111 | |||
112 | wrapper = this.collapsedElement().wrap({tag:'div', cls:'drawer-collapsedElement-wrapper', children:[ | ||
113 | {tag:'div', cls:'drawer-pin-button', children:[ | ||
114 | {tag:'a', cls:'drawer-pin-button', href:"#", children:[ | ||
115 | {tag:'img', src:'./images/directLogins/drawer/mm-expand.gif'} | ||
116 | ]} | ||
117 | ]} | ||
118 | ]}); | ||
119 | |||
120 | link = wrapper.getChildrenByClassName('drawer-pin-button', 'a')[0]; | ||
121 | MochiKit.Signal.connect(link.dom, 'onclick', this, 'pinDrawer'); | ||
122 | |||
123 | this.collapsedElement().setHeight('100%'); | ||
124 | this.collapsedElement().setStyle('cursor', 'pointer'); | ||
125 | MochiKit.Signal.connect(this.collapsedElement().dom, 'onclick', this, 'showDrawer'); | ||
126 | |||
127 | return wrapper; | ||
128 | }, | ||
129 | |||
130 | //----------------------------------------------------- | ||
131 | |||
132 | 'enhanceContentElement': function() { | ||
133 | var wrapper; | ||
134 | |||
135 | wrapper = this.contentElement().wrap({tag:'div', cls:'drawer-content-wrapper', children:[ | ||
136 | {tag:'div', cls:'drawer-content-header', html:'direct login', style:'width:100%;'} | ||
137 | ]}); | ||
138 | |||
139 | MochiKit.Signal.connect(wrapper.dom, 'onclick', this, 'hideDrawer'); | ||
140 | return wrapper; | ||
141 | }, | ||
142 | |||
143 | //----------------------------------------------------- | ||
144 | |||
145 | 'pinDrawer': function() { | ||
146 | alert("pin drawer"); | ||
147 | }, | ||
148 | |||
149 | //----------------------------------------------------- | ||
150 | |||
151 | 'showDrawer': function() { | ||
152 | if (this.status() == 'slideIn') { | ||
153 | var actor; | ||
154 | |||
155 | this.setStatus('slidingOut'); | ||
156 | actor = this.contentElementActor(); | ||
157 | actor.setHeight(this.region().element().getHeight()); | ||
158 | |||
159 | actor.startCapture(true); | ||
160 | actor.alignTo(this.element(), 'tr'); | ||
161 | actor.blindShow('left', this.contentWidth(), .35); | ||
162 | actor.play(this.onSlideOut.createDelegate(this)); | ||
163 | } | ||
164 | }, | ||
165 | |||
166 | //----------------------------------------------------- | ||
167 | |||
168 | 'onSlideOut': function() { | ||
169 | this.setStatus('slideOut'); | ||
170 | MochiKit.Logging.logDebug(">>> onSlideOut"); | ||
171 | // alert("done"); | ||
172 | }, | ||
173 | |||
174 | //----------------------------------------------------- | ||
175 | /* | ||
176 | 'showContentElement': function() { | ||
177 | var top, left, width, height; | ||
178 | |||
179 | MochiKit.Logging.logDebug(">>> showContentElement"); | ||
180 | |||
181 | |||
182 | top = this.element().getTop(true); | ||
183 | left = this.element().getRight(); | ||
184 | width = this.contentWidth(); | ||
185 | height = this.element().getHeight(); | ||
186 | |||
187 | this.contentWrapper().setStyle('position', 'absolute'); | ||
188 | this.contentWrapper().setStyle('overflow', 'none'); | ||
189 | this.contentWrapper().setStyle('visibility', 'visible'); | ||
190 | this.contentWrapper().setStyle('z-index', '10'); | ||
191 | |||
192 | this.contentWrapper().setLeft(left); | ||
193 | this.contentWrapper().setTop(top); | ||
194 | this.contentWrapper().setHeight(height); | ||
195 | this.contentWrapper().setWidth(width); | ||
196 | |||
197 | this.contentWrapper().show(); | ||
198 | }, | ||
199 | */ | ||
200 | //----------------------------------------------------- | ||
201 | |||
202 | 'hideDrawer': function() { | ||
203 | if (this.status() == 'slideOut') { | ||
204 | var actor; | ||
205 | |||
206 | this.setStatus('slidingIn'); | ||
207 | |||
208 | actor = this.contentElementActor(); | ||
209 | actor.setHeight(this.region().element().getHeight()); | ||
210 | |||
211 | actor.startCapture(true); | ||
212 | actor.alignTo(this.element(), 'tr'); | ||
213 | actor.blindHide('left', .35); | ||
214 | actor.setVisible(false); | ||
215 | actor.play(this.onSlideIn.createDelegate(this)); | ||
216 | } | ||
217 | }, | ||
218 | |||
219 | //----------------------------------------------------- | ||
220 | |||
221 | 'onSlideIn': function() { | ||
222 | this.setStatus('slideIn'); | ||
223 | MochiKit.Logging.logDebug(">>> onSlideIn"); | ||
224 | // alert("done"); | ||
225 | }, | ||
226 | |||
227 | //----------------------------------------------------- | ||
228 | |||
229 | 'hideContentElement': function() { | ||
230 | this.contentWrapper().hide(); | ||
231 | }, | ||
232 | |||
233 | //----------------------------------------------------- | ||
234 | //----------------------------------------------------- | ||
235 | |||
236 | //----------------------------------------------------- | ||
237 | __syntaxFix__: '__syntaxFix__' | ||
238 | }); \ No newline at end of file | ||
diff --git a/frontend/beta/js/Clipperz/YUI/IBLayoutManager.js b/frontend/beta/js/Clipperz/YUI/IBLayoutManager.js new file mode 100644 index 0000000..626b699 --- a/dev/null +++ b/frontend/beta/js/Clipperz/YUI/IBLayoutManager.js | |||
@@ -0,0 +1,114 @@ | |||
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.IBLayoutManager = function(container, config) { | ||
34 | var regionName; | ||
35 | varelement; | ||
36 | |||
37 | config = config || {}; | ||
38 | |||
39 | Clipperz.YUI.IBLayoutManager.superclass.constructor.call(this, container); | ||
40 | this.hideOnLayout = config.hideOnLayout || false; | ||
41 | |||
42 | element = YAHOO.ext.Element.get(container); | ||
43 | element.setStyle('position', 'absolute'); | ||
44 | element.setStyle('overflow', 'hidden'); | ||
45 | |||
46 | for (regionName in config.regions) { | ||
47 | var newRegion; | ||
48 | |||
49 | newRegion = new new Clipperz.YUI.IBLayoutRegion(this, regionName, config.regions[regionName]); | ||
50 | this.addRegion(regionName, newRegion); | ||
51 | } | ||
52 | |||
53 | this.layout(); | ||
54 | }; | ||
55 | |||
56 | YAHOO.extendX(Clipperz.YUI.IBLayoutManager, YAHOO.ext.LayoutManager, { | ||
57 | |||
58 | 'toString': function() { | ||
59 | return "IBLayoutManager (" + this.el.id + ")"; | ||
60 | }, | ||
61 | |||
62 | //----------------------------------------------------- | ||
63 | |||
64 | 'add': function(aName, aPanel) { | ||
65 | var regionName; | ||
66 | |||
67 | regionName = aName.toLowerCase(); | ||
68 | return this.regions[regionName].add(aPanel); | ||
69 | }, | ||
70 | |||
71 | //----------------------------------------------------- | ||
72 | |||
73 | 'addRegion': function(aRegion) { | ||
74 | var regionName; | ||
75 | |||
76 | regionName = aRegion.name().toLowerCase(); | ||
77 | if (!this.regions[regionName]) { | ||
78 | //MochiKit.Logging.logDebug("--- adding region with name: " + aRegion.name()); | ||
79 | this.regions[regionName] = aRegion; | ||
80 | } else { | ||
81 | // ???? | ||
82 | } | ||
83 | |||
84 | return aRegion; | ||
85 | }, | ||
86 | |||
87 | //----------------------------------------------------- | ||
88 | |||
89 | 'getRegion': function(target){ | ||
90 | return this.regions[target.toLowerCase()]; | ||
91 | }, | ||
92 | |||
93 | //----------------------------------------------------- | ||
94 | |||
95 | 'layout': function(){ | ||
96 | varregion; | ||
97 | |||
98 | //MochiKit.Logging.logDebug(">>> IBLayoutManager.layout - regions: " + Clipperz.Base.serializeJSON(MochiKit.Base.keys(this.regions))); | ||
99 | for (region in this.regions) { | ||
100 | //MochiKit.Logging.logDebug("--- IBLayoutManager.layout - region: " + region); | ||
101 | this.regions[region].layout(); | ||
102 | } | ||
103 | //MochiKit.Logging.logDebug("<<< IBLayoutManager.layout"); | ||
104 | }, | ||
105 | |||
106 | //----------------------------------------------------- | ||
107 | |||
108 | 'getSize': function() { | ||
109 | return this.el.getSize(); | ||
110 | }, | ||
111 | |||
112 | //----------------------------------------------------- | ||
113 | __syntaxFix__: '__syntaxFix__' | ||
114 | }); | ||
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 | }); | ||
diff --git a/frontend/beta/js/Clipperz/YUI/MessageBox.js b/frontend/beta/js/Clipperz/YUI/MessageBox.js new file mode 100644 index 0000000..ec33d7d --- a/dev/null +++ b/frontend/beta/js/Clipperz/YUI/MessageBox.js | |||
@@ -0,0 +1,265 @@ | |||
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 | Clipperz.YUI.MessageBox = function(){ | ||
30 | var dlg, opt, mask; | ||
31 | var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp; | ||
32 | var buttons, activeTextEl, bwidth; | ||
33 | |||
34 | var handleButton = function(button){ | ||
35 | if(typeof opt.fn == 'function'){ | ||
36 | if(opt.fn.call(opt.scope||window, button, activeTextEl.dom.value) !== false){ | ||
37 | dlg.hide(); | ||
38 | } | ||
39 | }else{ | ||
40 | dlg.hide(); | ||
41 | } | ||
42 | }; | ||
43 | |||
44 | return { | ||
45 | updateButtons: function(b){ | ||
46 | var width = 0; | ||
47 | if(!b){ | ||
48 | buttons['ok'].hide(); | ||
49 | buttons['cancel'].hide(); | ||
50 | buttons['yes'].hide(); | ||
51 | buttons['no'].hide(); | ||
52 | return width; | ||
53 | } | ||
54 | for(var k in buttons){ | ||
55 | if(typeof buttons[k] != 'function'){ | ||
56 | if(b[k]){ | ||
57 | buttons[k].show(); | ||
58 | buttons[k].setText(typeof b[k] == 'string' ? b[k] : YAHOO.ext.MessageBox.buttonText[k]); | ||
59 | width += buttons[k].el.getWidth()+15; | ||
60 | }else{ | ||
61 | buttons[k].hide(); | ||
62 | } | ||
63 | } | ||
64 | } | ||
65 | return width; | ||
66 | }, | ||
67 | |||
68 | getDialog : function(){ | ||
69 | if(!dlg){ | ||
70 | dlg = new YAHOO.ext.BasicDialog('mb-dlg', { | ||
71 | autoCreate:true, | ||
72 | shadow:true, | ||
73 | draggable:true, | ||
74 | resizable:false, | ||
75 | constraintoviewport:true, | ||
76 | fixedcenter:true, | ||
77 | shim:true, | ||
78 | modal:true, | ||
79 | width:400, height:100, | ||
80 | buttonAlign:'center', | ||
81 | closeClick : function(){ | ||
82 | if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){ | ||
83 | handleButton('no'); | ||
84 | }else{ | ||
85 | handleButton('cancel'); | ||
86 | } | ||
87 | } | ||
88 | }); | ||
89 | dlg.closeClick = function(){ | ||
90 | alert('wtf'); | ||
91 | }; | ||
92 | mask = dlg.mask; | ||
93 | dlg.addKeyListener(27, dlg.hide, dlg); | ||
94 | buttons = {}; | ||
95 | buttons['ok'] = dlg.addButton(this.buttonText['ok'], handleButton.createCallback('ok')); | ||
96 | buttons['yes'] = dlg.addButton(this.buttonText['yes'], handleButton.createCallback('yes')); | ||
97 | buttons['no'] = dlg.addButton(this.buttonText['no'], handleButton.createCallback('no')); | ||
98 | buttons['cancel'] = dlg.addButton(this.buttonText['cancel'], handleButton.createCallback('cancel')); | ||
99 | bodyEl = dlg.body.createChild({ | ||
100 | tag:'div', | ||
101 | html:'<span class="ext-mb-text"></span><br /><input type="text" class="ext-mb-input"><textarea class="ext-mb-textarea"></textarea><div class="ext-mb-progress-wrap"><div class="ext-mb-progress"><div class="ext-mb-progress-bar"> </div></div></div>' | ||
102 | }); | ||
103 | msgEl = bodyEl.dom.firstChild; | ||
104 | textboxEl = getEl(bodyEl.dom.childNodes[2]); | ||
105 | textboxEl.enableDisplayMode(); | ||
106 | textboxEl.addKeyListener([10,13], function(){ | ||
107 | if(dlg.isVisible() && opt && opt.buttons){ | ||
108 | if(opt.buttons.ok){ | ||
109 | handleButton('ok'); | ||
110 | }else if(opt.buttons.yes){ | ||
111 | handleButton('yes'); | ||
112 | } | ||
113 | } | ||
114 | }); | ||
115 | textareaEl = getEl(bodyEl.dom.childNodes[3]); | ||
116 | textareaEl.enableDisplayMode(); | ||
117 | progressEl = getEl(bodyEl.dom.childNodes[4]); | ||
118 | progressEl.enableDisplayMode(); | ||
119 | pp = getEl(progressEl.dom.firstChild.firstChild); | ||
120 | } | ||
121 | return dlg; | ||
122 | }, | ||
123 | |||
124 | updateText : function(text){ | ||
125 | if(!dlg.isVisible() && !opt.width){ | ||
126 | dlg.resizeTo(this.maxWidth, 100); // resize first so content is never clipped from previous shows | ||
127 | } | ||
128 | msgEl.innerHTML = text; | ||
129 | var w = Math.max(Math.min(opt.width || msgEl.offsetWidth, this.maxWidth), | ||
130 | Math.max(opt.minWidth || this.minWidth, bwidth)); | ||
131 | if(opt.prompt){ | ||
132 | activeTextEl.setWidth(w); | ||
133 | } | ||
134 | dlg.setContentSize(w, bodyEl.getHeight()); | ||
135 | }, | ||
136 | |||
137 | updateProgress : function(value, text){ | ||
138 | if(text){ | ||
139 | this.updateText(text); | ||
140 | } | ||
141 | pp.setWidth(value*progressEl.dom.firstChild.offsetWidth); | ||
142 | }, | ||
143 | |||
144 | isVisible : function(){ | ||
145 | return dlg && dlg.isVisible(); | ||
146 | }, | ||
147 | |||
148 | hide : function(){ | ||
149 | if(this.isVisible()){ | ||
150 | dlg.hide(); | ||
151 | } | ||
152 | }, | ||
153 | |||
154 | show : function(options){ | ||
155 | var d = this.getDialog(); | ||
156 | opt = options; | ||
157 | d.setTitle(opt.title || ' '); | ||
158 | d.close.setDisplayed(opt.closable !== false); | ||
159 | activeTextEl = textboxEl; | ||
160 | opt.prompt = opt.prompt || (opt.multiline ? true : false) | ||
161 | if(opt.prompt){ | ||
162 | if(opt.multiline){ | ||
163 | textboxEl.hide(); | ||
164 | textareaEl.show(); | ||
165 | textareaEl.setHeight(typeof opt.multiline == 'number' ? | ||
166 | opt.multiline : this.defaultTextHeight); | ||
167 | activeTextEl = textareaEl; | ||
168 | }else{ | ||
169 | textboxEl.show(); | ||
170 | textareaEl.hide(); | ||
171 | } | ||
172 | }else{ | ||
173 | textboxEl.hide(); | ||
174 | textareaEl.hide(); | ||
175 | } | ||
176 | progressEl.setDisplayed(opt.progress === true); | ||
177 | this.updateProgress(0); | ||
178 | activeTextEl.dom.value = opt.value || ''; | ||
179 | if(opt.prompt){ | ||
180 | dlg.setDefaultButton(activeTextEl); | ||
181 | }else{ | ||
182 | var bs = opt.buttons; | ||
183 | var db = null; | ||
184 | if(bs && bs.ok){ | ||
185 | db = buttons['ok']; | ||
186 | }else if(bs && bs.yes){ | ||
187 | db = buttons['yes']; | ||
188 | } | ||
189 | dlg.setDefaultButton(db); | ||
190 | } | ||
191 | bwidth = this.updateButtons(opt.buttons); | ||
192 | this.updateText(opt.msg); | ||
193 | d.modal = opt.modal !== false; | ||
194 | d.mask = opt.modal !== false ? mask : false; | ||
195 | d.animateTarget = null; | ||
196 | d.show(options.animEl); | ||
197 | }, | ||
198 | |||
199 | progress : function(title, msg){ | ||
200 | this.show({ | ||
201 | title : title, | ||
202 | msg : msg, | ||
203 | buttons: false, | ||
204 | progress:true, | ||
205 | closable:false | ||
206 | }); | ||
207 | }, | ||
208 | |||
209 | progressElement : function() { | ||
210 | return progressEl; | ||
211 | }, | ||
212 | |||
213 | opt: function() { | ||
214 | return opt; | ||
215 | }, | ||
216 | |||
217 | alert : function(title, msg, fn, scope){ | ||
218 | this.show({ | ||
219 | title : title, | ||
220 | msg : msg, | ||
221 | buttons: this.OK, | ||
222 | fn: fn, | ||
223 | scope : scope | ||
224 | }); | ||
225 | }, | ||
226 | |||
227 | confirm : function(title, msg, fn, scope){ | ||
228 | this.show({ | ||
229 | title : title, | ||
230 | msg : msg, | ||
231 | buttons: this.YESNO, | ||
232 | fn: fn, | ||
233 | scope : scope | ||
234 | }); | ||
235 | }, | ||
236 | |||
237 | prompt : function(title, msg, fn, scope, multiline){ | ||
238 | this.show({ | ||
239 | title : title, | ||
240 | msg : msg, | ||
241 | buttons: this.OKCANCEL, | ||
242 | fn: fn, | ||
243 | minWidth:250, | ||
244 | scope : scope, | ||
245 | prompt:true, | ||
246 | multiline: multiline | ||
247 | }); | ||
248 | }, | ||
249 | |||
250 | OK : {ok:true}, | ||
251 | YESNO : {yes:true, no:true}, | ||
252 | OKCANCEL : {ok:true, cancel:true}, | ||
253 | YESNOCANCEL : {yes:true, no:true, cancel:true}, | ||
254 | |||
255 | defaultTextHeight:75, | ||
256 | maxWidth : 500, | ||
257 | minWidth : 100, | ||
258 | buttonText : { | ||
259 | ok : 'OK', | ||
260 | cancel : 'Cancel', | ||
261 | yes : 'Yes', | ||
262 | no : 'No' | ||
263 | } | ||
264 | }; | ||
265 | }(); | ||