source: Dev/branches/rest-dojo-ui/client/dojo/uacss.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

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