source: main/trunk/model-sites-dev/mozarts-laptop/collect/digital-music-stand/script/musicstand-util.js@ 30446

Last change on this file since 30446 was 30446, checked in by davidb, 8 years ago

... and the example collection (initial version)

  • Property svn:executable set to *
File size: 6.6 KB
Line 
1
2var orientation = "portrait";
3
4var httpdocument = gs.xsltParams.library_name + "?a=d&ed=1&book=off&site="+gs.xsltParams.site_name+"&c="+gs.cgiParams["c"];
5
6
7function getElement(elem_str)
8{
9 var elem;
10 if (document.all) {
11 elem = eval("document.all."+elem_str);
12 }
13 else if (document.getElementById) {
14 elem = document.getElementById(elem_str);
15 }
16 else if (document.layers) {
17 elem = eval("document."+elem_str);
18 }
19
20 return elem;
21}
22
23
24function setVisibility(id,val)
25{
26 if (document.layers) {
27 if (val == 'hidden') { val = 'hide' }
28 if (val == 'visible') { val = 'show' }
29 document.layers[id].visibility = val;
30 }
31 else if (document.all) {
32 document.all[id].style.visibility = val;
33 }
34 else if (document.getElementById) {
35 document.getElementById(id).style.visibility = val;
36 }
37}
38
39function getVisibility(id)
40{
41 var val;
42
43 if (document.layers) {
44 val = document.layers[id].visibility;
45 if (val == 'hide') { val = 'hidden' }
46 if (val == 'show') { val = 'visible' }
47 }
48 else if (document.all) {
49 val = document.all[id].style.visibility;
50 }
51 else if (document.getElementById) {
52 val = document.getElementById(id).style.visibility;
53 }
54}
55
56function makeVisible(id)
57{
58 setVisibility(id,'visible');
59}
60
61function makeInvisible(id)
62{
63 setVisibility(id,'hidden');
64}
65
66function toggleVisibility(id)
67{
68 var curr_vista = getVisibility(id);
69 var new_vista = (curr_vista == 'hidden') ? 'visible' : 'hidden'
70 setVisibility(id,new_vista);
71}
72
73
74function setDisplay(id,val)
75{
76 if (document.layers) {
77 document.layers[id].display = val;
78 }
79 else if (document.all) {
80 document.all[id].style.display = val;
81 }
82 else if (document.getElementById) {
83 document.getElementById(id).style.display = val;
84 }
85}
86
87function getDisplay(id)
88{
89 var val;
90
91 if (document.layers) {
92 val = document.layers[id].display;
93 }
94 else if (document.all) {
95 val = document.all[id].style.display;
96 }
97 else if (document.getElementById) {
98 val = document.getElementById(id).style.display;
99 }
100}
101
102function displayBlock(id)
103{
104 setDisplay(id,'block');
105}
106
107function displayInline(id)
108{
109 setDisplay(id,'inline');
110}
111
112function displayNone(id)
113{
114 setDisplay(id,'none');
115}
116
117function toggleDisplay(id)
118{
119 var curr_vista = getDisplay(id);
120 var new_vista = (curr_vista == 'block') ? 'none' : 'block'
121 displayBlock(id,new_vista);
122}
123
124
125
126function getAbsoluteLeft(el) {
127 xPos = el.offsetLeft;
128 tempEl = el.offsetParent;
129 while (tempEl != null) {
130 xPos += tempEl.offsetLeft;
131 tempEl = tempEl.offsetParent;
132 }
133 return xPos;
134}
135
136function getAbsoluteTop(el) {
137 yPos = el.offsetTop;
138 tempEl = el.offsetParent;
139 while (tempEl != null) {
140 yPos += tempEl.offsetTop;
141 tempEl = tempEl.offsetParent;
142 }
143 return yPos;
144}
145
146
147
148function get_rect_xl(el)
149{
150 var xl;
151
152 if (document.all) {
153 xl = el.style.pixelLeft;
154 }
155 else if (document.getElementById) {
156 xl = parseInt(el.style.left);
157 }
158 else if (document.layers) {
159 xl = el.left;
160 }
161
162 return xl;
163}
164
165function get_rect_yt(el)
166{
167 var yt;
168
169 if (document.all) {
170 yt = el.style.pixelTop;
171 }
172 else if (document.getElementById) {
173 yt = parseInt(el.style.top);
174 }
175 else if (document.layers) {
176 yt = el.top;
177 }
178
179 return yt;
180}
181
182function getRectWidth(el)
183{
184 if (typeof(el) == "string") {
185 el = getElement(el);
186 }
187
188 var width;
189
190 if (document.all) {
191 width = parseInt(el.style.width);
192 }
193 else if (document.getElementById) {
194 width = parseInt(el.style.width);
195 }
196 else if (document.layers) {
197 width = el.clip.width;
198 }
199
200 return width;
201}
202
203function getRectHeight(el)
204{
205 if (typeof(el) == "string") {
206 el = getElement(el);
207 }
208
209
210 var height;
211
212 if (document.all) {
213 height = parseInt(el.style.height);
214 }
215 else if (document.getElementById) {
216 height = parseInt(el.style.height);
217 }
218 else if (document.layers) {
219 height = el.clip.height;
220 }
221
222 return height;
223}
224
225function get_rect_xr(el)
226{
227 var xr;
228
229 xr = get_rect_xl(el) + get_rect_width(el) -1;
230
231 return xr;
232}
233
234function get_rect_yb(el)
235{
236 var yb;
237
238 yb = get_rect_yt(el) + get_rect_height(el) -1;
239
240 return yb;
241}
242
243
244function set_rect_xl(el,xl)
245{
246 if (document.all) {
247 el.style.pixelLeft = xl;
248 }
249 else if (document.getElementById) {
250 el.style.left = xl + "px";
251 }
252 else if (document.layers) {
253 el.left = xl + "px";
254 }
255}
256
257function set_rect_yt(el,yt)
258{
259 if (document.all) {
260 el.style.pixelTop = yt;
261 }
262 else if (document.getElementById) {
263 el.style.top = yt + "px";
264 }
265 else if (document.layers) {
266 el.top = yt + "px";
267 }
268}
269
270function set_rect_width(el,width)
271{
272 if (document.all) {
273 el.style.width = width;
274 }
275 else if (document.getElementById) {
276 el.style.width = width;
277 }
278 else if (document.layers) {
279 el.width = width;
280 }
281}
282
283function set_rect_height(el,height)
284{
285 if (document.all) {
286 el.style.height = height;
287 }
288 else if (document.getElementById) {
289 el.style.height = height;
290 }
291 else if (document.layers) {
292 el.height = height;
293 }
294}
295
296
297
298function getMouseCoords(evt)
299{
300 var mouse = new Object();
301
302 if (!evt) var evt = window.event;
303
304 if (evt.pageX || evt.pageY) {
305 mouse.x = evt.pageX;
306 mouse.y = evt.pageY;
307 }
308 else if (evt.clientX || evt.clientY) {
309 mouse.x = evt.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
310 mouse.y = evt.clientY + document.body.scrollTop + document.documentElement.scrollTop;
311
312 }
313
314 return mouse;
315}
316
317
318function clip_to_rect(mouse, xl,yt,xr,yb)
319{
320 if (mouse.x < xl) {
321 mouse.x = xl;
322 }
323 else if (mouse.x > xr) {
324 mouse.x = xr;
325 }
326
327 if (mouse.y < yt) {
328 mouse.y = yt;
329 }
330 else if (mouse.y > yb) {
331 mouse.y = yb;
332 }
333}
334
335function draw_graphic(gr,x_org,y_org)
336{
337 if (document.all) {
338 gr.style.pixelLeft = x_org;
339 gr.style.pixelTop = y_org;
340 gr.style.visibility = 'visible';
341 }
342 else if (document.getElementById) {
343 gr.style.left = x_org + 'px';
344 gr.style.top = y_org + 'px';
345 gr.style.visibility = 'visible';
346 }
347 else if (document.layers) {
348 gr.left = x_org;
349 gr.top = y_org;
350 gr.visibility = 'show';
351 }
352}
353
354function hide_graphic(gr)
355{
356 if (document.all) {
357 gr.style.visibility = 'hidden';
358 }
359 else if (document.getElementById) {
360 gr.style.visibility = 'hidden';
361 }
362 else if (document.layers) {
363 gr.visibility = 'hide';
364 }
365}
366
Note: See TracBrowser for help on using the repository browser.