]>
Commit | Line | Data |
---|---|---|
f0cfe83e AD |
1 | define("dojo/uacss", ["./dom-geometry", "./_base/lang", "./ready", "./sniff", "./_base/window"], |
2 | function(geometry, lang, ready, has, baseWindow){ | |
3 | ||
4 | // module: | |
5 | // dojo/uacss | |
6 | ||
7 | /*===== | |
8 | return { | |
9 | // summary: | |
10 | // Applies pre-set CSS classes to the top-level HTML node, based on: | |
11 | // | |
12 | // - browser (ex: dj_ie) | |
13 | // - browser version (ex: dj_ie6) | |
14 | // - box model (ex: dj_contentBox) | |
15 | // - text direction (ex: dijitRtl) | |
16 | // | |
17 | // In addition, browser, browser version, and box model are | |
18 | // combined with an RTL flag when browser text is RTL. ex: dj_ie-rtl. | |
19 | // | |
20 | // Returns the has() method. | |
21 | }; | |
22 | =====*/ | |
23 | ||
24 | var | |
25 | html = baseWindow.doc.documentElement, | |
26 | ie = has("ie"), | |
27 | opera = has("opera"), | |
28 | maj = Math.floor, | |
29 | ff = has("ff"), | |
30 | boxModel = geometry.boxModel.replace(/-/,''), | |
31 | ||
32 | classes = { | |
33 | "dj_quirks": has("quirks"), | |
34 | ||
35 | // NOTE: Opera not supported by dijit | |
36 | "dj_opera": opera, | |
37 | ||
38 | "dj_khtml": has("khtml"), | |
39 | ||
40 | "dj_webkit": has("webkit"), | |
41 | "dj_safari": has("safari"), | |
42 | "dj_chrome": has("chrome"), | |
43 | ||
44 | "dj_gecko": has("mozilla") | |
45 | }; // no dojo unsupported browsers | |
46 | ||
47 | if(ie){ | |
48 | classes["dj_ie"] = true; | |
49 | classes["dj_ie" + maj(ie)] = true; | |
50 | classes["dj_iequirks"] = has("quirks"); | |
51 | } | |
52 | if(ff){ | |
53 | classes["dj_ff" + maj(ff)] = true; | |
54 | } | |
55 | ||
56 | classes["dj_" + boxModel] = true; | |
57 | ||
58 | // apply browser, browser version, and box model class names | |
59 | var classStr = ""; | |
60 | for(var clz in classes){ | |
61 | if(classes[clz]){ | |
62 | classStr += clz + " "; | |
63 | } | |
64 | } | |
65 | html.className = lang.trim(html.className + " " + classStr); | |
66 | ||
67 | // If RTL mode, then add dj_rtl flag plus repeat existing classes with -rtl extension. | |
68 | // We can't run the code below until the <body> tag has loaded (so we can check for dir=rtl). | |
69 | // priority is 90 to run ahead of parser priority of 100 | |
70 | ready(90, function(){ | |
71 | if(!geometry.isBodyLtr()){ | |
72 | var rtlClassStr = "dj_rtl dijitRtl " + classStr.replace(/ /g, "-rtl "); | |
73 | html.className = lang.trim(html.className + " " + rtlClassStr + "dj_rtl dijitRtl " + classStr.replace(/ /g, "-rtl ")); | |
74 | } | |
75 | }); | |
76 | return has; | |
77 | }); |