1318 |
alexandre_ |
1 |
/*
|
|
|
2 |
Copyright (c) 2004-2006, The Dojo Foundation
|
|
|
3 |
All Rights Reserved.
|
|
|
4 |
|
|
|
5 |
Licensed under the Academic Free License version 2.1 or above OR the
|
|
|
6 |
modified BSD license. For more information on Dojo licensing, see:
|
|
|
7 |
|
|
|
8 |
http://dojotoolkit.org/community/licensing.shtml
|
|
|
9 |
*/
|
|
|
10 |
|
1422 |
alexandre_ |
11 |
|
|
|
12 |
|
1318 |
alexandre_ |
13 |
dojo.provide("dojo.html.display");
|
|
|
14 |
dojo.require("dojo.html.style");
|
|
|
15 |
dojo.html._toggle = function (node, tester, setter) {
|
|
|
16 |
node = dojo.byId(node);
|
|
|
17 |
setter(node, !tester(node));
|
|
|
18 |
return tester(node);
|
|
|
19 |
};
|
|
|
20 |
dojo.html.show = function (node) {
|
|
|
21 |
node = dojo.byId(node);
|
|
|
22 |
if (dojo.html.getStyleProperty(node, "display") == "none") {
|
|
|
23 |
dojo.html.setStyle(node, "display", (node.dojoDisplayCache || ""));
|
|
|
24 |
node.dojoDisplayCache = undefined;
|
|
|
25 |
}
|
|
|
26 |
};
|
|
|
27 |
dojo.html.hide = function (node) {
|
|
|
28 |
node = dojo.byId(node);
|
|
|
29 |
if (typeof node["dojoDisplayCache"] == "undefined") {
|
|
|
30 |
var d = dojo.html.getStyleProperty(node, "display");
|
|
|
31 |
if (d != "none") {
|
|
|
32 |
node.dojoDisplayCache = d;
|
|
|
33 |
}
|
|
|
34 |
}
|
|
|
35 |
dojo.html.setStyle(node, "display", "none");
|
|
|
36 |
};
|
|
|
37 |
dojo.html.setShowing = function (node, showing) {
|
|
|
38 |
dojo.html[(showing ? "show" : "hide")](node);
|
|
|
39 |
};
|
|
|
40 |
dojo.html.isShowing = function (node) {
|
|
|
41 |
return (dojo.html.getStyleProperty(node, "display") != "none");
|
|
|
42 |
};
|
|
|
43 |
dojo.html.toggleShowing = function (node) {
|
|
|
44 |
return dojo.html._toggle(node, dojo.html.isShowing, dojo.html.setShowing);
|
|
|
45 |
};
|
|
|
46 |
dojo.html.displayMap = {tr:"", td:"", th:"", img:"inline", span:"inline", input:"inline", button:"inline"};
|
|
|
47 |
dojo.html.suggestDisplayByTagName = function (node) {
|
|
|
48 |
node = dojo.byId(node);
|
|
|
49 |
if (node && node.tagName) {
|
|
|
50 |
var tag = node.tagName.toLowerCase();
|
|
|
51 |
return (tag in dojo.html.displayMap ? dojo.html.displayMap[tag] : "block");
|
|
|
52 |
}
|
|
|
53 |
};
|
|
|
54 |
dojo.html.setDisplay = function (node, display) {
|
|
|
55 |
dojo.html.setStyle(node, "display", ((display instanceof String || typeof display == "string") ? display : (display ? dojo.html.suggestDisplayByTagName(node) : "none")));
|
|
|
56 |
};
|
|
|
57 |
dojo.html.isDisplayed = function (node) {
|
|
|
58 |
return (dojo.html.getComputedStyle(node, "display") != "none");
|
|
|
59 |
};
|
|
|
60 |
dojo.html.toggleDisplay = function (node) {
|
|
|
61 |
return dojo.html._toggle(node, dojo.html.isDisplayed, dojo.html.setDisplay);
|
|
|
62 |
};
|
|
|
63 |
dojo.html.setVisibility = function (node, visibility) {
|
|
|
64 |
dojo.html.setStyle(node, "visibility", ((visibility instanceof String || typeof visibility == "string") ? visibility : (visibility ? "visible" : "hidden")));
|
|
|
65 |
};
|
|
|
66 |
dojo.html.isVisible = function (node) {
|
|
|
67 |
return (dojo.html.getComputedStyle(node, "visibility") != "hidden");
|
|
|
68 |
};
|
|
|
69 |
dojo.html.toggleVisibility = function (node) {
|
|
|
70 |
return dojo.html._toggle(node, dojo.html.isVisible, dojo.html.setVisibility);
|
|
|
71 |
};
|
|
|
72 |
dojo.html.setOpacity = function (node, opacity, dontFixOpacity) {
|
|
|
73 |
node = dojo.byId(node);
|
|
|
74 |
var h = dojo.render.html;
|
|
|
75 |
if (!dontFixOpacity) {
|
|
|
76 |
if (opacity >= 1) {
|
|
|
77 |
if (h.ie) {
|
|
|
78 |
dojo.html.clearOpacity(node);
|
|
|
79 |
return;
|
|
|
80 |
} else {
|
|
|
81 |
opacity = 0.999999;
|
|
|
82 |
}
|
|
|
83 |
} else {
|
|
|
84 |
if (opacity < 0) {
|
|
|
85 |
opacity = 0;
|
|
|
86 |
}
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
if (h.ie) {
|
|
|
90 |
if (node.nodeName.toLowerCase() == "tr") {
|
|
|
91 |
var tds = node.getElementsByTagName("td");
|
|
|
92 |
for (var x = 0; x < tds.length; x++) {
|
|
|
93 |
tds[x].style.filter = "Alpha(Opacity=" + opacity * 100 + ")";
|
|
|
94 |
}
|
|
|
95 |
}
|
|
|
96 |
node.style.filter = "Alpha(Opacity=" + opacity * 100 + ")";
|
|
|
97 |
} else {
|
|
|
98 |
if (h.moz) {
|
|
|
99 |
node.style.opacity = opacity;
|
|
|
100 |
node.style.MozOpacity = opacity;
|
|
|
101 |
} else {
|
|
|
102 |
if (h.safari) {
|
|
|
103 |
node.style.opacity = opacity;
|
|
|
104 |
node.style.KhtmlOpacity = opacity;
|
|
|
105 |
} else {
|
|
|
106 |
node.style.opacity = opacity;
|
|
|
107 |
}
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
};
|
|
|
111 |
dojo.html.clearOpacity = function (node) {
|
|
|
112 |
node = dojo.byId(node);
|
|
|
113 |
var ns = node.style;
|
|
|
114 |
var h = dojo.render.html;
|
|
|
115 |
if (h.ie) {
|
|
|
116 |
try {
|
|
|
117 |
if (node.filters && node.filters.alpha) {
|
|
|
118 |
ns.filter = "";
|
|
|
119 |
}
|
|
|
120 |
}
|
|
|
121 |
catch (e) {
|
|
|
122 |
}
|
|
|
123 |
} else {
|
|
|
124 |
if (h.moz) {
|
|
|
125 |
ns.opacity = 1;
|
|
|
126 |
ns.MozOpacity = 1;
|
|
|
127 |
} else {
|
|
|
128 |
if (h.safari) {
|
|
|
129 |
ns.opacity = 1;
|
|
|
130 |
ns.KhtmlOpacity = 1;
|
|
|
131 |
} else {
|
|
|
132 |
ns.opacity = 1;
|
|
|
133 |
}
|
|
|
134 |
}
|
|
|
135 |
}
|
|
|
136 |
};
|
|
|
137 |
dojo.html.getOpacity = function (node) {
|
|
|
138 |
node = dojo.byId(node);
|
|
|
139 |
var h = dojo.render.html;
|
|
|
140 |
if (h.ie) {
|
|
|
141 |
var opac = (node.filters && node.filters.alpha && typeof node.filters.alpha.opacity == "number" ? node.filters.alpha.opacity : 100) / 100;
|
|
|
142 |
} else {
|
|
|
143 |
var opac = node.style.opacity || node.style.MozOpacity || node.style.KhtmlOpacity || 1;
|
|
|
144 |
}
|
|
|
145 |
return opac >= 0.999999 ? 1 : Number(opac);
|
|
|
146 |
};
|
|
|
147 |
|