add hotkey (a N) to toggle night.css

master
Andrew Dolgov 6 years ago
parent a5813bb766
commit 1c8593c1fa

@ -1831,6 +1831,11 @@ body#sharepopup input {
.flat label.dijitButton:hover {
background-color: #f5f5f5;
}
.flat .dijitTree .dijitTreeNode .dijitTreeRow {
padding: 4px 0px 4px;
border-width: 1px;
color: #555555;
}
@font-face {
font-family: 'Material Icons';
font-style: normal;
@ -1873,11 +1878,6 @@ body#sharepopup input {
.flat .dijitCheckBox {
background: #ccc;
}
.flat .dijitTree .dijitTreeNode .dijitTreeRow {
padding: 4px 0px 4px;
border-width: 1px;
color: #333;
}
body.ttrss_zoom {
margin-left: auto;
margin-right: auto;

File diff suppressed because one or more lines are too long

@ -132,4 +132,13 @@
label.dijitButton:hover {
background-color : @color-panel-bg;
}
.dijitTree {
.dijitTreeNode .dijitTreeRow {
padding : 4px 0px 4px;
border-width : 1px;
color : @default-text;
}
}
}

@ -11,12 +11,4 @@
.dijitCheckBox {
background : #ccc;
}
.dijitTree {
.dijitTreeNode .dijitTreeRow {
padding : 4px 0px 4px;
border-width : 1px;
color : #333;
}
}
}

@ -233,10 +233,12 @@ function print_feed_cat_select($id, $default_id,
}
}
function stylesheet_tag($filename) {
function stylesheet_tag($filename, $id = false) {
$timestamp = filemtime($filename);
return "<link rel=\"stylesheet\" type=\"text/css\" href=\"$filename?$timestamp\"/>\n";
$id_part = $id ? "id=\"$id\"" : "";
return "<link rel=\"stylesheet\" $id_part type=\"text/css\" href=\"$filename?$timestamp\"/>\n";
}
function javascript_tag($filename) {

@ -1174,6 +1174,7 @@
"create_label" => __("Create label"),
"create_filter" => __("Create filter"),
"collapse_sidebar" => __("Un/collapse sidebar"),
"toggle_night_mode" => __("Toggle night mode"),
"help_dialog" => __("Show help dialog"))
);
@ -1245,6 +1246,7 @@
"c l" => "create_label",
"c f" => "create_filter",
"c s" => "collapse_sidebar",
"a *n" => "toggle_night_mode",
"^(191)|Ctrl+/" => "help_dialog",
);

@ -64,9 +64,9 @@
<?php if ($_SESSION["uid"]) {
$theme = get_pref("USER_CSS_THEME", false, false);
if ($theme && theme_exists("$theme")) {
echo stylesheet_tag(get_theme_path($theme));
echo stylesheet_tag(get_theme_path($theme), 'theme_css');
} else {
echo stylesheet_tag("css/default.css");
echo stylesheet_tag("css/default.css", 'theme_css');
}
}
?>

@ -51,8 +51,9 @@ define(["dojo/_base/declare"], function (declare) {
if (dijit.byId("loading_bar"))
dijit.byId("loading_bar").update({progress: loading_progress});
if (loading_progress >= 90)
Element.hide("overlay");
if (loading_progress >= 90) {
$("overlay").hide();
}
},
keyeventToAction: function(event) {
@ -351,6 +352,29 @@ define(["dojo/_base/declare"], function (declare) {
this.initSecondStage();
},
toggleNightMode: function() {
const link = $("theme_css");
if (link) {
let user_theme = "";
let user_css = "";
if (link.getAttribute("href").indexOf("themes/night.css") == -1) {
user_css = "themes/night.css?" + Date.now();
user_theme = "night.css";
} else {
user_theme = "default.php";
user_css = "css/default.css?" + Date.now();
}
fetch(user_css).then(() => {
link.setAttribute("href", user_css);
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "USER_CSS_THEME", value: user_theme});
});
}
},
explainError: function(code) {
return this.displayDlg(__("Error explained"), "explainError", code);
},

@ -132,6 +132,8 @@ require(["dojo/_base/kernel",
case "help_dialog":
App.helpDialog("main");
return false;
case "toggle_night_mode":
App.toggleNightMode();
default:
console.log("unhandled action: " + action_name + "; keycode: " + event.which);
}

@ -466,6 +466,9 @@ require(["dojo/_base/kernel",
Feeds.reloadCurrent();
});
};
this.hotkey_actions["toggle_night_mode"] = function () {
App.toggleNightMode();
};
},
onActionSelected: function(opid) {
switch (opid) {

@ -40,9 +40,9 @@
<?php if ($_SESSION["uid"]) {
$theme = get_pref("USER_CSS_THEME", false, false);
if ($theme && theme_exists("$theme")) {
echo stylesheet_tag(get_theme_path($theme));
echo stylesheet_tag(get_theme_path($theme), 'theme_css');
} else {
echo stylesheet_tag("css/default.css");
echo stylesheet_tag("css/default.css", 'theme_css');
}
}
?>

@ -1831,6 +1831,11 @@ body#sharepopup input {
.flat label.dijitButton:hover {
background-color: #222222;
}
.flat .dijitTree .dijitTreeNode .dijitTreeRow {
padding: 4px 0px 4px;
border-width: 1px;
color: #cccccc;
}
@font-face {
font-family: 'Material Icons';
font-style: normal;

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save