forked from CartoDB/cdb-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nav.js
34 lines (28 loc) · 1.03 KB
/
nav.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
// Takes care of changing the view on the main area of the app window
// View names are string:
// * one word for simple views (e.g., tables)
// * two words separated by a dot for tabbed views (e.g. table.columns means the column tab subview of a single table view)
// Currently only those two levels are supported, but isCurrentView is prepared to support an arbitrary number of levels.
cdbmanager.service("nav", function () {
let self = this;
this.current = null;
// Better use this instead of setting current directly.
// In the future it's quite possible that changing the current view will be
// a more complex step.
this.setCurrentView = function (viewName) {
self.current = viewName;
};
this.isCurrentView = function (viewName) {
if (!self.current) {
return false;
}
viewName = viewName.split(".");
let currentSplit = self.current.split(".");
for (let i = 0; i < viewName.length; i++) {
if (viewName[i] != currentSplit[i]) {
return false;
}
}
return true;
};
});