mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-19 06:15:13 +03:00
ISSUE-1609: Create communication mechanism between windows, implement dark theme for sticks window using it. Small fix for Tip popup window.
This commit is contained in:
parent
c6fd43fdec
commit
262bc05ab5
11 changed files with 190 additions and 72 deletions
|
@ -11,6 +11,8 @@
|
||||||
--paper: url(../../images/paper-dark.jpg);
|
--paper: url(../../images/paper-dark.jpg);
|
||||||
--ledAccent: #6e6e6e;
|
--ledAccent: #6e6e6e;
|
||||||
--ledBackground: #424242;
|
--ledBackground: #424242;
|
||||||
|
--gimbalBackground: var(--subtleAccent);
|
||||||
|
--gimbalCrosshair: var(--mutedText);
|
||||||
--switcherysecond: #858585;
|
--switcherysecond: #858585;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +151,7 @@ button {
|
||||||
}
|
}
|
||||||
|
|
||||||
.noUi-pips {
|
.noUi-pips {
|
||||||
color: #dbdbdb;
|
color: var(--mutedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
.jBox-container {
|
.jBox-container {
|
||||||
|
@ -164,3 +166,7 @@ button {
|
||||||
text-shadow: 0 1px 1px #ffffff;
|
text-shadow: 0 1px 1px #ffffff;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.jBox-pointer:after {
|
||||||
|
background: #393b3a;
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
--paper: url(../../images/paper.jpg);
|
--paper: url(../../images/paper.jpg);
|
||||||
--ledAccent: #adadad;
|
--ledAccent: #adadad;
|
||||||
--ledBackground: #e9e9e9;
|
--ledBackground: #e9e9e9;
|
||||||
|
--gimbalBackground: #eee;
|
||||||
|
--gimbalCrosshair: var(--subtleAccent);
|
||||||
--switcherysecond: #c4c4c4;
|
--switcherysecond: #c4c4c4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2141,3 +2143,33 @@ input {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
noUi slider stylings
|
||||||
|
*/
|
||||||
|
|
||||||
|
.noUi-target {
|
||||||
|
background: var(--alternativeBackground);
|
||||||
|
border-color: var(--subtleAccent);
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.noUi-handle {
|
||||||
|
background: var(--sideBackground);
|
||||||
|
border-color: var(--subtleAccent);
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.noUi-handle:before,
|
||||||
|
.noUi-handle:after {
|
||||||
|
background-color: var(--subtleAccent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.noUi-background {
|
||||||
|
background: var(--alternativeBackground);
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.noUi-connect {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
|
@ -15,7 +15,3 @@
|
||||||
background-color: #3a3a3a;
|
background-color: #3a3a3a;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-adjustments .noUi-background {
|
|
||||||
background-color: #858585;
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,18 +4,10 @@
|
||||||
|
|
||||||
.tab-adjustments .range .marker, .tab-adjustments .channel-slider .noUi-connect {
|
.tab-adjustments .range .marker, .tab-adjustments .channel-slider .noUi-connect {
|
||||||
background: var(--accent);
|
background: var(--accent);
|
||||||
box-shadow: inset 0 0px 2px rgba(0, 0, 0, 0.4), 0px 1px 0px rgba(255, 255, 255, 0.6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.noUi-target {
|
.noUi-target {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
border: 1px solid #D3D3D3;
|
|
||||||
box-shadow: inset 0 0px 2px rgba(0, 0, 0, 0.4), 0px 1px 0px rgba(255, 255, 255, 0.6);
|
|
||||||
}
|
|
||||||
|
|
||||||
.noUi-background {
|
|
||||||
box-shadow: inset 0 0px 2px rgba(0, 0, 0, 0.4), 0px 1px 0px rgba(255, 255, 255, 0.6);
|
|
||||||
background: #D2D2D2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-adjustments .adjustments {
|
.tab-adjustments .adjustments {
|
||||||
|
|
|
@ -21,7 +21,7 @@ body {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 120px;
|
width: 120px;
|
||||||
height: 120px;
|
height: 120px;
|
||||||
background-color: #eee;
|
background-color: var(--gimbalBackground);
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
margin-right: 1em;
|
margin-right: 1em;
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
|
@ -33,7 +33,7 @@ body {
|
||||||
.crosshair {
|
.crosshair {
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: var(--subtleAccent);
|
background-color: var(--gimbalCrosshair);
|
||||||
}
|
}
|
||||||
|
|
||||||
.crosshair-vert {
|
.crosshair-vert {
|
||||||
|
|
|
@ -29,27 +29,28 @@ var css_dark = [
|
||||||
var DarkTheme = {
|
var DarkTheme = {
|
||||||
configEnabled: undefined,
|
configEnabled: undefined,
|
||||||
};
|
};
|
||||||
|
DarkTheme.isDarkThemeEnabled = function (val) {
|
||||||
DarkTheme.setConfig = function(result) {
|
return val === 0 || val === 2 && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
|
}
|
||||||
|
DarkTheme.setConfig = function (result) {
|
||||||
if (this.configEnabled != result) {
|
if (this.configEnabled != result) {
|
||||||
this.configEnabled = result;
|
this.configEnabled = result;
|
||||||
|
|
||||||
if (this.configEnabled === 0 || this.configEnabled === 2 && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
if (this.isDarkThemeEnabled(this.configEnabled)) {
|
||||||
this.applyDark();
|
this.applyDark();
|
||||||
} else {
|
} else {
|
||||||
this.applyNormal();
|
this.applyNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
windowWatcherUtil.passValue(chrome.app.window.get("receiver_msp"), 'darkTheme', this.isDarkThemeEnabled(this.configEnabled));
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DarkTheme.applyDark = function() {
|
DarkTheme.applyDark = function () {
|
||||||
for (var i = 0; i < css_dark.length; i++) {
|
css_dark.forEach((el) => $('link[href="' + el + '"]').prop('disabled', false));
|
||||||
$('link[href="' + css_dark[i] + '"]').prop('disabled', false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DarkTheme.applyNormal = function() {
|
DarkTheme.applyNormal = function () {
|
||||||
for (var i = 0; i < css_dark.length; i++) {
|
css_dark.forEach((el) => $('link[href="' + el + '"]').prop('disabled', true));
|
||||||
$('link[href="' + css_dark[i] + '"]').prop('disabled', true);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -319,6 +319,9 @@ TABS.receiver.initialize = function (callback) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
windowWatcherUtil.passValue(createdWindow, 'darkTheme', DarkTheme.isDarkThemeEnabled(DarkTheme.configEnabled));
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
let css_dark = [
|
||||||
|
'/css/main-dark.css'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
var
|
var
|
||||||
CHANNEL_MIN_VALUE = 1000,
|
CHANNEL_MIN_VALUE = 1000,
|
||||||
CHANNEL_MID_VALUE = 1500,
|
CHANNEL_MID_VALUE = 1500,
|
||||||
|
@ -43,6 +48,16 @@ var
|
||||||
// This is a hack to get the i18n var of the parent, but the localizePage not works
|
// This is a hack to get the i18n var of the parent, but the localizePage not works
|
||||||
const i18n = opener.i18n;
|
const i18n = opener.i18n;
|
||||||
|
|
||||||
|
let watchers = {
|
||||||
|
darkTheme: (val) => {
|
||||||
|
if (val) {
|
||||||
|
applyDarkTheme();
|
||||||
|
} else {
|
||||||
|
applyNormalTheme();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('[i18n]:not(.i18n-replaced)').each(function() {
|
$('[i18n]:not(.i18n-replaced)').each(function() {
|
||||||
var element = $(this);
|
var element = $(this);
|
||||||
|
@ -50,7 +65,9 @@ $(document).ready(function () {
|
||||||
element.html(i18n.getMessage(element.attr('i18n')));
|
element.html(i18n.getMessage(element.attr('i18n')));
|
||||||
element.addClass('i18n-replaced');
|
element.addClass('i18n-replaced');
|
||||||
});
|
});
|
||||||
})
|
|
||||||
|
windowWatcherUtil.bindWatchers(window, watchers);
|
||||||
|
});
|
||||||
|
|
||||||
function transmitChannels() {
|
function transmitChannels() {
|
||||||
var
|
var
|
||||||
|
@ -131,6 +148,14 @@ function localizeAxisNames() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyDarkTheme() {
|
||||||
|
css_dark.forEach((el) => $('link[href="' + el + '"]').prop('disabled', false));
|
||||||
|
};
|
||||||
|
|
||||||
|
function applyNormalTheme() {
|
||||||
|
css_dark.forEach((el) => $('link[href="' + el + '"]').prop('disabled', true));
|
||||||
|
};
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$(".button-enable .btn").click(function() {
|
$(".button-enable .btn").click(function() {
|
||||||
var
|
var
|
||||||
|
|
59
src/js/utils/window_watchers.js
Normal file
59
src/js/utils/window_watchers.js
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/*
|
||||||
|
This utility is intended to communicate between chrome windows.
|
||||||
|
One window could watch passed values from another window and react to them.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var windowWatcherUtil = {};
|
||||||
|
|
||||||
|
windowWatcherUtil.invokeWatcher = function(bindingKey, bindingVal, watchersObject) {
|
||||||
|
if (watchersObject[bindingKey]) {
|
||||||
|
watchersObject[bindingKey](bindingVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
windowWatcherUtil.iterateOverBindings = function(bindings, watchersObject) {
|
||||||
|
let entries = Object.entries(bindings);
|
||||||
|
for (const [key, val] of entries) {
|
||||||
|
this.invokeWatcher(key, val, watchersObject)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
windowWatcherUtil.bindWatchers = function(windowObject, watchersObject) {
|
||||||
|
if (!windowObject.bindings) {
|
||||||
|
windowObject.bindings = {};
|
||||||
|
} else {
|
||||||
|
this.iterateOverBindings(windowObject.bindings, watchersObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
windowObject.bindings = new Proxy(windowObject.bindings, {
|
||||||
|
set(target, prop, val, receiver) {
|
||||||
|
windowWatcherUtil.invokeWatcher(prop, val, watchersObject);
|
||||||
|
return Reflect.set(target, prop, val, receiver);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 'Windows' here could be array or single window reference
|
||||||
|
windowWatcherUtil.passValue = function(windows, key, val) {
|
||||||
|
let applyBinding = function(win, key, val) {
|
||||||
|
if (!win) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (win.contentWindow.bindings) {
|
||||||
|
win.contentWindow.bindings[key] = val;
|
||||||
|
} else {
|
||||||
|
win.contentWindow.bindings = {
|
||||||
|
[key]: val
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(windows)) {
|
||||||
|
windows.forEach((el) => applyBinding(el, key, val));
|
||||||
|
} else {
|
||||||
|
applyBinding(windows, key, val)
|
||||||
|
}
|
||||||
|
}
|
|
@ -85,6 +85,7 @@
|
||||||
<script type="text/javascript" src="./js/libraries/jquery.ba-throttle-debounce.min.js"></script>
|
<script type="text/javascript" src="./js/libraries/jquery.ba-throttle-debounce.min.js"></script>
|
||||||
<script type="text/javascript" src="./node_modules/inflection/inflection.min.js"></script>
|
<script type="text/javascript" src="./node_modules/inflection/inflection.min.js"></script>
|
||||||
<script type="text/javascript" src="./js/libraries/analytics.js"></script>
|
<script type="text/javascript" src="./js/libraries/analytics.js"></script>
|
||||||
|
<script type="text/javascript" src="./js/utils/window_watchers.js"></script>
|
||||||
<script type="text/javascript" src="./js/injected_methods.js"></script>
|
<script type="text/javascript" src="./js/injected_methods.js"></script>
|
||||||
<script type="text/javascript" src="./js/ConfigStorage.js"></script>
|
<script type="text/javascript" src="./js/ConfigStorage.js"></script>
|
||||||
<script type="text/javascript" src="./js/data_storage.js"></script>
|
<script type="text/javascript" src="./js/data_storage.js"></script>
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<script type="text/javascript" src="/node_modules/jquery-ui-npm/jquery-ui.min.js"></script>
|
<script type="text/javascript" src="/node_modules/jquery-ui-npm/jquery-ui.min.js"></script>
|
||||||
<script type="text/javascript" src="/js/libraries/jquery.nouislider.all.min.js"></script>
|
<script type="text/javascript" src="/js/libraries/jquery.nouislider.all.min.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="/js/utils/window_watchers.js"></script>
|
||||||
<script type="text/javascript" src="/js/tabs/receiver_msp.js"></script>
|
<script type="text/javascript" src="/js/tabs/receiver_msp.js"></script>
|
||||||
|
|
||||||
<link type="text/css" rel="stylesheet" href="/js/libraries/jquery.nouislider.min.css">
|
<link type="text/css" rel="stylesheet" href="/js/libraries/jquery.nouislider.min.css">
|
||||||
|
@ -12,6 +13,8 @@
|
||||||
|
|
||||||
<link type="text/css" rel="stylesheet" href="/css/main.css" media="all" />
|
<link type="text/css" rel="stylesheet" href="/css/main.css" media="all" />
|
||||||
<link type="text/css" rel="stylesheet" href="/css/tabs/receiver_msp.css" media="all" />
|
<link type="text/css" rel="stylesheet" href="/css/tabs/receiver_msp.css" media="all" />
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="/css/main-dark.css" media="all" disabled/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="control-gimbals">
|
<div class="control-gimbals">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue