blob: a7e52c7dd7667f48cfe4e66818e523a1c2fe02c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
Element.hidden = function() {
for (var i = 0; i < arguments.length; i++) {
var element = $(arguments[i]);
if (element.style.display != 'none') {
return false;
}
}
return true;
}
function lazyToggle(container, url, options) {
options = ({method: 'get'}).extend(options);
if (Element.hidden(container)) {
Element.show(container);
if (! $(container).lazy_loaded) {
new Ajax.Updater(container, url, {method: 'get'});
$(container).lazy_loaded = true;
}
if (options.link) {
var newHTML = options.link.getAttribute('shownhtml');
if (newHTML) {
options.link.setAttribute('hiddenhtml', options.link.innerHTML);
options.link.innerHTML = newHTML;
}
}
} else {
Element.hide(container);
if (options.link) {
var newHTML = options.link.getAttribute('hiddenhtml');
if (newHTML) {
options.link.innerHTML = newHTML;
}
}
}
}
function toggle(container, options) {
if (Element.hidden(container)) {
Element.show(container);
if (options && options.link) {
var newHTML = options.link.getAttribute('shownhtml');
if (newHTML) {
options.link.setAttribute('hiddenhtml', options.link.innerHTML);
options.link.innerHTML = newHTML;
}
}
} else {
Element.hide(container);
if (options && options.link) {
var newHTML = options.link.getAttribute('hiddenhtml');
if (newHTML) {
options.link.setAttribute('shownhtml', options.link.innerHTML);
options.link.innerHTML = newHTML;
}
}
}
}
|