mirror of
https://github.com/linuxserver/core.git
synced 2026-02-20 05:07:19 +08:00
fix prompt after theme change
This commit is contained in:
parent
8ff0cb3886
commit
6a83374e8d
@ -1,3 +1,4 @@
|
||||
/*global apf*/
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
main.consumes = [
|
||||
@ -95,7 +96,7 @@ define(function(require, exports, module) {
|
||||
var themeCounter = 100;
|
||||
var lastTheme, grpSyntax, grpThemes;
|
||||
|
||||
var theme;
|
||||
var currentTheme;
|
||||
var skin = settings.get("user/general/@skin");
|
||||
var defaultThemes = {
|
||||
"light": "ace/theme/cloud9_day",
|
||||
@ -117,7 +118,7 @@ define(function(require, exports, module) {
|
||||
} else {
|
||||
require([defaultThemes[skin]], function() {}); // Preload Themes
|
||||
}
|
||||
handle.__defineGetter__("theme", function() { return theme; });
|
||||
handle.__defineGetter__("theme", function() { return currentTheme; });
|
||||
|
||||
function addCorner(ace) {
|
||||
if (isMinimal)
|
||||
@ -144,7 +145,7 @@ define(function(require, exports, module) {
|
||||
|
||||
function setTheme(path, isPreview, fromServer, $err) {
|
||||
// Get Theme or wait for theme to load
|
||||
theme = fromServer;
|
||||
var theme = fromServer;
|
||||
if (/custom_themes/.test(path)) {
|
||||
theme = themes[path];
|
||||
if (!theme) return;
|
||||
@ -157,6 +158,7 @@ define(function(require, exports, module) {
|
||||
}
|
||||
|
||||
if (!isPreview) {
|
||||
currentTheme = theme;
|
||||
if (settings.get("user/ace/@theme") != path) {
|
||||
settings.set("user/ace/@theme", path);
|
||||
|
||||
@ -551,13 +553,23 @@ define(function(require, exports, module) {
|
||||
themeLoaded = {};
|
||||
lastTheme = null;
|
||||
setTheme(settings.get("user/ace/@theme"));
|
||||
|
||||
if (e.type !== "ace"
|
||||
&& settings.get("user/ace/@theme") != defaultThemes[e.oldTheme])
|
||||
return false;
|
||||
});
|
||||
|
||||
layout.on("validateThemeChange", function(e) {
|
||||
if (e.type !== "ace") {
|
||||
var themeName = settings.get("user/ace/@theme");
|
||||
if (themeName == defaultThemes[e.oldTheme])
|
||||
return;
|
||||
var style = currentTheme && (currentTheme.isDark ? "dark" : "light");
|
||||
if (e.theme.indexOf(style) == -1)
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
layout.on("themeDefaults", function(e) {
|
||||
var style = currentTheme && (currentTheme.isDark ? "dark" : "light");
|
||||
if (e.force == false && e.theme.indexOf(style) != -1)
|
||||
return;
|
||||
if (e.type != "ace")
|
||||
handle.setTheme(defaultThemes[e.theme]);
|
||||
}, handle);
|
||||
@ -1900,7 +1912,7 @@ define(function(require, exports, module) {
|
||||
|
||||
handle.on("themeChange", function(e) {
|
||||
ace.setTheme(e.path);
|
||||
changeTheme();
|
||||
changeTheme(e);
|
||||
|
||||
emit("themeChange", e);
|
||||
}, plugin);
|
||||
@ -2119,11 +2131,11 @@ define(function(require, exports, module) {
|
||||
ace.renderer.animateScrolling(initialScroll);
|
||||
}
|
||||
|
||||
function changeTheme() {
|
||||
function changeTheme(e) {
|
||||
if (immutableSkin || !currentSession)
|
||||
return;
|
||||
|
||||
var theme = handle.theme;
|
||||
var theme = e && e.theme || handle.theme;
|
||||
if (handle.theme && currentSession.cssClass != theme.cssClass) {
|
||||
var tab = currentDocument.tab;
|
||||
var html = plugin.aml.$int;
|
||||
|
||||
@ -179,19 +179,21 @@ define(function(require, exports, module) {
|
||||
changeTheme();
|
||||
}
|
||||
function changeTheme() {
|
||||
emit("eachTheme", { changed: true });
|
||||
setGeckoMask();
|
||||
|
||||
var auto = emit("themeChange", {
|
||||
var event = {
|
||||
theme: theme,
|
||||
oldTheme: oldTheme,
|
||||
type: type
|
||||
}) !== false;
|
||||
};
|
||||
emit("eachTheme", { changed: true });
|
||||
emit("themeChange", event);
|
||||
setGeckoMask();
|
||||
|
||||
var auto = emit("validateThemeChange", event) !== false;
|
||||
|
||||
if (!oldTheme || noquestion) return;
|
||||
|
||||
if (auto)
|
||||
return emit("themeDefaults", { theme: theme, type: type });
|
||||
return emit("themeDefaults", { theme: theme, type: type, force: false });
|
||||
|
||||
question.show("Set default colors?",
|
||||
"Would you like to reset colors to their default value?",
|
||||
@ -215,7 +217,7 @@ define(function(require, exports, module) {
|
||||
"Click Yes to change the theme or No to keep the current theme.",
|
||||
function() { // yes
|
||||
ignoreTheme = true;
|
||||
var theme = { "dark": "flat-dark", "light": "flat-light" }[kind];
|
||||
var theme = { "dark": "dark", "light": "flat-light" }[kind];
|
||||
settings.set("user/general/@skin", theme);
|
||||
updateTheme(false, type);
|
||||
ignoreTheme = false;
|
||||
|
||||
@ -46,12 +46,12 @@ define(function(require, exports, module) {
|
||||
var handleEmit = handle.getEmitter();
|
||||
|
||||
var defaults = {
|
||||
"flat-light": ["#e0e5e7", "#333333", "#aebabf", false],
|
||||
"flat-dark": ["#003a58", "#FFFFFF", "#225477", true],
|
||||
"light": ["#eef7ff", "#333333", "#89c1ff", false],
|
||||
"light-gray": ["#eef7ff", "#333333", "#89c1ff", false],
|
||||
"dark": ["#003a58", "#FFFFFF", "#225477", true],
|
||||
"dark-gray": ["#003a58", "#FFFFFF", "#225477", true]
|
||||
"flat-light": ["#e0e5e7", "#333333", "#aebabf"],
|
||||
"flat-dark": ["#003a58", "#FFFFFF", "#225477"],
|
||||
"light": ["#eef7ff", "#333333", "#89c1ff"],
|
||||
"light-gray": ["#eef7ff", "#333333", "#89c1ff"],
|
||||
"dark": ["#003a58", "#FFFFFF", "#225477"],
|
||||
"dark-gray": ["#003a58", "#FFFFFF", "#225477"]
|
||||
};
|
||||
|
||||
handle.on("load", function() {
|
||||
@ -138,12 +138,17 @@ define(function(require, exports, module) {
|
||||
|
||||
settings.on("user/output", setSettings);
|
||||
|
||||
layout.on("themeChange", function(e) {
|
||||
var colors = defaults[e.oldTheme];
|
||||
if (!colors) return;
|
||||
if (!(settings.get("user/output/@backgroundColor") == colors[0] &&
|
||||
settings.get("user/output/@foregroundColor") == colors[1] &&
|
||||
settings.get("user/output/@selectionColor") == colors[2]))
|
||||
layout.on("validateThemeChange", function(e) {
|
||||
var oldColors = defaults[e.oldTheme];
|
||||
var newColors = defaults[e.theme];
|
||||
var colors = [
|
||||
settings.get("user/output/@backgroundColor"),
|
||||
settings.get("user/output/@foregroundColor"),
|
||||
settings.get("user/output/@selectionColor"),
|
||||
];
|
||||
var matchesOldTheme = oldColors && oldColors.toString() == colors.toString();
|
||||
var matchesNewTheme = newColors && newColors.toString() == colors.toString();
|
||||
if (!matchesOldTheme && !matchesNewTheme)
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
@ -261,13 +261,20 @@ define(function(require, exports, module) {
|
||||
|
||||
layout.on("themeChange", function(e) {
|
||||
setSettings();
|
||||
|
||||
var colors = defaults[e.oldTheme];
|
||||
if (!colors) return;
|
||||
if (!(settings.get("user/terminal/@backgroundColor") == colors[0] &&
|
||||
settings.get("user/terminal/@foregroundColor") == colors[1] &&
|
||||
settings.get("user/terminal/@selectionColor") == colors[2] &&
|
||||
settings.get("user/terminal/@antialiasedfonts") == colors[3]))
|
||||
});
|
||||
|
||||
layout.on("validateThemeChange", function(e) {
|
||||
var oldColors = defaults[e.oldTheme];
|
||||
var newColors = defaults[e.theme];
|
||||
var colors = [
|
||||
settings.get("user/terminal/@backgroundColor"),
|
||||
settings.get("user/terminal/@foregroundColor"),
|
||||
settings.get("user/terminal/@selectionColor"),
|
||||
settings.get("user/terminal/@antialiasedfonts"),
|
||||
];
|
||||
var matchesOldTheme = oldColors && oldColors.toString() == colors.toString();
|
||||
var matchesNewTheme = newColors && newColors.toString() == colors.toString();
|
||||
if (!matchesOldTheme && !matchesNewTheme)
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user