package kitchen sink demo and include it in the build

This commit is contained in:
Fabian Jakobs 2011-08-03 16:47:43 +02:00
commit 63785dc92f
5 changed files with 122 additions and 8 deletions

View file

@ -351,7 +351,14 @@ exports.launch = function(env) {
});
bindDropdown("theme", function(value) {
env.editor.setTheme(value);
if (require.packaged) {
loadTheme(value, function() {
env.editor.setTheme(value);
});
}
else {
env.editor.setTheme(value);
}
});
bindDropdown("keybinding", function(value) {
@ -702,4 +709,25 @@ exports.launch = function(env) {
}
};
var themes = {};
function loadTheme(name, callback) {
if (themes[name])
return;
themes[name] = 1;
var base = name.split("/").pop();
var fileName = "src/theme-" + base + ".js";
loadScriptFile(fileName, callback)
}
function loadScriptFile(path, callback) {
var head = document.getElementsByTagName('head')[0];
var s = document.createElement('script');
s.src = path;
head.appendChild(s);
s.onload = callback;
}
});