Skip to content

Commit 9f42852

Browse files
authored
Replace jBox tooltips with Tippy.js tooltips, remove jBox assets and references (#4582)
1 parent 95f2b2c commit 9f42852

File tree

7 files changed

+67
-107
lines changed

7 files changed

+67
-107
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"i18next-vue": "^5.2.0",
5454
"i18next-xhr-backend": "^3.2.2",
5555
"inflection": "^1.13.4",
56-
"jbox": "^1.3.3",
5756
"jquery": "^3.7.1",
5857
"jquery-textcomplete": "^1.8.5",
5958
"jquery-touchswipe": "^1.6.19",
@@ -70,6 +69,7 @@
7069
"switchery-latest": "^0.8.2",
7170
"three": "^0.176.0",
7271
"tiny-emitter": "^2.1.0",
72+
"tippy.js": "^6.3.7",
7373
"vite-plugin-pwa": "^1.0.0",
7474
"vue": "^3.5.13"
7575
},

src/components/init.js

Lines changed: 14 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 tippy from "tippy.js";
10+
import "tippy.js/dist/tippy.css";
911
import I18NextVue from "i18next-vue";
1012
import FC from "../js/fc.js";
1113
import MSP from "../js/msp.js";
@@ -38,6 +40,18 @@ const betaflightModel = reactive({
3840
CONNECTION,
3941
});
4042

43+
tippy.setDefaultProps({
44+
allowHTML: true,
45+
appendTo: () => document.body,
46+
delay: 100,
47+
interactive: true,
48+
placement: "right",
49+
theme: "custom",
50+
// Un-comment for debugging:
51+
// hideOnClick: false,
52+
// trigger: 'click',
53+
});
54+
4155
i18next.on("initialized", function () {
4256
console.log("i18n initialized, starting Vue framework");
4357

src/css/main.less

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,11 +1631,19 @@ button.active {
16311631
border: 1px solid var(--primary-600);
16321632
color: #000;
16331633
}
1634-
.jBox-Tooltip {
1635-
max-width: 180px;
1634+
.tippy-box[data-theme~="custom"] {
1635+
background: var(--surface-300);
1636+
border: 2px solid var(--primary-500);
1637+
border-radius: 0.5rem;
1638+
color: var(--text);
1639+
}
1640+
.tippy-box[data-theme~="custom"][data-placement^="right"] > .tippy-arrow:before {
1641+
border-right-color: var(--primary-500);
1642+
left: -9px;
16361643
}
1637-
.jBox-Widetip {
1638-
max-width: 300px;
1644+
.tippy-box[data-theme~="custom"][data-placement^="left"] > .tippy-arrow:before {
1645+
border-left-color: var(--primary-500);
1646+
right: -9px;
16391647
}
16401648
.hidden {
16411649
display: none;
@@ -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: 11 additions & 29 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 tippy from "tippy.js";
55
import $ from "jquery";
66
import { getOS } from "./utils/checkBrowserCompatibility";
77

@@ -290,35 +290,17 @@ 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",
295+
$(".cf_tip, .cf_tip_wide").each((_, element) => {
296+
const jQueryElement = $(element);
297+
const attrTitle = jQueryElement.attr("title");
298+
if (attrTitle && !element._tippy) {
299+
tippy(element, {
300+
content: attrTitle,
301+
});
302+
jQueryElement.removeAttr("title");
303+
}
322304
});
323305
});
324306

src/js/tabs/osd.js

Lines changed: 16 additions & 22 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 tippy from "tippy.js";
1414
import inflection from "inflection";
1515
import debounce from "lodash.debounce";
1616
import $ from "jquery";
@@ -3937,28 +3937,22 @@ 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+
element._tippy?.destroy();
3943+
}
3944+
// Attach new tooltips
3945+
OSD.data.tooltips = $(".osd_tip").toArray();
3946+
for (const element of OSD.data.tooltips) {
3947+
const jQueryElement = $(element);
3948+
const attrTitle = jQueryElement.attr("title");
3949+
if (attrTitle && !element._tippy) {
3950+
tippy(element, {
3951+
content: attrTitle,
3952+
});
3953+
jQueryElement.removeAttr("title");
3954+
}
39433955
}
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",
3956-
});
3957-
3958-
myModal.attach($(this));
3959-
3960-
OSD.data.tooltips.push(myModal);
3961-
});
39623956
});
39633957
}
39643958

yarn.lock

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,11 @@
16071607
resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31"
16081608
integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==
16091609

1610+
"@popperjs/core@^2.9.0":
1611+
version "2.11.8"
1612+
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f"
1613+
integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==
1614+
16101615
"@quanle94/innosetup@^6.0.2":
16111616
version "6.0.2"
16121617
resolved "https://registry.yarnpkg.com/@quanle94/innosetup/-/innosetup-6.0.2.tgz#b678b67240486302a08e3469151faca2c29f80ab"
@@ -6424,13 +6429,6 @@ jake@^10.8.5:
64246429
filelist "^1.0.4"
64256430
minimatch "^3.1.2"
64266431

6427-
jbox@^1.3.3:
6428-
version "1.3.3"
6429-
resolved "https://registry.yarnpkg.com/jbox/-/jbox-1.3.3.tgz#7bfc5f2c89eb3f4dd5185ce6b56a5f9875d70692"
6430-
integrity sha512-aayuZDf4Dc3w/adEdixUetNxJMIbThgt3r9Gfsxh8rWqBBEM3ODKON3YWSwpjgy7BzUHQjIeZ2sdPwV8RSVW6w==
6431-
dependencies:
6432-
jquery "^3.6.0"
6433-
64346432
jquery-textcomplete@^1.8.5:
64356433
version "1.8.5"
64366434
resolved "https://registry.yarnpkg.com/jquery-textcomplete/-/jquery-textcomplete-1.8.5.tgz#df9724b42c3af9ece272356a7e8b55cd9cf239dd"
@@ -6448,7 +6446,7 @@ jquery-ui@^1.14.1:
64486446
dependencies:
64496447
jquery ">=1.12.0 <5.0.0"
64506448

6451-
[email protected], "jquery@>=1.12.0 <5.0.0", jquery@^3.6.0:
6449+
[email protected], "jquery@>=1.12.0 <5.0.0":
64526450
version "3.6.3"
64536451
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.3.tgz#23ed2ffed8a19e048814f13391a19afcdba160e6"
64546452
integrity sha512-bZ5Sy3YzKo9Fyc8wH2iIQK4JImJ6R0GWI9kL1/k7Z91ZBNgkRXE6U0JfHIizZbort8ZunhSI3jw9I6253ahKfg==
@@ -9635,6 +9633,13 @@ tinyspy@^3.0.2:
96359633
resolved "https://registry.yarnpkg.com/tinyspy/-/tinyspy-3.0.2.tgz#86dd3cf3d737b15adcf17d7887c84a75201df20a"
96369634
integrity sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==
96379635

9636+
tippy.js@^6.3.7:
9637+
version "6.3.7"
9638+
resolved "https://registry.yarnpkg.com/tippy.js/-/tippy.js-6.3.7.tgz#8ccfb651d642010ed9a32ff29b0e9e19c5b8c61c"
9639+
integrity sha512-E1d3oP2emgJ9dRQZdf3Kkn0qJgI6ZLpyS5z6ZkY1DF3kaQaBsGZsndEpHwx+eC+tYM41HaSNvNtLx8tU57FzTQ==
9640+
dependencies:
9641+
"@popperjs/core" "^2.9.0"
9642+
96389643
title-case@^2.1.0:
96399644
version "2.1.1"
96409645
resolved "https://registry.yarnpkg.com/title-case/-/title-case-2.1.1.tgz#3e127216da58d2bc5becf137ab91dae3a7cd8faa"

0 commit comments

Comments
 (0)