forked from adobe/brackets
-
Notifications
You must be signed in to change notification settings - Fork 279
/
StartupState.js
51 lines (41 loc) · 1.28 KB
/
StartupState.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
/* jslint newcap:true */
define(function (require, exports, module) {
"use strict";
var Map = require("thirdparty/immutable").Map;
var _ui;
var _project;
var _url;
/**
* UI state (fontSize, theme) that comes in from the hosting
* app on startup.
*/
exports.ui = function(property) {
return _ui ? _ui.get(property) : null;
};
exports.ui.init = function(state) {
_ui = Map(state);
};
/**
* Project state (e.g., root, file to open first) that comes in
* from the hosting app on startup.
*/
exports.project = function(property) {
return _project ? _project.get(property) : null;
};
exports.project.init = function(state) {
_project = Map(state);
};
/**
* Depending on where Bramble is hosted, this helps you get a useful
* url prefix. Most callers will want url("base") to get http://bramble.com/dist/
* for constructing URLs to things in src/* or dist/*
*/
exports.url = function(property) {
return _url ? _url.get(property) : null;
};
_url = Map({
origin: window.location.origin,
host: window.location.host,
base: window.location.origin + window.location.pathname.replace(/\/index.html*$/, "/")
});
});