/
ua__dom.js
44 lines (42 loc) · 1.84 KB
/
ua__dom.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
/**
* @module ua
* @description Use ua module to provide user agent features by modifiers and update some on orient change
*/
modules.define('ua', ['i-bem__dom'], function(provide, bemDom, ua) {
provide(/** @exports */bemDom.declBlock(this.name,
{
onSetMod : {
'js' : {
'inited' : function() {
this
.setMod('platform',
ua.ios? 'ios' :
ua.android? 'android' :
ua.bada? 'bada' :
ua.wp? 'wp' :
ua.opera? 'opera' :
'other')
.setMod('browser',
ua.opera? 'opera' :
ua.chrome? 'chrome' :
'')
.setMod('ios', ua.ios? ua.ios.charAt(0) : '')
.setMod('android', ua.android? ua.android.charAt(0) : '')
.setMod('ios-subversion', ua.ios? ua.ios.match(/(\d\.\d)/)[1].replace('.', '') : '')
.setMod('screen-size', ua.screenSize)
.setMod('svg', ua.svg? 'yes' : 'no')
.setMod('orient', ua.landscape? 'landscape' : 'portrait')
.bindToWin(
'orientchange',
function(e, data) {
ua.width = data.width;
ua.height = data.height;
ua.landscape = data.landscape;
this.setMod('orient', data.landscape? 'landscape' : 'portrait');
});
}
}
}
},
ua));
});