Diffstat (limited to 'backend/php/src/setup/setup_library/xPandMenu.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | backend/php/src/setup/setup_library/xPandMenu.js | 273 |
1 files changed, 273 insertions, 0 deletions
diff --git a/backend/php/src/setup/setup_library/xPandMenu.js b/backend/php/src/setup/setup_library/xPandMenu.js new file mode 100644 index 0000000..7f9a632 --- a/dev/null +++ b/backend/php/src/setup/setup_library/xPandMenu.js | |||
@@ -0,0 +1,273 @@ | |||
1 | /******************************** | ||
2 | * xPandMenu MULTI-LEVEL class | ||
3 | ********************************* | ||
4 | * Javascript file | ||
5 | ********************************* | ||
6 | * Patrick Brosset | ||
7 | * patrickbrosset@gmail.com | ||
8 | ********************************* | ||
9 | * 02/2005 | ||
10 | *********************************/ | ||
11 | |||
12 | |||
13 | // Show / hide a sub-menu | ||
14 | function xMenuShowHide(obj) | ||
15 | { | ||
16 | |||
17 | if(obj.style.display == 'none'){ | ||
18 | obj.style.display = 'block'; | ||
19 | }else{ | ||
20 | obj.style.display = 'none'; | ||
21 | } | ||
22 | |||
23 | } | ||
24 | |||
25 | |||
26 | // Toggle expanded / collapsed versions of items' images | ||
27 | function xSwapImg(imgDiv,srcImg,srcAltImg){ | ||
28 | |||
29 | /* Update by Christian Vallee <cv@valtechnologie.com> | ||
30 | ==> No need to specify absolute URL for images anymore, this feature will find it on its own */ | ||
31 | |||
32 | // looking for the images' root URL based on the current image | ||
33 | var str = imgDiv.src; | ||
34 | var pos = str.search(srcImg); | ||
35 | // if the URL root wasn't found using the first image, try with the alternative one | ||
36 | if ( pos == -1 ) { pos = str.search(srcAltImg); } | ||
37 | // extracting the URL root | ||
38 | var root = str.substring(0,pos); | ||
39 | // adding the root the image path supplied | ||
40 | srcImg = root.concat(srcImg); | ||
41 | srcAltImg = root.concat(srcAltImg); | ||
42 | |||
43 | /* End Update */ | ||
44 | |||
45 | if(imgDiv.src == srcImg){ | ||
46 | imgDiv.src = srcAltImg; | ||
47 | }else{ | ||
48 | imgDiv.src = srcImg; | ||
49 | } | ||
50 | |||
51 | } | ||
52 | |||
53 | |||
54 | // Restore the menu state when the page loads | ||
55 | function xRestoreState() | ||
56 | { | ||
57 | //restore list state | ||
58 | var name = "xMenuState"; | ||
59 | var start = document.cookie.indexOf(name+"="); | ||
60 | if(start != -1) | ||
61 | { | ||
62 | var len = start+name.length+1; | ||
63 | if ((!start) && (name != document.cookie.substring(0,name.length))) return null; | ||
64 | if (start == -1) return null; | ||
65 | var end = document.cookie.indexOf(";",len); | ||
66 | if (end == -1) end = document.cookie.length; | ||
67 | var value = unescape(document.cookie.substring(len,end)); | ||
68 | var values = value.split("|"); | ||
69 | for(i=0;i<values.length-1;i++) | ||
70 | { | ||
71 | var couple = values[i].split(":"); | ||
72 | document.getElementById(couple[0]).style.display = couple[1]; | ||
73 | } | ||
74 | } | ||
75 | //restore img state | ||
76 | name = "xMenuStateImg"; | ||
77 | start = document.cookie.indexOf(name+"="); | ||
78 | if(start != -1) | ||
79 | { | ||
80 | var len = start+name.length+1; | ||
81 | if ((!start) && (name != document.cookie.substring(0,name.length))) return null; | ||
82 | if (start == -1) return null; | ||
83 | var end = document.cookie.indexOf(";",len); | ||
84 | if (end == -1) end = document.cookie.length; | ||
85 | var value = unescape(document.cookie.substring(len,end)); | ||
86 | var values = value.split("[]"); | ||
87 | for(i=0;i<values.length-1;i++) | ||
88 | { | ||
89 | var couple = values[i].split(">>"); | ||
90 | var imgs = couple[1].split(","); | ||
91 | for(var il in imgs) | ||
92 | { | ||
93 | document.getElementById(imgs[il]).src = couple[0]; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | |||
99 | //Get the ids of all open nodes | ||
100 | function getOpenNodes() | ||
101 | { | ||
102 | value = new Array(); | ||
103 | var myLists = document.getElementsByTagName("UL"); | ||
104 | for(i=0;i<myLists.length;i++) | ||
105 | { | ||
106 | if(myLists[i].className == "Xtree" && myLists[i].style.display == "block")value += myLists[i].id + "-"; | ||
107 | } | ||
108 | return value; | ||
109 | } | ||
110 | |||
111 | // Save the menu state when the page unloads | ||
112 | function xSaveState() | ||
113 | { | ||
114 | //Save list state | ||
115 | var value = ""; | ||
116 | var myLists = document.getElementsByTagName("UL"); | ||
117 | for(i=0;i<myLists.length;i++) | ||
118 | { | ||
119 | if(myLists[i].className == "Xtree")value += myLists[i].id + ":" + myLists[i].style.display + "|"; | ||
120 | } | ||
121 | document.cookie = "xMenuState=" + escape(value) + ";"; | ||
122 | //save img state | ||
123 | value = new Array(); | ||
124 | myLists = document.getElementsByTagName("IMG"); | ||
125 | for(i=0;i<myLists.length;i++) | ||
126 | { | ||
127 | if(myLists[i].id.substring(0,4) == "Ximg") | ||
128 | { | ||
129 | if(value[myLists[i].src]){value[myLists[i].src] += "," + myLists[i].id;} | ||
130 | else{value[myLists[i].src] = myLists[i].id;} | ||
131 | } | ||
132 | } | ||
133 | var str = ""; | ||
134 | for(var imgPath in value) | ||
135 | { | ||
136 | str += imgPath + ">>" + value[imgPath] + "[]"; | ||
137 | } | ||
138 | var cook = str.substring(0,str.length-2); | ||
139 | document.cookie = "xMenuStateImg=" + escape(cook) + ";"; | ||
140 | } | ||
141 | |||
142 | function createRequestObject() | ||
143 | { | ||
144 | var ro; | ||
145 | if (window.XMLHttpRequest) | ||
146 | { | ||
147 | ro = new XMLHttpRequest(); | ||
148 | } | ||
149 | else | ||
150 | { | ||
151 | ro = new ActiveXObject('MSXML2.XMLHTTP.3.0'); | ||
152 | } | ||
153 | return ro; | ||
154 | } | ||
155 | |||
156 | var http = createRequestObject(); | ||
157 | |||
158 | function refTree(offset, limit, objectName) | ||
159 | { | ||
160 | http = createRequestObject(); | ||
161 | var req = './rpc.php?action=Refresh&offset='+offset+'&limit='+limit+'&objectname='+objectName; | ||
162 | http.open('get', req); | ||
163 | http.onreadystatechange = handleResponse; | ||
164 | http.send(null); | ||
165 | } | ||
166 | |||
167 | function sndReq(action, openNodes, objectName, objectId, currentNode, attributes, anchor) | ||
168 | { | ||
169 | |||
170 | |||
171 | http = createRequestObject(); | ||
172 | var req = './rpc.php?action='+action+'&opennodes='+openNodes+'&objectname='+objectName+'&objectid='+objectId+'¤tnode='+currentNode+'&anchor='+anchor; | ||
173 | if (action == "Add") | ||
174 | { | ||
175 | for (i=0; i<attributes.length; i++) | ||
176 | { | ||
177 | thisId = attributes[i]; | ||
178 | var thisInput = document.getElementById(thisId); | ||
179 | if (thisInput != null) | ||
180 | { | ||
181 | if (thisInput.type == "checkbox") | ||
182 | { | ||
183 | if (thisInput.checked) | ||
184 | { | ||
185 | req += "&" + thisId + "=" + thisInput.value; | ||
186 | } | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | req += "&" + thisId + "=" + thisInput.value; | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | else if (action == "Update") | ||
196 | { | ||
197 | for (i=0; i<attributes.length; i++) | ||
198 | { | ||
199 | thisId = attributes[i]; | ||
200 | var thisInput = document.getElementById(thisId+"_"+objectId); | ||
201 | if (thisInput.type == "checkbox") | ||
202 | { | ||
203 | if (thisInput.checked) | ||
204 | { | ||
205 | req += "&" + thisId + "=" + thisInput.value; | ||
206 | } | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | req += "&" + thisId + "=" + thisInput.value; | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | http.open('get', req); | ||
215 | http.onreadystatechange = handleResponse; | ||
216 | http.send(null); | ||
217 | } | ||
218 | |||
219 | function handleResponse() | ||
220 | { | ||
221 | if(http.readyState == 4) | ||
222 | { | ||
223 | var response = http.responseText; | ||
224 | document.getElementById('container').innerHTML = response; | ||
225 | } | ||
226 | } | ||
227 | |||
228 | function expandAll() | ||
229 | { | ||
230 | var myLists = document.getElementsByTagName("UL"); | ||
231 | for(i=0;i<myLists.length;i++) | ||
232 | { | ||
233 | if(myLists[i].className == "Xtree" && myLists[i].style.display == "none")myLists[i].style.display = "block"; | ||
234 | } | ||
235 | myLists = document.getElementsByTagName("IMG"); | ||
236 | for(i=0;i<myLists.length;i++) | ||
237 | { | ||
238 | if(myLists[i].id.substring(0,4) == "Ximg") | ||
239 | { | ||
240 | myLists[i].src = "setup_images/folderopen.gif"; | ||
241 | } | ||
242 | } | ||
243 | } | ||
244 | |||
245 | function collapseAll() | ||
246 | { | ||
247 | var myLists = document.getElementsByTagName("UL"); | ||
248 | for(i=0;i<myLists.length;i++) | ||
249 | { | ||
250 | if(myLists[i].className == "Xtree" && myLists[i].style.display == "block")myLists[i].style.display = "none"; | ||
251 | } | ||
252 | myLists = document.getElementsByTagName("IMG"); | ||
253 | for(i=0;i<myLists.length;i++) | ||
254 | { | ||
255 | if(myLists[i].id.substring(0,4) == "Ximg") | ||
256 | { | ||
257 | myLists[i].src = "setup_images/folderclose.gif"; | ||
258 | } | ||
259 | } | ||
260 | } | ||
261 | |||
262 | function ToggleElementVisibility(elementId) | ||
263 | { | ||
264 | var element = document.getElementById(elementId); | ||
265 | if (element.style.display != 'none') | ||
266 | { | ||
267 | element.style.display = 'none'; | ||
268 | } | ||
269 | else | ||
270 | { | ||
271 | element.style.display = 'inline'; | ||
272 | } | ||
273 | } \ No newline at end of file | ||