forked from angular/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview-utils.js
More file actions
55 lines (45 loc) · 1.05 KB
/
Copy pathview-utils.js
File metadata and controls
55 lines (45 loc) · 1.05 KB
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
angular.
module('ViewUtils', ['ngMaterial']).
service('ViewUtils', ViewUtilsService);
ViewUtilsService.$inject = ['$mdMedia', '$mdSidenav'];
function ViewUtilsService($mdMedia, $mdSidenav) {
this.closeSidenav = closeSidenav;
this.getFlex = getFlex;
this.getValueForSize = getValueForSize;
this.media = $mdMedia;
this.openSidenav = openSidenav;
var flexMap = {
toc: {
'gt-lg': '20',
'lg': '25',
'md': '33'
},
search: {
'gt-lg': '20'
}
};
function closeSidenav(id) {
$mdSidenav(id).close();
}
function getFlex(componentId) {
var flex;
if (flexMap.hasOwnProperty(componentId)) {
var queriesMap = flexMap[componentId];
flex = getValueForSize(queriesMap);
}
return flex;
}
function getValueForSize(queriesMap, defaultVal) {
var val = defaultVal;
Object.keys(queriesMap).some(function(q) {
if ($mdMedia(q)) {
val= queriesMap[q];
return true;
}
});
return val;
}
function openSidenav(id) {
$mdSidenav(id).open();
}
}