trc-client-core
Version:
The core of the TRC Client
59 lines (53 loc) • 1.52 kB
JavaScript
/*global navigator, document*/
var DeviceMixin = {
initialize: function () {
var a = navigator.userAgent;
function browser (str) {
return (a.indexOf(str) !== -1);
}
if (browser('ipad')) {
this.browser = 'Mobile Safari';
this.device = 'iPad';
}
else if (browser('iPhone')) {
this.browser = 'Mobile Safari';
this.device = 'iPhone';
}
else if (browser('Android')) {
this.browser = 'Mobile Chrome';
this.device = 'Android';
}
else if (browser('Chrome')) {
this.browser = 'Chrome';
}
else if (browser('Safari')) {
this.browser = 'Safari';
}
else if (browser('MSIE')) {
this.browser = 'MSIE';
}
else if (browser('Firefox')) {
this.browser = 'Firefox';
}
else {
this.browser = a;
}
},
/* From Modernizr */
animationEnd: function (){
var t;
var el = document.createElement('fakeelement');
var transitions = {
'animation': 'animationend',
'-o-animation': 'oAnimationEnd',
'-moz-animation': 'animationend',
'-webkit-animation': 'webkitAnimationEnd'
};
for(t in transitions){
if( el.style[t] !== undefined ){
return transitions[t];
}
}
}
};
module.exports = DeviceMixin;