Skip to content

Commit 74c9fe1

Browse files
committed
Added option to change alignment of video-toggle
1 parent 46bfec2 commit 74c9fe1

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

plugins/video-toggle/button-switcher.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
color: #fff;
2323
padding-right: 120px;
2424
position: absolute;
25-
left: calc(50% - 120px);
25+
left: var(--align);
2626
}
2727

2828
.video-switch-button:before {

plugins/video-toggle/front.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ module.exports = (_options) => {
3131
document.addEventListener("apiLoaded", setup, { once: true, passive: true });
3232
}
3333
}
34+
const mainpanel = document.querySelector("#main-panel");
35+
switch (_options.align) {
36+
case "right": {
37+
mainpanel.style.setProperty("--align", "calc(100% - 240px)");
38+
return;
39+
}
40+
case "middle": {
41+
mainpanel.style.setProperty("--align", "calc(50% - 120px)");
42+
return;
43+
}
44+
default:
45+
case "left": {
46+
mainpanel.style.setProperty("--align", "0px");
47+
}
48+
}
3449
};
3550

3651
function setup(e) {

plugins/video-toggle/menu.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,38 @@ module.exports = (win, options) => [
3333
},
3434
]
3535
},
36+
{
37+
label: "Alignment",
38+
submenu: [
39+
{
40+
label: "Left",
41+
type: "radio",
42+
checked: options.align === 'left',
43+
click: () => {
44+
options.align = 'left';
45+
setMenuOptions("video-toggle", options);
46+
}
47+
},
48+
{
49+
label: "Middle",
50+
type: "radio",
51+
checked: options.align === 'middle',
52+
click: () => {
53+
options.align = 'middle';
54+
setMenuOptions("video-toggle", options);
55+
}
56+
},
57+
{
58+
label: "Right",
59+
type: "radio",
60+
checked: options.align === 'right',
61+
click: () => {
62+
options.align = 'right';
63+
setMenuOptions("video-toggle", options);
64+
}
65+
},
66+
]
67+
},
3668
{
3769
label: "Force Remove Video Tab",
3870
type: "checkbox",

0 commit comments

Comments
 (0)