package kitchen sink demo and include it in the build
This commit is contained in:
parent
930c995c64
commit
63785dc92f
5 changed files with 122 additions and 8 deletions
30
demo/demo.js
30
demo/demo.js
|
|
@ -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;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue