mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
Add support for disabled
context menu items through puter.js
This commit is contained in:
parent
04adade80e
commit
ccf6ebef4d
@ -426,6 +426,7 @@ window.addEventListener('message', async (event) => {
|
|||||||
html: item.label,
|
html: item.label,
|
||||||
icon: item.icon ? `<img style="width: 15px; height: 15px; position: absolute; top: 4px; left: 6px;" src="${html_encode(item.icon)}" />` : undefined,
|
icon: item.icon ? `<img style="width: 15px; height: 15px; position: absolute; top: 4px; left: 6px;" src="${html_encode(item.icon)}" />` : undefined,
|
||||||
icon_active: item.icon_active ? `<img style="width: 15px; height: 15px; position: absolute; top: 4px; left: 6px;" src="${html_encode(item.icon_active)}" />` : undefined,
|
icon_active: item.icon_active ? `<img style="width: 15px; height: 15px; position: absolute; top: 4px; left: 6px;" src="${html_encode(item.icon_active)}" />` : undefined,
|
||||||
|
disabled: item.disabled,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
if (item.action !== undefined) {
|
if (item.action !== undefined) {
|
||||||
item.action();
|
item.action();
|
||||||
|
@ -261,7 +261,14 @@ function UIContextMenu(options){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Useful in cases such as where a menu item is over a window, this prevents from the mousedown event
|
// disabled item mousedown event
|
||||||
|
$(`#context-menu-${menu_id} > li.context-menu-item-disabled`).on('mousedown', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
|
||||||
|
// Useful in cases such as where a menu item is over a window, this prevents the mousedown event from
|
||||||
// reaching the window underneath
|
// reaching the window underneath
|
||||||
$(`#context-menu-${menu_id} > li:not(.context-menu-item-disabled)`).on('mousedown', function (e) {
|
$(`#context-menu-${menu_id} > li:not(.context-menu-item-disabled)`).on('mousedown', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
Loading…
Reference in New Issue
Block a user