Caret/js/ui/theme.js
2015-04-11 19:11:42 -07:00

46 lines
No EOL
1.1 KiB
JavaScript

define([
"command",
"settings!theme",
"util/template!templates/theme.css",
"util/dom2"
], function(command, Settings, inflate) {
var element = document.querySelector("#caret-theme");
var config = {
isDark: false,
cssText: "",
cssClass: "ace-caret"
};
var updateTheme = function(c) {
var theme = Settings.get("theme");
config.isDark = theme.dark;
var data = { blocks: [] };
theme.styles[""] = theme.editor;
for (var selector in theme.styles) {
var block = {
selector: selector.split(/,\s*/).map(function(s) { return ".ace-caret " + s }).join(", "),
styles: []
};
var definition = theme.styles[selector];
for (var prop in definition) {
block.styles.push({
prop: prop,
value: definition[prop]
});
}
data.blocks.push(block);
}
var css = inflate.getHTML("templates/theme.css", data);
element.innerHTML = css;
}
ace.define("ace/theme/caret", [], function() {
return config;
});
updateTheme();
command.on("init:restart", updateTheme);
})