Caret/js/main.js
2013-09-13 15:57:57 -07:00

39 lines
No EOL
894 B
JavaScript

require([
"command",
"settings!user",
"keys",
"sessions",
"menus",
"palette"
], function(command, Settings) {
var frame = chrome.app.window.current();
//store window dimensions on resize
frame.onBoundsChanged.addListener(function() {
var bounds = frame.getBounds();
chrome.storage.local.set({bounds: bounds});
});
command.on("app:exit", function() {
frame.close();
});
var setTheme = function() {
var user = Settings.get("user");
var themes = {
"dark": "css/caret-dark.css",
"light": "css/caret.css"
};
var theme = user.uiTheme || "light";
var url = themes[theme];
document.find("#theme").setAttribute("href", url);
}
//the settings manager may also fire init:restart to re-init components after startup
command.fire("init:startup");
command.on("init:restart", setTheme);
setTheme();
});