mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 22:58:14 +00:00
[Mobile] Add classes to body
Add classes describing device characteristics to the body of the current document at start-up. Refactor device matchers out of the mct-device directive for reuse and consistency here. https://github.com/nasa/openmctweb/issues/169
This commit is contained in:
@ -22,31 +22,10 @@
|
||||
/*global define,Promise*/
|
||||
|
||||
define(
|
||||
function () {
|
||||
['./DeviceMatchers'],
|
||||
function (DeviceMatchers) {
|
||||
'use strict';
|
||||
|
||||
var DEVICE_MATCHERS = {
|
||||
mobile: function (agentService) {
|
||||
return agentService.isMobile();
|
||||
},
|
||||
phone: function (agentService) {
|
||||
return agentService.isPhone();
|
||||
},
|
||||
tablet: function (agentService) {
|
||||
return agentService.isTablet();
|
||||
},
|
||||
desktop: function (agentService) {
|
||||
return !agentService.isMobile();
|
||||
},
|
||||
portrait: function (agentService) {
|
||||
return agentService.isPortrait();
|
||||
},
|
||||
landscape: function (agentService) {
|
||||
return agentService.isLandscape();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The `mct-device` directive, when applied as an attribute,
|
||||
* only includes the element when the device being used matches
|
||||
@ -77,7 +56,7 @@ define(
|
||||
function deviceMatches(tokens) {
|
||||
tokens = tokens || "";
|
||||
return tokens.split(" ").every(function (token) {
|
||||
var fn = DEVICE_MATCHERS[token];
|
||||
var fn = DeviceMatchers[token];
|
||||
return fn && fn(agentService);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user