From c563f15e93e5a30533f0ef54504649d30b59f034 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 30 Oct 2013 18:07:25 +0400 Subject: [PATCH] use ext/themelist.js in kitchen-sink demo --- demo/kitchen-sink/demo.js | 11 +++- demo/kitchen-sink/util.js | 2 +- kitchen-sink.html | 35 +------------ lib/ace/ext/themelist.js | 74 +++++++++++++++++---------- lib/ace/ext/themelist_utils/themes.js | 36 ------------- 5 files changed, 59 insertions(+), 99 deletions(-) delete mode 100644 lib/ace/ext/themelist_utils/themes.js diff --git a/demo/kitchen-sink/demo.js b/demo/kitchen-sink/demo.js index 3a1c6d63..9880d33e 100644 --- a/demo/kitchen-sink/demo.js +++ b/demo/kitchen-sink/demo.js @@ -65,6 +65,7 @@ var whitespace = require("ace/ext/whitespace"); var doclist = require("./doclist"); var modelist = require("ace/ext/modelist"); +var themelist = require("ace/ext/themelist"); var layout = require("./layout"); var TokenTooltip = require("./token_tooltip").TokenTooltip; var util = require("./util"); @@ -370,6 +371,12 @@ function updateUIEditorOptions() { saveOption(behavioursEl, editor.getBehavioursEnabled()); } +themelist.themes.forEach(function(x){ x.value = x.theme }); +fillDropdown(themeEl, { + Bright: themelist.themes.filter(function(x){return !x.isDark}), + Dark: themelist.themes.filter(function(x){return x.isDark}), +}); + event.addListener(themeEl, "mouseover", function(e){ themeEl.desiredValue = e.target.value; if (!themeEl.$timer) @@ -383,7 +390,7 @@ event.addListener(themeEl, "mouseout", function(e){ }); themeEl.updateTheme = function(){ - env.split.setTheme(themeEl.desiredValue || themeEl.selectedValue); + env.split.setTheme((themeEl.desiredValue || themeEl.selectedValue)); themeEl.$timer = null; }; @@ -588,4 +595,4 @@ env.editor.setOptions({ enableSnippets: true }); -}); \ No newline at end of file +}); diff --git a/demo/kitchen-sink/util.js b/demo/kitchen-sink/util.js index 3b00c1ce..c4b74f38 100644 --- a/demo/kitchen-sink/util.js +++ b/demo/kitchen-sink/util.js @@ -218,7 +218,7 @@ function optgroup(values) { return values.map(function(item) { if (typeof item == "string") item = {name: item, caption: item}; - return elt("option", {value: item.name}, item.caption || item.desc); + return elt("option", {value: item.value || item.name}, item.caption || item.desc); }); } diff --git a/kitchen-sink.html b/kitchen-sink.html index 2c5c518b..c149c484 100644 --- a/kitchen-sink.html +++ b/kitchen-sink.html @@ -63,40 +63,7 @@ diff --git a/lib/ace/ext/themelist.js b/lib/ace/ext/themelist.js index 1032f72c..420a5d6e 100644 --- a/lib/ace/ext/themelist.js +++ b/lib/ace/ext/themelist.js @@ -44,35 +44,57 @@ define(function(require, exports, module) { "use strict"; +var themeData = [ + ["Chrome" ], + ["Clouds" ], + ["Crimson Editor" ], + ["Dawn" ], + ["Dreamweaver" ], + ["Eclipse" ], + ["GitHub" ], + ["Solarized Light"], + ["TextMate" ], + ["Tomorrow" ], + ["XCode" ], + ["Kuroir"], + ["KatzenMilch"], + ["Ambiance" ,"ambiance" , "dark"], + ["Chaos" ,"chaos" , "dark"], + ["Clouds Midnight" ,"clouds_midnight" , "dark"], + ["Cobalt" ,"cobalt" , "dark"], + ["idle Fingers" ,"idle_fingers" , "dark"], + ["krTheme" ,"kr_theme" , "dark"], + ["Merbivore" ,"merbivore" , "dark"], + ["Merbivore Soft" ,"merbivore_soft" , "dark"], + ["Mono Industrial" ,"mono_industrial" , "dark"], + ["Monokai" ,"monokai" , "dark"], + ["Pastel on dark" ,"pastel_on_dark" , "dark"], + ["Solarized Dark" ,"solarized_dark" , "dark"], + ["Terminal" ,"terminal" , "dark"], + ["Tomorrow Night" ,"tomorrow_night" , "dark"], + ["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"], + ["Tomorrow Night Bright","tomorrow_night_bright" , "dark"], + ["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"], + ["Twilight" ,"twilight" , "dark"], + ["Vibrant Ink" ,"vibrant_ink" , "dark"], +] + + +exports.themesByName = {}; + /** * An array containing information about available themes. */ -module.exports.themes = require('ace/ext/themelist_utils/themes').themes; - -/** - * Creates a theme description. - * @param {string} name The file name of the theme. - * @returns {ThemeDescription} Returns a theme description object which has - * three properties: the name gives the filename, the desc gives a menu - * friendly name, and the theme gives the string to set the theme with - * `setTheme` - */ -module.exports.ThemeDescription = function(name) { - this.name = name; - this.desc = name.split('_' - ).map( - function(namePart) { - return namePart[0].toUpperCase() + namePart.slice(1); - } - ).join(' '); - this.theme = "ace/theme/" + name; -}; - -module.exports.themesByName = {}; - -module.exports.themes = module.exports.themes.map(function(name) { - module.exports.themesByName[name] = new module.exports.ThemeDescription(name); - return module.exports.themesByName[name]; +exports.themes = themeData.map(function(data) { + var name = data[1] || data[0].replace(/ /g, "_").toLowerCase(); + var theme = { + caption: data[0], + theme: "ace/theme/" + name, + isDark: data[2] == "dark", + name: name + }; + exports.themesByName[name] = theme; + return theme; }); }); diff --git a/lib/ace/ext/themelist_utils/themes.js b/lib/ace/ext/themelist_utils/themes.js deleted file mode 100644 index 2e490c9f..00000000 --- a/lib/ace/ext/themelist_utils/themes.js +++ /dev/null @@ -1,36 +0,0 @@ -define(function(require, exports, module) { - -module.exports.themes = [ - "ambiance", - "chaos", - "chrome", - "clouds", - "clouds_midnight", - "cobalt", - "crimson_editor", - "dawn", - "dreamweaver", - "eclipse", - "github", - "idle_fingers", - "kr_theme", - "merbivore", - "merbivore_soft", - "mono_industrial", - "monokai", - "pastel_on_dark", - "solarized_dark", - "solarized_light", - "terminal", - "textmate", - "tomorrow", - "tomorrow_night", - "tomorrow_night_blue", - "tomorrow_night_bright", - "tomorrow_night_eighties", - "twilight", - "vibrant_ink", - "xcode" -]; - -}); \ No newline at end of file