Skip to content

Commit 13ac125

Browse files
committed
Replace jBox tooltips with Floating Vue tooltips, remove jBox assets and references
1 parent 5ef9acb commit 13ac125

File tree

7 files changed

+80
-105
lines changed

7 files changed

+80
-105
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
"d3": "^7.9.0",
5050
"djv": "^2.1.4",
5151
"dompurify": "^3.2.4",
52+
"floating-vue": "^5.2.2",
5253
"i18next": "^24.2.2",
5354
"i18next-vue": "^5.2.0",
5455
"i18next-xhr-backend": "^3.2.2",
5556
"inflection": "^1.13.4",
56-
"jbox": "^1.3.3",
5757
"jquery": "^3.7.1",
5858
"jquery-textcomplete": "^1.8.5",
5959
"jquery-touchswipe": "^1.6.19",

src/components/init.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import "../js/localization.js";
66
import "../js/injected_methods";
77
import i18next from "i18next";
88
import { createApp, reactive } from "vue";
9+
import { Tooltip, options } from "floating-vue";
10+
import "floating-vue/dist/style.css";
911
import I18NextVue from "i18next-vue";
1012
import FC from "../js/fc.js";
1113
import MSP from "../js/msp.js";
@@ -41,6 +43,19 @@ i18next.on("initialized", function () {
4143
},
4244
});
4345

46+
// Register Floating Vue tooltip and custom themes
47+
app.component("VTooltip", Tooltip);
48+
options.themes.custom = {
49+
$extend: "tooltip",
50+
html: true,
51+
placement: "right",
52+
popperTriggers: ["focus", "hover", "touch"],
53+
triggers: ["focus", "hover", "touch"],
54+
};
55+
options.themes.custom_wide = {
56+
$extend: "custom",
57+
};
58+
4459
app.use(I18NextVue, { i18next }).use(BetaflightComponents).mount("#main-wrapper");
4560

