]>
Commit | Line | Data |
---|---|---|
2f01fe57 AD |
1 | /* |
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. | |
3 | Available via Academic Free License >= 2.1 OR the modified BSD license. | |
4 | see: http://dojotoolkit.org/license for details | |
5 | */ | |
6 | ||
7 | ||
a089699c AD |
8 | if(!dojo._hasResource["dojo.uacss"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
9 | dojo._hasResource["dojo.uacss"] = true; | |
2f01fe57 | 10 | dojo.provide("dojo.uacss"); |
a089699c | 11 | |
2f01fe57 | 12 | (function(){ |
a089699c AD |
13 | // summary: |
14 | // Applies pre-set CSS classes to the top-level HTML node, based on: | |
15 | // - browser (ex: dj_ie) | |
16 | // - browser version (ex: dj_ie6) | |
17 | // - box model (ex: dj_contentBox) | |
18 | // - text direction (ex: dijitRtl) | |
19 | // | |
20 | // In addition, browser, browser version, and box model are | |
21 | // combined with an RTL flag when browser text is RTL. ex: dj_ie-rtl. | |
22 | ||
23 | var d = dojo, | |
24 | html = d.doc.documentElement, | |
25 | ie = d.isIE, | |
26 | opera = d.isOpera, | |
27 | maj = Math.floor, | |
28 | ff = d.isFF, | |
29 | boxModel = d.boxModel.replace(/-/,''), | |
30 | ||
31 | classes = { | |
32 | dj_ie: ie, | |
33 | dj_ie6: maj(ie) == 6, | |
34 | dj_ie7: maj(ie) == 7, | |
35 | dj_ie8: maj(ie) == 8, | |
36 | dj_quirks: d.isQuirks, | |
37 | dj_iequirks: ie && d.isQuirks, | |
38 | ||
39 | // NOTE: Opera not supported by dijit | |
40 | dj_opera: opera, | |
41 | ||
42 | dj_khtml: d.isKhtml, | |
43 | ||
44 | dj_webkit: d.isWebKit, | |
45 | dj_safari: d.isSafari, | |
46 | dj_chrome: d.isChrome, | |
47 | ||
48 | dj_gecko: d.isMozilla, | |
49 | dj_ff3: maj(ff) == 3 | |
50 | }; // no dojo unsupported browsers | |
51 | ||
52 | classes["dj_" + boxModel] = true; | |
53 | ||
54 | // apply browser, browser version, and box model class names | |
55 | var classStr = ""; | |
56 | for(var clz in classes){ | |
57 | if(classes[clz]){ | |
58 | classStr += clz + " "; | |
59 | } | |
60 | } | |
61 | html.className = d.trim(html.className + " " + classStr); | |
62 | ||
63 | // If RTL mode, then add dj_rtl flag plus repeat existing classes with -rtl extension. | |
64 | // We can't run the code below until the <body> tag has loaded (so we can check for dir=rtl). | |
65 | // Unshift() is to run sniff code before the parser. | |
66 | dojo._loaders.unshift(function(){ | |
67 | if(!dojo._isBodyLtr()){ | |
68 | var rtlClassStr = "dj_rtl dijitRtl " + classStr.replace(/ /g, "-rtl ") | |
69 | html.className = d.trim(html.className + " " + rtlClassStr); | |
70 | } | |
71 | }); | |
2f01fe57 | 72 | })(); |
a089699c | 73 | |
2f01fe57 | 74 | } |