-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathlayout.engine.js
126 lines (119 loc) · 2.41 KB
/
layout.engine.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*!
* Layout Engine v0.10.3
*
* Copyright (c) 2015-2019 Matt Stow
* http://mattstow.com
* Licensed under the MIT license
*/
;var layoutEngine = (function() {
var html = document.documentElement,
style = html.style,
vendor = ' vendor-',
edge = 'edge',
ie = 'ie',
khtml = 'khtml',
mozilla = 'mozilla',
opera = 'opera',
webkit = 'webkit',
browser = ' browser-',
android = 'android',
chrome = 'chrome',
safari = 'safari',
iosSafari = safari + '-ios',
wiiu = 'wiiu',
cssClass = vendor,
jsObject;
// Edge and IE
if ('msScrollLimit' in style || 'behavior' in style) {
if ('msTextSizeAdjust' in style && !('msFlex' in style)) {
cssClass += edge;
jsObject = {
vendor: edge
};
}
else {
cssClass += ie + vendor + ie;
jsObject = {
vendor: ie
};
if ('msImeAlign' in style) {
cssClass += '-11';
jsObject.version = 11;
}
else if ('msUserSelect' in style) {
cssClass += '-10';
jsObject.version = 10;
}
else if ('fill' in style) {
cssClass += '-9';
jsObject.version = 9;
}
else if ('widows' in style) {
cssClass += '-8';
jsObject.version = 8;
}
else {
cssClass += '-7';
jsObject.version = 7;
}
}
}
// Mozilla
else if ('MozAppearance' in style) {
cssClass += mozilla;
jsObject = {
vendor: mozilla
}
}
// WebKit
else if ('WebkitAppearance' in style) {
cssClass += webkit;
var ua = navigator.userAgent;
jsObject = {
vendor: webkit
};
if (!!window.chrome || ua.indexOf('OPR') >= 0 || ua.indexOf('wv') >= 0) {
cssClass += browser + chrome;
jsObject.browser = chrome;
}
else if ('webkitDashboardRegion' in style) {
cssClass += browser + safari;
jsObject.browser = safari;
}
else if ('webkitOverflowScrolling' in style) {
cssClass += browser + iosSafari;
jsObject.browser = iosSafari;
}
else if (ua.indexOf('Android') >= 0) {
cssClass += browser + android;
jsObject.browser = android;
}
else if (!!window.wiiu) {
cssClass += browser + wiiu;
jsObject.browser = wiiu;
}
}
// Opera
else if ('OLink' in style || !!window.opera) {
cssClass += opera;
jsObject = {
vendor: opera,
};
if ('OMiniFold' in style) {
cssClass += '-mini';
jsObject.browser = 'mini';
}
}
// KHTML
else if ('KhtmlUserInput' in style) {
cssClass += khtml;
jsObject = {
vendor: khtml
};
}
else {
return false;
}
html.className += cssClass;
return jsObject;
})();