4661
if (process.env.NODE_ENV === "development") {

src/css/main.less

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,10 +1631,18 @@ button.active {
16311631
border: 1px solid var(--primary-600);
16321632
color: #000;
16331633
}
1634-
.jBox-Tooltip {
1634+
.v-popper--theme-tooltip.v-popper--theme-custom .v-popper__inner {
1635+
background: var(--surface-300);
1636+
border: 2px solid var(--primary-500);
1637+
border-radius: 0.5rem;
1638+
color: var(--text);
16351639
max-width: 180px;
1640+
padding: 8px;
1641+
}
1642+
.v-popper--theme-tooltip.v-popper--theme-custom .v-popper__arrow-outer {
1643+
border-color: var(--primary-500);
16361644
}
1637-
.jBox-Widetip {
1645+
.v-popper--theme-tooltip.v-popper--theme-custom_wide .v-popper__inner {
16381646
max-width: 300px;
16391647
}
16401648
.hidden {
@@ -1648,48 +1656,6 @@ button.active {
16481656
border-top: 1px solid var(--surface-400);
16491657
padding-top: 5px;
16501658
}
1651-
.jBox-container {
1652-
background: var(--surface-300) !important;
1653-
border: 2px solid var(--primary-500);
1654-
color: var(--text);
1655-
border-radius: 0.5rem !important;
1656-
}
1657-
.jBox-title {
1658-
background: var(--surface-300) !important;
1659-
border-bottom: 1px solid var(--surface-950) !important;
1660-
}
1661-
.jBox-content {
1662-
padding: 0.5rem;
1663-
}
1664-
.jBox-Modal {
1665-
.jBox-content {
1666-
padding: 10px 15px;
1667-
}
1668-
}
1669-
.jBox-pointer-top {
1670-
width: 22px;
1671-
height: 10px;
1672-
}
1673-
.jBox-pointer-bottom {
1674-
width: 22px;
1675-
height: 10px;
1676-
}
1677-
.jBox-pointer-left {
1678-
width: 10px;
1679-
height: 20px;
1680-
}
1681-
.jBox-pointer-right {
1682-
width: 10px;
1683-
height: 20px;
1684-
}
1685-
.jBox-pointer {
1686-
&:after {
1687-
width: 10px;
1688-
height: 9px;
1689-
border: 2px solid var(--primary-500) !important;
1690-
background-color: var(--primary-500) !important;
1691-
}
1692-
}
16931659
#dialogResetToCustomDefaults-content {
16941660
margin-top: 10px;
16951661
margin-bottom: 10px;

src/js/browserMain.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import "../js/jqueryPlugins";
2-
import "jbox/dist/jBox.min.css";
32
import "../../libraries/jquery.nouislider.min.css";
43
import "../../libraries/jquery.nouislider.pips.min.css";
54
import "../../libraries/flightindicators.css";

src/js/gui.js

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { get as getConfig } from "./ConfigStorage";
22
import MSP from "./msp";
33
import Switchery from "switchery-latest";
4-
import jBox from "jbox";
4+
import { createTooltip } from "floating-vue";
55
import $ from "jquery";
66
import { getOS } from "./utils/checkBrowserCompatibility";
77

@@ -290,36 +290,16 @@ class GuiControl {
290290
.html(i18n.getMessage("betaflightSupportButton"))
291291
.attr("href", `https://betaflight.com/docs/wiki/configurator/${tRex}-tab`);
292292

293-
// loading tooltip
293+
// Create tooltips once page is "ready"
294294
$(function () {
295-
new jBox("Tooltip", {
296-
attach: ".cf_tip",
297-
trigger: "mouseenter",
298-
closeOnMouseleave: true,
299-
closeOnClick: "body",
300-
delayOpen: 100,
301-
delayClose: 100,
302-
position: {
303-
x: "right",
304-
y: "center",
305-
},
306-
outside: "x",
307-
});
308-
309-
new jBox("Tooltip", {
310-
theme: "Widetip",
311-
attach: ".cf_tip_wide",
312-
trigger: "mouseenter",
313-
closeOnMouseleave: true,
314-
closeOnClick: "body",
315-
delayOpen: 100,
316-
delayClose: 100,
317-
position: {
318-
x: "right",
319-
y: "center",
320-
},
321-
outside: "x",
322-
});
295+
for (const suffix of ["", "_wide"]) {
296+
$(`.cf_tip${suffix}`).each((_, element) => {
297+
createTooltip(element, {
298+
content: $(element).attr("title"),
299+
theme: `custom${suffix}`,
300+
});
301+
});
302+
}
323303
});
324304

325305
if (callback) {

src/js/tabs/osd.js

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import CONFIGURATOR, { API_VERSION_1_45, API_VERSION_1_46, API_VERSION_1_47 } fr
1010
import LogoManager from "../LogoManager";
1111
import { gui_log } from "../gui_log";
1212
import semver from "semver";
13-
import jBox from "jbox";
13+
import { createTooltip, destroyTooltip } from "floating-vue";
1414
import inflection from "inflection";
1515
import debounce from "lodash.debounce";
1616
import $ from "jquery";
@@ -3937,28 +3937,18 @@ osd.initialize = function (callback) {
39373937
}
39383938
}
39393939

3940-
// Remove last tooltips
3941-
for (const tt of OSD.data.tooltips) {
3942-
tt.destroy();
3940+
// Remove previous tooltips
3941+
for (const element of OSD.data.tooltips) {
3942+
destroyTooltip(element);
39433943
}
3944-
OSD.data.tooltips = [];
3945-
3946-
// Generate tooltips for OSD elements
3947-
$(".osd_tip").each(function () {
3948-
const myModal = new jBox("Tooltip", {
3949-
delayOpen: 100,
3950-
delayClose: 100,
3951-
position: {
3952-
x: "right",
3953-
y: "center",
3954-
},
3955-
outside: "x",
3944+
// Attach new tooltips
3945+
OSD.data.tooltips = $(".osd_tip").toArray();
3946+
for (const element of OSD.data.tooltips) {
3947+
createTooltip(element, {
3948+
content: $(element).attr("title"),
3949+
theme: "custom",
39563950
});
3957-
3958-
myModal.attach($(this));
3959-
3960-
OSD.data.tooltips.push(myModal);
3961-
});
3951+
}
39623952
});
39633953
}
39643954

yarn.lock

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,25 @@
12071207
"@eslint/core" "^0.12.0"
12081208
levn "^0.4.1"
12091209

1210+
"@floating-ui/core@^1.1.0":
1211+
version "1.7.2"
1212+
resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.7.2.tgz#3d1c35263950b314b6d5a72c8bfb9e3c1551aefd"
1213+
integrity sha512-wNB5ooIKHQc+Kui96jE/n69rHFWAVoxn5CAzL1Xdd8FG03cgY3MLO+GF9U3W737fYDSgPWA6MReKhBQBop6Pcw==
1214+
dependencies:
1215+
"@floating-ui/utils" "^0.2.10"
1216+
1217+
"@floating-ui/dom@~1.1.1":
1218+
version "1.1.1"
1219+
resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.1.1.tgz#66aa747e15894910869bf9144fc54fc7d6e9f975"
1220+
integrity sha512-TpIO93+DIujg3g7SykEAGZMDtbJRrmnYRCNYSjJlvIbGhBjRSNTLVbNeDQBrzy9qDgUbiWdc7KA0uZHZ2tJmiw==
1221+
dependencies:
1222+
"@floating-ui/core" "^1.1.0"
1223+
1224+
"@floating-ui/utils@^0.2.10":
1225+
version "0.2.10"
1226+
resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.2.10.tgz#a2a1e3812d14525f725d011a73eceb41fef5bc1c"
1227+
integrity sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==
1228+
12101229
"@fortawesome/fontawesome-free@^6.5.2":
12111230
version "6.7.2"
12121231
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-6.7.2.tgz#8249de9b7e22fcb3ceb5e66090c30a1d5492b81a"
@@ -4865,6 +4884,14 @@ flatted@^3.2.9:
48654884
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.3.tgz#67c8fad95454a7c7abebf74bb78ee74a44023358"
48664885
integrity sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==
48674886

4887+
floating-vue@^5.2.2:
4888+
version "5.2.2"
4889+
resolved "https://registry.yarnpkg.com/floating-vue/-/floating-vue-5.2.2.tgz#e263932042753f59f3e36e7c1188f3f3e272a539"
4890+
integrity sha512-afW+h2CFafo+7Y9Lvw/xsqjaQlKLdJV7h1fCHfcYQ1C4SVMlu7OAekqWgu5d4SgvkBVU0pVpLlVsrSTBURFRkg==
4891+
dependencies:
4892+
"@floating-ui/dom" "~1.1.1"
4893+
vue-resize "^2.0.0-alpha.1"
4894+
48684895
flush-write-stream@^1.0.2:
48694896
version "1.1.1"
48704897
resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.1.1.tgz#8dd7d873a1babc207d94ead0c2e0e44276ebf2e8"
@@ -6419,13 +6446,6 @@ jake@^10.8.5:
64196446
filelist "^1.0.4"
64206447
minimatch "^3.1.2"
64216448

6422-
jbox@^1.3.3:
6423-
version "1.3.3"
6424-
resolved "https://registry.yarnpkg.com/jbox/-/jbox-1.3.3.tgz#7bfc5f2c89eb3f4dd5185ce6b56a5f9875d70692"
6425-
integrity sha512-aayuZDf4Dc3w/adEdixUetNxJMIbThgt3r9Gfsxh8rWqBBEM3ODKON3YWSwpjgy7BzUHQjIeZ2sdPwV8RSVW6w==
6426-
dependencies:
6427-
jquery "^3.6.0"
6428-
64296449
jquery-textcomplete@^1.8.5:
64306450
version "1.8.5"
64316451
resolved "https://registry.yarnpkg.com/jquery-textcomplete/-/jquery-textcomplete-1.8.5.tgz#df9724b42c3af9ece272356a7e8b55cd9cf239dd"
@@ -6443,7 +6463,7 @@ jquery-ui@^1.14.1:
64436463
dependencies:
64446464
jquery ">=1.12.0 <5.0.0"
64456465

6446-
[email protected], "jquery@>=1.12.0 <5.0.0", jquery@^3.6.0:
6466+
[email protected], "jquery@>=1.12.0 <5.0.0":
64476467
version "3.6.3"
64486468
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.3.tgz#23ed2ffed8a19e048814f13391a19afcdba160e6"
64496469
integrity sha512-bZ5Sy3YzKo9Fyc8wH2iIQK4JImJ6R0GWI9kL1/k7Z91ZBNgkRXE6U0JfHIizZbort8ZunhSI3jw9I6253ahKfg==
@@ -10240,6 +10260,11 @@ vue-loader@^17.4.2:
1024010260
hash-sum "^2.0.0"
1024110261
watchpack "^2.4.0"
1024210262

10263+
vue-resize@^2.0.0-alpha.1:
10264+
version "2.0.0-alpha.1"
10265+
resolved "https://registry.yarnpkg.com/vue-resize/-/vue-resize-2.0.0-alpha.1.tgz#43eeb79e74febe932b9b20c5c57e0ebc14e2df3a"
10266+
integrity sha512-7+iqOueLU7uc9NrMfrzbG8hwMqchfVfSzpVlCMeJQe4pyibqyoifDNbKTZvwxZKDvGkB+PdFeKvnGZMoEb8esg==
10267+
1024310268
vue-template-compiler@^2.7.16:
1024410269
version "2.7.16"
1024510270
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.7.16.tgz#c81b2d47753264c77ac03b9966a46637482bb03b"

0 commit comments

Comments
 (0)