-
Notifications
You must be signed in to change notification settings - Fork 28
/
uacss.js
49 lines (43 loc) · 1.06 KB
/
uacss.js
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
/**
* Applies pre-set CSS classes to the top-level HTML node, based on:
*
* - browser: `d-webkit`, `d-safari`, `d-chrome`, `d-ff`, `d-edge`, `d-ie`, `d-ios`, `d-android`
* - browser version (ex: `d-ie-9`, `d-ff-26`)
*
* Returns the `has()` method.
*
* @module delite/uacss
*/
define(["ibm-decor/sniff", "requirejs-domready/domReady"], function (has, domReady) {
var ie = has("ie"),
maj = Math.floor,
ff = has("ff"),
classes = {
"d-edge": has("edge"),
"d-webkit": has("webkit"),
"d-safari": has("safari"),
"d-chrome": has("chrome"),
"d-ios": has("ios"),
"d-android": has("android"),
"d-mac": has("mac")
};
if (ie) {
classes["d-ie"] = true;
classes["d-ie-" + maj(ie)] = true;
}
if (ff) {
classes["d-ff"] = true;
classes["d-ff-" + maj(ff)] = true;
}
// Apply browser and browser version class names.
var classStr = "";
for (var clz in classes) {
if (classes[clz]) {
classStr += clz + " ";
}
}
domReady(function () {
document.body.className = (document.body.className + " " + classStr).trim();
});
return has;
});