mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 00:50:28 +00:00
Fallback to a list of default themes
Avoids the situation where an empty wiki uses the vanilla theme unless you explicitly apply a different theme.
This commit is contained in:
parent
6be7e2c30e
commit
eb41ca578d
@ -13,7 +13,10 @@ Manages themes and styling.
|
||||
"use strict";
|
||||
|
||||
var THEME_PLUGIN_TITLE = "$:/theme", // This tiddler contains the title of the current theme plugin
|
||||
DEFAULT_THEME_PLUGIN = "$:/themes/tiddlywiki/vanilla";
|
||||
DEFAULT_THEME_PLUGINS = [
|
||||
"$:/themes/tiddlywiki/snowwhite",
|
||||
"$:/themes/tiddlywiki/vanilla"
|
||||
];
|
||||
|
||||
function ThemeManager(wiki) {
|
||||
this.wiki = wiki;
|
||||
@ -32,7 +35,12 @@ function ThemeManager(wiki) {
|
||||
|
||||
ThemeManager.prototype.switchTheme = function() {
|
||||
// Get the name of the current theme
|
||||
var themePluginTitle = this.wiki.getTiddlerText(THEME_PLUGIN_TITLE,DEFAULT_THEME_PLUGIN);
|
||||
var themePluginTitle = this.wiki.getTiddlerText(THEME_PLUGIN_TITLE);
|
||||
// If it doesn't exist, then fallback to one of the default themes
|
||||
var index = 0;
|
||||
while(!this.wiki.getTiddler(themePluginTitle) && index < DEFAULT_THEME_PLUGINS.length) {
|
||||
themePluginTitle = DEFAULT_THEME_PLUGINS[index++];
|
||||
}
|
||||
// Accumulate the titles of the plugins that we need to load
|
||||
var themePlugins = [],
|
||||
self = this,
|
||||
|
Loading…
Reference in New Issue
Block a user