[mobile] add phone/tablet to app class list
This commit is contained in:
parent
ec6c451f28
commit
00e1fd2f43
|
@ -1,8 +1,9 @@
|
|||
|
||||
import React from 'react';
|
||||
import { f7 } from 'framework7-react';
|
||||
import { Dom7, Device } from 'framework7'
|
||||
|
||||
class Device {
|
||||
class WrapDevice {
|
||||
constructor(){
|
||||
const ua = navigator.userAgent,
|
||||
isMobile = /Mobile(\/|\s|;)/.test(ua);
|
||||
|
@ -16,6 +17,16 @@ class Device {
|
|||
(/MSIE 10/.test(ua) && /; Touch/.test(ua)));
|
||||
}
|
||||
|
||||
initDom() {
|
||||
const $$ = Dom7;
|
||||
if ( this.sailfish ) {
|
||||
$$('html').addClass('sailfish');
|
||||
}
|
||||
|
||||
$$('html').addClass(this.phone ? 'phone' : 'tablet');
|
||||
// $$(window).on('resize', _.bind(this.onWindowResize, this));
|
||||
}
|
||||
|
||||
get phone() {
|
||||
return this.isPhone
|
||||
}
|
||||
|
@ -37,5 +48,5 @@ class Device {
|
|||
}
|
||||
}
|
||||
|
||||
const device = new Device();
|
||||
const device = new WrapDevice();
|
||||
export {device as Device};
|
||||
|
|
|
@ -8,6 +8,7 @@ import '../../../../common/Gateway.js';
|
|||
import '../../../../common/main/lib/util/utils.js';
|
||||
import Notifications from '../../../../common/mobile/utils/notifications.js'
|
||||
import MainController from '../controller/Main';
|
||||
import {Device} from '../../../../common/mobile/utils/device'
|
||||
|
||||
export default class extends React.Component {
|
||||
constructor() {
|
||||
|
@ -82,6 +83,7 @@ export default class extends React.Component {
|
|||
componentDidMount() {
|
||||
this.$f7ready((f7) => {
|
||||
// Call F7 APIs here
|
||||
Device.initDom();
|
||||
});
|
||||
|
||||
this.refs.mainController.initSdk();
|
||||
|
|
|
@ -8,6 +8,7 @@ import '../../../../common/Gateway.js';
|
|||
import '../../../../common/main/lib/util/utils.js';
|
||||
import Notifications from '../../../../common/mobile/utils/notifications.js'
|
||||
import {MainController} from '../controller/Main';
|
||||
import {Device} from '../../../../common/mobile/utils/device'
|
||||
|
||||
export default class extends React.Component {
|
||||
constructor() {
|
||||
|
@ -38,7 +39,7 @@ export default class extends React.Component {
|
|||
|
||||
componentDidMount() {
|
||||
this.$f7ready((f7) => {
|
||||
// Call F7 APIs here
|
||||
Device.initDom();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue