This repository has been archived by the owner on Sep 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
State.js
103 lines (85 loc) · 2.68 KB
/
State.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
'use strict';
define([
'dojo/_base/declare',
'underscore'
],
function(declare, _) {
var State = declare(null, {
constructor: function(data) {
this.savedState = _.defaults({}, data, {
provider: 'coral',
region: 'Global',
period: 'ANN',
layer: 'people',
variable: 'PF',
coralVisibility: false,
mangroveVisibility: false,
});
},
getState: function() {
return this.savedState;
},
setRegion: function(region) {
return this.clone({
region: region
});
},
getProvider: function() {
return this.savedState.provider;
},
setProvider: function(provider) {
return this.clone({
provider: provider
});
},
getRegion: function() {
return this.savedState.region;
},
setPeriod: function(period) {
return this.clone({
period: period
});
},
getPeriod: function() {
return this.savedState.period;
},
setLayer: function(layer) {
return this.clone({
layer: layer
});
},
getLayer: function() {
return this.savedState.layer;
},
setVariable: function(variable) {
return this.clone({
variable: variable
});
},
getVariable: function() {
return this.savedState.variable;
},
setCoralVisibility: function(coralVisibility) {
return this.clone({
coralVisibility: coralVisibility
});
},
getCoralVisibility: function() {
return this.savedState.coralVisibility;
},
setMangroveVisibility: function(mangroveVisibility) {
return this.clone({
mangroveVisibility: mangroveVisibility
});
},
getMangroveVisibility: function() {
return this.savedState.mangroveVisibility;
},
// Return new State combined with `data`.
clone: function(data) {
return new State(_.assign({}, this.getState(), data));
}
});
return State;
}
);