Diffstat (limited to 'frontend/gamma/js/Clipperz/DOM.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/DOM.js | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/DOM.js b/frontend/gamma/js/Clipperz/DOM.js new file mode 100644 index 0000000..40720d8 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/DOM.js | |||
@@ -0,0 +1,139 @@ | |||
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.DOM) == 'undefined') { Clipperz.DOM = {}; } | ||
31 | |||
32 | Clipperz.DOM.VERSION = "0.1"; | ||
33 | Clipperz.DOM.NAME = "Clipperz.DOM"; | ||
34 | |||
35 | MochiKit.Base.update(Clipperz.DOM, { | ||
36 | |||
37 | //------------------------------------------------------------------------- | ||
38 | |||
39 | '__repr__': function () { | ||
40 | return "[" + this.NAME + " " + this.VERSION + "]"; | ||
41 | }, | ||
42 | |||
43 | //------------------------------------------------------------------------- | ||
44 | |||
45 | 'toString': function () { | ||
46 | return this.__repr__(); | ||
47 | }, | ||
48 | |||
49 | //------------------------------------------------------------------------- | ||
50 | |||
51 | 'selectOptionMatchingValue': function (aSelectElement, aValue, shouldUseCaseInsensitiveTest) { | ||
52 | var selectedOptionIndex; | ||
53 | var i, c; | ||
54 | |||
55 | selectedOptionIndex = -1; | ||
56 | |||
57 | c = aSelectElement.options.length; | ||
58 | for (i=0; (i<c) && (selectedOptionIndex == -1); i++) { | ||
59 | if (shouldUseCaseInsensitiveTest == true) { | ||
60 | if (aSelectElement.options[i].value.toLowerCase() == aValue.toLowerCase()) { | ||
61 | selectedOptionIndex = i; | ||
62 | } | ||
63 | } else { | ||
64 | if (aSelectElement.options[i].value == aValue) { | ||
65 | selectedOptionIndex = i; | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | |||
70 | if (selectedOptionIndex != -1) { | ||
71 | aSelectElement.selectedIndex = selectedOptionIndex; | ||
72 | } | ||
73 | }, | ||
74 | |||
75 | //------------------------------------------------------------------------- | ||
76 | |||
77 | 'setFormContents': function(aNode, someValues) { | ||
78 | var node; | ||
79 | var values; | ||
80 | var i, c; | ||
81 | |||
82 | values = {}; | ||
83 | c = someValues[0].length; | ||
84 | for (i=0; i<c; i++) { | ||
85 | values[someValues[0][i]] = someValues[1][i]; | ||
86 | } | ||
87 | |||
88 | // var m = MochiKit.Base; | ||
89 | // var self = MochiKit.DOM; | ||
90 | if (typeof(aNode) == "undefined" || aNode === null) { | ||
91 | node = MochiKit.DOM._document.body; | ||
92 | } else { | ||
93 | node = MochiKit.DOM.getElement(aNode); | ||
94 | } | ||
95 | |||
96 | MochiKit.Base.nodeWalk(node, function(aNode) { | ||
97 | var result; | ||
98 | var name; | ||
99 | |||
100 | result = null; | ||
101 | name = aNode.name; | ||
102 | if (MochiKit.Base.isNotEmpty(name) && (typeof(values[name]) != 'undefined')) { | ||
103 | var tagName; | ||
104 | |||
105 | tagName = aNode.tagName.toUpperCase(); | ||
106 | if (tagName === "INPUT" && (aNode.type == "radio" || aNode.type == "checkbox")) { | ||
107 | aNode.checked = values[name]; | ||
108 | } else if (tagName === "SELECT") { | ||
109 | if (aNode.type == "select-one") { | ||
110 | Clipperz.DOM.selectOptionMatchingValue(aNode, values[name]); | ||
111 | } else { //aNode.type == "select-multiple" | ||
112 | MochiKit.Logging.logWarning("### unhandled Select.type = 'select-multiple' condition"); | ||
113 | } | ||
114 | } else if (tagName === "FORM" || tagName === "P" || tagName === "SPAN" || tagName === "DIV") { | ||
115 | result = aNode.childNodes; | ||
116 | } else { | ||
117 | aNode.value = values[name] | ||
118 | } | ||
119 | } else { | ||
120 | result = aNode.childNodes; | ||
121 | } | ||
122 | |||
123 | return result; | ||
124 | }); | ||
125 | }, | ||
126 | |||
127 | //------------------------------------------------------------------------- | ||
128 | |||
129 | 'get': MochiKit.DOM.getElement, | ||
130 | |||
131 | //------------------------------------------------------------------------- | ||
132 | |||
133 | 'Helper': Clipperz.YUI.DomHelper, | ||
134 | |||
135 | //------------------------------------------------------------------------- | ||
136 | __syntaxFix__: "syntax fix" | ||
137 | |||
138 | }); | ||
139 | |||