diff --git a/src/gui/src/UI/UIContextMenu.js b/src/gui/src/UI/UIContextMenu.js index 202852c7..66d69c1b 100644 --- a/src/gui/src/UI/UIContextMenu.js +++ b/src/gui/src/UI/UIContextMenu.js @@ -90,7 +90,6 @@ * https://github.com/kamens/jQuery-menu-aim */ (function ($) { - $.fn.menuAim = function (opts) { // Initialize menu-aim for all elements in jQuery collection this.each(function () { @@ -365,6 +364,10 @@ function UIContextMenu(options){ $('.window-active .window-app-iframe').css('pointer-events', 'none'); const menu_id = window.global_element_id++; + + // Dispatch 'ctxmenu-will-open' event + window.dispatchEvent(new CustomEvent('ctxmenu-will-open', { detail: { options: options} })); + let h = ''; h += `
` $('body').append(h) + const contextMenu = document.getElementById(`context-menu-${menu_id}`); const menu_width = $(contextMenu).width(); const menu_height = $(contextMenu).outerHeight(); let start_x, start_y; + //-------------------------------- // Auto position //-------------------------------- @@ -505,7 +510,7 @@ function UIContextMenu(options){ }; // An item is clicked - $(`#context-menu-${menu_id} > li:not(.context-menu-item-disabled)`).on('click', function (e) { + $(document).on('click', `#context-menu-${menu_id} > li:not(.context-menu-item-disabled)`, function (e) { // onClick if(options.items[$(this).attr("data-action")].onClick && typeof options.items[$(this).attr("data-action")].onClick === 'function'){ diff --git a/src/gui/src/UI/UIDesktop.js b/src/gui/src/UI/UIDesktop.js index 38c80aeb..c9014c0e 100644 --- a/src/gui/src/UI/UIDesktop.js +++ b/src/gui/src/UI/UIDesktop.js @@ -1411,6 +1411,7 @@ $(document).on('click', '.user-options-menu-btn', async function(e){ //-------------------------------------------------- { html: i18n('contact_us'), + id: 'contact_us', onClick: async function(){ UIWindowFeedback(); } diff --git a/src/gui/src/extensions/modify-user-options-menu.js b/src/gui/src/extensions/modify-user-options-menu.js new file mode 100644 index 00000000..6991bf68 --- /dev/null +++ b/src/gui/src/extensions/modify-user-options-menu.js @@ -0,0 +1,27 @@ +$(window).on('ctxmenu-will-open', (event) => { + if(event.detail.options?.id === 'user-options-menu'){ + // Define array of new menu items + const newMenuItems = [ + // Separator + '-', + // 'Developer', opens developer site in new tab + { + id: 'go_to_developer_site', + html: 'Developer', + html_active: 'Developer ', + action: function(){ + window.open('https://developer.puter.com', '_blank'); + } + }, + ]; + + // Find the position of 'contact_us' + const items = event.detail.options.items; + const insertBeforeIndex = items.findIndex(item => item.id === 'contact_us'); + + // Insert all new items before 'contact_us' + const firstHalf = items.slice(0, insertBeforeIndex); + const secondHalf = items.slice(insertBeforeIndex); + event.detail.options.items = [...firstHalf, ...newMenuItems, ...secondHalf]; + } +}); \ No newline at end of file