Skip to content

Commit

Permalink
Fix setting the CTFd theme color (CTFd#1482)
Browse files Browse the repository at this point in the history
* Fix setting the CTFd theme color in the Admin Panel by properly getting the current theme header value
  • Loading branch information
ColdHeat authored Jun 8, 2020
1 parent 8b6e91f commit aad3d21
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
34 changes: 20 additions & 14 deletions CTFd/themes/admin/assets/js/pages/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,25 @@ function insertTimezones(target) {
}

$(() => {
CodeMirror.fromTextArea(document.getElementById("theme-header"), {
lineNumbers: true,
lineWrapping: true,
mode: "htmlmixed",
htmlMode: true
});
const theme_header_editor = CodeMirror.fromTextArea(
document.getElementById("theme-header"),
{
lineNumbers: true,
lineWrapping: true,
mode: "htmlmixed",
htmlMode: true
}
);

CodeMirror.fromTextArea(document.getElementById("theme-footer"), {
lineNumbers: true,
lineWrapping: true,
mode: "htmlmixed",
htmlMode: true
});
const theme_footer_editor = CodeMirror.fromTextArea(
document.getElementById("theme-footer"),
{
lineNumbers: true,
lineWrapping: true,
mode: "htmlmixed",
htmlMode: true
}
);

insertTimezones($("#start-timezone"));
insertTimezones($("#end-timezone"));
Expand All @@ -256,7 +262,7 @@ $(() => {
$("#import-button").click(importConfig);
$("#config-color-update").click(function() {
const hex_code = $("#config-color-picker").val();
const user_css = $("#theme-header").val();
const user_css = theme_header_editor.getValue();
let new_css;
if (user_css.length) {
let css_vars = `theme-color: ${hex_code};`;
Expand All @@ -269,7 +275,7 @@ $(() => {
`.jumbotron{background-color: var(--theme-color) !important;}\n` +
`</style>\n`;
}
$("#theme-header").val(new_css);
theme_header_editor.getDoc().setValue(new_css);
});

$(".start-date").change(function() {
Expand Down
Loading

0 comments on commit aad3d21

Please sign in to comment.