diff --git a/src/gui/src/UI/UIDesktop.js b/src/gui/src/UI/UIDesktop.js index c05469b9c..9ca338a6e 100644 --- a/src/gui/src/UI/UIDesktop.js +++ b/src/gui/src/UI/UIDesktop.js @@ -43,24 +43,62 @@ import launch_app from "../helpers/launch_app.js" import item_icon from "../helpers/item_icon.js" import UIWindowSearch from "./UIWindowSearch.js" -async function UIDesktop(options){ +async function UIDesktop(options) { let h = ''; // Set up the desktop channel for communication between different tabs in the same browser window.channel = new BroadcastChannel('puter-desktop-channel'); - channel.onmessage = function(e){ + channel.onmessage = function (e) { } + // Initialize desktop icons visibility preference - move this earlier in the initialization + // Add this near the very beginning of the UIDesktop function + window.desktop_icons_hidden = false; // Set default value immediately + + // Initialize the preference early + puter.kv.get('desktop_icons_hidden').then(async (val) => { + window.desktop_icons_hidden = val === 'true'; + + // Apply the setting immediately if needed + if (window.desktop_icons_hidden) { + hideDesktopIcons(); + } + }); + + // Modify the hide/show functions to use CSS rules that will apply to all icons, including future ones + window.hideDesktopIcons = function () { + // Add a CSS class to the desktop container that will hide all child icons + $('.desktop.item-container').addClass('desktop-icons-hidden'); + }; + + window.showDesktopIcons = function () { + // Remove the CSS class to show all icons + $('.desktop.item-container').removeClass('desktop-icons-hidden'); + }; + + // Add this function to the global scope + window.toggleDesktopIcons = function () { + window.desktop_icons_hidden = !window.desktop_icons_hidden; + + if (window.desktop_icons_hidden) { + hideDesktopIcons(); + } else { + showDesktopIcons(); + } + + // Save preference + puter.kv.set('desktop_icons_hidden', window.desktop_icons_hidden.toString()); + }; // Give Camera and Recorder write permissions to Desktop puter.kv.get('has_set_default_app_user_permissions').then(async (user_permissions) => { - if(!user_permissions){ + if (!user_permissions) { // Camera - try{ - await fetch( window.api_origin + "/auth/grant-user-app", { + try { + await fetch(window.api_origin + "/auth/grant-user-app", { "headers": { - "Content-Type": "application/json", - "Authorization": "Bearer " + window.auth_token, + "Content-Type": "application/json", + "Authorization": "Bearer " + window.auth_token, }, "body": JSON.stringify({ app_uid: 'app-5584fbf7-ed69-41fc-99cd-85da21b1ef51', @@ -68,16 +106,16 @@ async function UIDesktop(options){ }), "method": "POST", }); - }catch(err){ + } catch (err) { console.error(err); } // Recorder - try{ - await fetch( window.api_origin + "/auth/grant-user-app", { + try { + await fetch(window.api_origin + "/auth/grant-user-app", { "headers": { - "Content-Type": "application/json", - "Authorization": "Bearer " + window.auth_token, + "Content-Type": "application/json", + "Authorization": "Bearer " + window.auth_token, }, "body": JSON.stringify({ app_uid: 'app-7bdca1a4-6373-4c98-ad97-03ff2d608ca1', @@ -85,7 +123,7 @@ async function UIDesktop(options){ }), "method": "POST", }); - }catch(err){ + } catch (err) { console.error(err); } @@ -103,13 +141,13 @@ async function UIDesktop(options){ window.socket.on('error', (error) => { console.error('GUI Socket Error:', error); }); - - window.socket.on('connect', function(){ + + window.socket.on('connect', function () { // console.log('GUI Socket: Connected', window.socket.id); window.socket.emit('puter_is_actually_open'); }); - window.socket.on('reconnect', function(){ + window.socket.on('reconnect', function () { console.log('GUI Socket: Reconnected', window.socket.id); }); @@ -138,17 +176,17 @@ async function UIDesktop(options){ }); window.socket.on('upload.progress', (msg) => { - if(window.progress_tracker[msg.operation_id]){ + if (window.progress_tracker[msg.operation_id]) { window.progress_tracker[msg.operation_id].cloud_uploaded += msg.loaded_diff - if(window.progress_tracker[msg.operation_id][msg.item_upload_id]){ + if (window.progress_tracker[msg.operation_id][msg.item_upload_id]) { window.progress_tracker[msg.operation_id][msg.item_upload_id].cloud_uploaded = msg.loaded; } } }); window.socket.on('download.progress', (msg) => { - if(window.progress_tracker[msg.operation_id]){ - if(window.progress_tracker[msg.operation_id][msg.item_upload_id]){ + if (window.progress_tracker[msg.operation_id]) { + if (window.progress_tracker[msg.operation_id][msg.item_upload_id]) { window.progress_tracker[msg.operation_id][msg.item_upload_id].downloaded = msg.loaded; window.progress_tracker[msg.operation_id][msg.item_upload_id].total = msg.total; } @@ -159,10 +197,10 @@ async function UIDesktop(options){ $(`.item[data-path="${html_encode(window.trash_path)}" i]`).find('.item-icon > img').attr('src', msg.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg']); $(`.window[data-path="${html_encode(window.trash_path)}" i]`).find('.window-head-icon').attr('src', msg.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg']); // empty trash windows if needed - if(msg.is_empty) + if (msg.is_empty) $(`.window[data-path="${html_encode(window.trash_path)}" i]`).find('.item-container').empty(); }) - + /** * This event is triggered if a user receives a notification during * an active session. @@ -171,14 +209,14 @@ async function UIDesktop(options){ let icon = window.icons[notification.icon]; let round_icon = false; - if(notification.template === "file-shared-with-you" && notification.fields?.username){ + if (notification.template === "file-shared-with-you" && notification.fields?.username) { let profile_pic = await get_profile_picture(notification.fields?.username); - if(profile_pic){ + if (profile_pic) { icon = profile_pic; round_icon = true; } } - + UINotification({ title: notification.title, text: notification.text, @@ -197,12 +235,12 @@ async function UIDesktop(options){ }); }, click: async (notif) => { - if(notification.template === "file-shared-with-you"){ + if (notification.template === "file-shared-with-you") { let item_path = '/' + notification.fields.username; UIWindow({ path: '/' + notification.fields.username, title: path.basename(item_path), - icon: await item_icon({is_dir: true, path: item_path}), + icon: await item_icon({ is_dir: true, path: item_path }), is_dir: true, app: 'explorer', }); @@ -221,22 +259,22 @@ async function UIDesktop(options){ */ window.__already_got_unreads = false; window.socket.on('notif.unreads', async ({ unreads }) => { - if ( window.__already_got_unreads ) return; + if (window.__already_got_unreads) return; window.__already_got_unreads = true; - for ( const notif_info of unreads ) { + for (const notif_info of unreads) { const notification = notif_info.notification; let icon = window.icons[notification.icon]; let round_icon = false; - if(notification.template === "file-shared-with-you" && notification.fields?.username){ + if (notification.template === "file-shared-with-you" && notification.fields?.username) { let profile_pic = await get_profile_picture(notification.fields?.username); - if(profile_pic){ + if (profile_pic) { icon = profile_pic; round_icon = true; } } - + UINotification({ icon, round_icon, @@ -256,12 +294,12 @@ async function UIDesktop(options){ }); }, click: async (notif) => { - if(notification.template === "file-shared-with-you"){ + if (notification.template === "file-shared-with-you") { let item_path = '/' + notification.fields?.username; UIWindow({ path: '/' + notification.fields?.username, title: path.basename(item_path), - icon: await item_icon({is_dir: true, path: item_path}), + icon: await item_icon({ is_dir: true, path: item_path }), is_dir: true, app: 'explorer', }); @@ -278,9 +316,9 @@ async function UIDesktop(options){ window.socket.on('app.opened', async (app) => { // don't update if this is the original client that initiated the action - if(app.original_client_socket_id === window.socket.id) + if (app.original_client_socket_id === window.socket.id) return; - + // add the app to the beginning of the array window.launch_apps.recent.unshift(app); @@ -293,15 +331,15 @@ async function UIDesktop(options){ window.socket.on('item.removed', async (item) => { // don't update if this is the original client that initiated the action - if(item.original_client_socket_id === window.socket.id) + if (item.original_client_socket_id === window.socket.id) return; // don't remove items if this was a descendants_only operation - if(item.descendants_only) + if (item.descendants_only) return; // hide all UIItems with matching uids - $(`.item[data-path='${item.path}']`).fadeOut(150, function(){ + $(`.item[data-path='${item.path}']`).fadeOut(150, function () { // close all windows with matching uids // $('.window-' + item.uid).close(); // close all windows that belong to a descendant of this item @@ -312,7 +350,7 @@ async function UIDesktop(options){ window.socket.on('item.updated', async (item) => { // Don't update if this is the original client that initiated the action - if(item.original_client_socket_id === window.socket.id) + if (item.original_client_socket_id === window.socket.id) return; // Update matching items @@ -342,31 +380,31 @@ async function UIDesktop(options){ $(`.window-${item.uid}`).attr('data-path', new_path); // Update all elements that have matching paths - $(`[data-path="${html_encode(item.old_path)}" i]`).each(function(){ + $(`[data-path="${html_encode(item.old_path)}" i]`).each(function () { $(this).attr('data-path', new_path) - if($(this).hasClass('window-navbar-path-dirname')) + if ($(this).hasClass('window-navbar-path-dirname')) $(this).text(item.name); }); // Update all elements whose paths start with old_path - $(`[data-path^="${html_encode(item.old_path) + '/'}"]`).each(function(){ - const new_el_path = _.replace($(this).attr('data-path'), item.old_path + '/', new_path+'/'); + $(`[data-path^="${html_encode(item.old_path) + '/'}"]`).each(function () { + const new_el_path = _.replace($(this).attr('data-path'), item.old_path + '/', new_path + '/'); $(this).attr('data-path', new_el_path); }); // Update all exact-matching windows - $(`.window-${item.uid}`).each(function(){ + $(`.window-${item.uid}`).each(function () { window.update_window_path(this, new_path); }) // Set new name for matching open windows $(`.window-${item.uid} .window-head-title`).text(item.name); // Re-sort all matching item containers - $(`.item[data-uid='${item.uid}']`).parent('.item-container').each(function(){ + $(`.item[data-uid='${item.uid}']`).parent('.item-container').each(function () { window.sort_items(this, $(this).closest('.item-container').attr('data-sort_by'), $(this).closest('.item-container').attr('data-sort_order')); }) }) - + window.socket.on('item.moved', async (resp) => { let fsentry = resp; // Notify all apps that are watching this item @@ -377,7 +415,7 @@ async function UIDesktop(options){ }) // don't update if this is the original client that initiated the action - if(resp.original_client_socket_id === window.socket.id) + if (resp.original_client_socket_id === window.socket.id) return; let dest_path = path.dirname(fsentry.path); @@ -385,40 +423,40 @@ async function UIDesktop(options){ // update all shortcut_to_path $(`.item[data-shortcut_to_path="${html_encode(resp.old_path)}" i]`).attr(`data-shortcut_to_path`, html_encode(fsentry.path)); - + // remove all items with matching uids - $(`.item[data-uid='${fsentry.uid}']`).fadeOut(150, function(){ + $(`.item[data-uid='${fsentry.uid}']`).fadeOut(150, function () { // find all parent windows that contain this item let parent_windows = $(`.item[data-uid='${fsentry.uid}']`).closest('.window'); // remove this item $(this).removeItems(); // update parent windows' item counts - $(parent_windows).each(function(index){ + $(parent_windows).each(function (index) { window.update_explorer_footer_item_count(this); window.update_explorer_footer_selected_items_count(this) }); }) // if trashing, close windows of trashed items and its descendants - if(dest_path === window.trash_path){ + if (dest_path === window.trash_path) { $(`.window[data-path="${html_encode(resp.old_path)}" i]`).close(); // todo this has to be case-insensitive but the `i` selector doesn't work on ^= $(`.window[data-path^="${html_encode(resp.old_path)}/"]`).close(); } // update all paths of its and its descendants' open windows - else{ + else { // todo this has to be case-insensitive but the `i` selector doesn't work on ^= - $(`.window[data-path^="${html_encode(resp.old_path)}/"], .window[data-path="${html_encode(resp.old_path)}" i]`).each(function(){ + $(`.window[data-path^="${html_encode(resp.old_path)}/"], .window[data-path="${html_encode(resp.old_path)}" i]`).each(function () { window.update_window_path(this, $(this).attr('data-path').replace(resp.old_path, fsentry.path)); }) } - if(dest_path === window.trash_path){ + if (dest_path === window.trash_path) { $(`.item[data-uid="${fsentry.uid}"]`).find('.item-is-shared').fadeOut(300); // if trashing dir... - if(fsentry.is_dir){ + if (fsentry.is_dir) { // remove website badge $(`.mywebsites-dir-path[data-uuid="${fsentry.uid}"]`).remove(); // remove the website badge from all instances of the dir @@ -429,7 +467,7 @@ async function UIDesktop(options){ } } // if replacing an existing item, remove the old item that was just replaced - if(fsentry.overwritten_uid !== undefined) + if (fsentry.overwritten_uid !== undefined) $(`.item[data-uid=${fsentry.overwritten_uid}]`).removeItems(); // if this is trash, get original name from item metadata @@ -456,14 +494,14 @@ async function UIDesktop(options){ metadata: JSON.stringify(fsentry.metadata) ?? '', }); - if(fsentry.parent_dirs_created && fsentry.parent_dirs_created.length > 0){ + if (fsentry.parent_dirs_created && fsentry.parent_dirs_created.length > 0) { // this operation may have created some missing directories, // see if any of the directories in the path of this file is new AND // if these new path have any open parents that need to be updated - + fsentry.parent_dirs_created.forEach(async dir => { let item_container = $(`.item-container[data-path='${html_encode(path.dirname(dir.path))}' i]`); - if(item_container.length > 0 && $(`.item[data-path="${html_encode(dir.path)}" i]`).length === 0){ + if (item_container.length > 0 && $(`.item[data-path="${html_encode(dir.path)}" i]`).length === 0) { UIItem({ appendTo: item_container, immutable: false, @@ -478,20 +516,20 @@ async function UIDesktop(options){ is_selected: false, is_shared: dir.is_shared, has_website: false, - }); - } + }); + } window.sort_items(item_container, $(item_container).attr('data-sort_by'), $(item_container).attr('data-sort_order')); - }); + }); } //sort each container - $(`.item-container[data-path='${html_encode(dest_path)}' i]`).each(function(){ + $(`.item-container[data-path='${html_encode(dest_path)}' i]`).each(function () { window.sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order')) }) }); - + window.socket.on('user.email_confirmed', (msg) => { // don't update if this is the original client that initiated the action - if(msg.original_client_socket_id === window.socket.id) + if (msg.original_client_socket_id === window.socket.id) return; window.refresh_user_data(window.auth_token); @@ -499,7 +537,7 @@ async function UIDesktop(options){ window.socket.on('user.email_changed', (msg) => { // don't update if this is the original client that initiated the action - if(msg.original_client_socket_id === window.socket.id) + if (msg.original_client_socket_id === window.socket.id) return; window.refresh_user_data(window.auth_token); @@ -516,7 +554,7 @@ async function UIDesktop(options){ }) // Don't update if this is the original client that initiated the action - if(item.original_client_socket_id === window.socket.id) + if (item.original_client_socket_id === window.socket.id) return; // Update matching items @@ -545,34 +583,34 @@ async function UIDesktop(options){ $(`.window-${item.uid}`).attr('data-path', new_path); // Update all elements that have matching paths - $(`[data-path="${html_encode(item.old_path)}" i]`).each(function(){ + $(`[data-path="${html_encode(item.old_path)}" i]`).each(function () { $(this).attr('data-path', new_path) - if($(this).hasClass('window-navbar-path-dirname')) + if ($(this).hasClass('window-navbar-path-dirname')) $(this).text(item.name); }); // Update all elements whose paths start with old_path - $(`[data-path^="${html_encode(item.old_path) + '/'}"]`).each(function(){ - const new_el_path = _.replace($(this).attr('data-path'), item.old_path + '/', new_path+'/'); + $(`[data-path^="${html_encode(item.old_path) + '/'}"]`).each(function () { + const new_el_path = _.replace($(this).attr('data-path'), item.old_path + '/', new_path + '/'); $(this).attr('data-path', new_el_path); }); // Update all exact-matching windows - $(`.window-${item.uid}`).each(function(){ + $(`.window-${item.uid}`).each(function () { window.update_window_path(this, new_path); }) // Set new name for matching open windows $(`.window-${item.uid} .window-head-title`).text(item.name); // Re-sort all matching item containers - $(`.item[data-uid='${item.uid}']`).parent('.item-container').each(function(){ + $(`.item[data-uid='${item.uid}']`).parent('.item-container').each(function () { window.sort_items(this, $(this).closest('.item-container').attr('data-sort_by'), $(this).closest('.item-container').attr('data-sort_order')); }) }); window.socket.on('item.added', async (item) => { // if item is empty, don't proceed - if(_.isEmpty(item)) + if (_.isEmpty(item)) return; // Notify all apps that are watching this item @@ -586,11 +624,11 @@ async function UIDesktop(options){ }); // Don't update if this is the original client that initiated the action - if(item.original_client_socket_id === window.socket.id) + if (item.original_client_socket_id === window.socket.id) return; // Update replaced items with matching uids - if(item.overwritten_uid){ + if (item.overwritten_uid) { $(`.item[data-uid='${item.overwritten_uid}']`).attr({ 'data-immutable': item.immutable, 'data-path': item.path, @@ -603,13 +641,13 @@ async function UIDesktop(options){ // set new icon const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await item_icon(item)).image); $(`.item[data-uid="${item.overwritten_uid}"]`).find('.item-icon > img').attr('src', new_icon); - + //sort each window - $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`).each(function(){ + $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`).each(function () { window.sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order')) - }) + }) } - else{ + else { UIItem({ appendTo: $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`), uid: item.uid, @@ -629,7 +667,7 @@ async function UIDesktop(options){ }); //sort each window - $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`).each(function(){ + $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`).each(function () { window.sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order')) }) } @@ -641,9 +679,9 @@ async function UIDesktop(options){ `; - + h += `
`; - + // Desktop // If desktop is not in fullpage/embedded mode, we hide it until files and directories are loaded and then fade in the UI // This gives a calm and smooth experience for the user @@ -659,7 +697,7 @@ async function UIDesktop(options){ puter.kv.get('window_sidebar_width').then(async (val) => { let value = parseInt(val); // if value is a valid number - if(!isNaN(value) && value > 0){ + if (!isNaN(value) && value > 0) { window.window_sidebar_width = value; } }) @@ -678,29 +716,29 @@ async function UIDesktop(options){ // Get menubar style puter.kv.get('menubar_style').then(async (val) => { let value = val; - if(value === 'system' || value === 'desktop' || value === 'window'){ + if (value === 'system' || value === 'desktop' || value === 'window') { window.menubar_style = value; - }else{ + } else { window.menubar_style = 'system'; } - if(window.menubar_style === 'system'){ - if(window.detectHostOS() === 'macos') + if (window.menubar_style === 'system') { + if (window.detectHostOS() === 'macos') window.menubar_style = 'desktop'; else window.menubar_style = 'window'; } // set menubar style class to body - if(window.menubar_style === 'desktop'){ + if (window.menubar_style === 'desktop') { $('body').addClass('menubar-style-desktop'); } }) // Remove `?ref=...` from navbar URL - if(window.url_query_params.has('ref')){ - window.history.pushState(null, document.title, '/'); + if (window.url_query_params.has('ref')) { + window.history.pushState(null, document.title, '/'); } // update local user preferences @@ -712,7 +750,7 @@ async function UIDesktop(options){ // update default apps puter.kv.list('user_preferences.default_apps.*').then(async (default_app_keys) => { - for(let key in default_app_keys){ + for (let key in default_app_keys) { user_preferences[default_app_keys[key].substring(17)] = await puter.kv.get(default_app_keys[key]); } @@ -747,10 +785,10 @@ async function UIDesktop(options){ drop: async function (dragsterEvent, event) { const e = event.originalEvent; // no drop on item - if($(event.target).hasClass('item') || $(event.target).parent('.item').length > 0) + if ($(event.target).hasClass('item') || $(event.target).parent('.item').length > 0) return false; // recursively create directories and upload files - if(e.dataTransfer?.items?.length>0){ + if (e.dataTransfer?.items?.length > 0) { window.upload_items(e.dataTransfer.items, window.desktop_path); } @@ -766,21 +804,21 @@ async function UIDesktop(options){ $(el_desktop).droppable({ accept: '.item', tolerance: "intersect", - drop: function( event, ui ) { + drop: function (event, ui) { // Check if item was actually dropped on desktop and not a window - if(window.mouseover_window !== undefined) + if (window.mouseover_window !== undefined) return; - + // Can't drop anything but UIItems on desktop - if(!$(ui.draggable).hasClass('item')) + if (!$(ui.draggable).hasClass('item')) return; - + // Don't move an item to its current directory - if( path.dirname($(ui.draggable).attr('data-path')) === window.desktop_path && !event.ctrlKey) + if (path.dirname($(ui.draggable).attr('data-path')) === window.desktop_path && !event.ctrlKey) return; - + // If ctrl is pressed and source is Trashed, cancel whole operation - if(event.ctrlKey && path.dirname($(ui.draggable).attr('data-path')) === window.trash_path) + if (event.ctrlKey && path.dirname($(ui.draggable).attr('data-path')) === window.trash_path) return; // Unselect previously selected items @@ -792,22 +830,22 @@ async function UIDesktop(options){ // all subsequent items const cloned_items = document.getElementsByClassName('item-selected-clone'); - for(let i =0; i${i18n('confirm_open_apps_log_out')}
`, - buttons:[ + buttons: [ { label: i18n('close_all_windows_and_log_out'), value: 'close_and_log_out', @@ -1556,7 +1605,7 @@ $(document).on('click', '.user-options-menu-btn', async function(e){ }, ] }) - if(alert_resp === 'close_and_log_out') + if (alert_resp === 'close_and_log_out') window.logout(); } // no open windows @@ -1565,11 +1614,11 @@ $(document).on('click', '.user-options-menu-btn', async function(e){ } }, ] - }); + }); }) $(document).on('click', '.fullscreen-btn', async function (e) { - if(!window.is_fullscreen()) { + if (!window.is_fullscreen()) { var elem = document.documentElement; if (elem.requestFullscreen) { elem.requestFullscreen(); @@ -1581,7 +1630,7 @@ $(document).on('click', '.fullscreen-btn', async function (e) { elem.msRequestFullscreen(); } } - else{ + else { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.webkitExitFullscreen) { @@ -1590,49 +1639,49 @@ $(document).on('click', '.fullscreen-btn', async function (e) { document.mozCancelFullScreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); - } - } + } + } }) -$(document).on('click', '.close-launch-popover', function(){ - $(".launch-popover").closest('.popover').fadeOut(200, function(){ +$(document).on('click', '.close-launch-popover', function () { + $(".launch-popover").closest('.popover').fadeOut(200, function () { $(".launch-popover").closest('.popover').remove(); }); }); -$(document).on('click', '.search-btn', function(){ +$(document).on('click', '.search-btn', function () { UIWindowSearch(); }) -$(document).on('click', '.toolbar-puter-logo', function(){ +$(document).on('click', '.toolbar-puter-logo', function () { UIWindowSettings(); }) -$(document).on('click', '.user-options-create-account-btn', async function(e){ +$(document).on('click', '.user-options-create-account-btn', async function (e) { UIWindowSaveAccount({ send_confirmation_code: false, default_username: window.user.username, }); }) -$(document).on('click', '.refer-btn', async function(e){ +$(document).on('click', '.refer-btn', async function (e) { UIWindowRefer(); }) -$(document).on('click', '.start-app', async function(e){ +$(document).on('click', '.start-app', async function (e) { launch_app({ name: $(this).attr('data-app-name') }) // close popovers - $(".popover").fadeOut(200, function(){ + $(".popover").fadeOut(200, function () { $(".popover").remove(); }); }) -$(document).on('click', '.user-options-login-btn', async function(e){ +$(document).on('click', '.user-options-login-btn', async function (e) { const alert_resp = await UIAlert({ message: `Save session before exiting!You are in a temporary session and logging into another account will erase all data in your current session.
`, - buttons:[ + buttons: [ { label: i18n('save_session'), value: 'save-session', @@ -1647,16 +1696,16 @@ $(document).on('click', '.user-options-login-btn', async function(e){ }, ] }) - - if(alert_resp === 'save-session'){ + + if (alert_resp === 'save-session') { let saved = await UIWindowSaveAccount({ send_confirmation_code: false, }); - if(saved) - UIWindowLogin({show_signup_button: false, reload_on_success: true}); - }else if (alert_resp === 'login'){ + if (saved) + UIWindowLogin({ show_signup_button: false, reload_on_success: true }); + } else if (alert_resp === 'login') { UIWindowLogin({ - show_signup_button: false, + show_signup_button: false, reload_on_success: true, window_options: { backdrop: true, @@ -1666,7 +1715,7 @@ $(document).on('click', '.user-options-login-btn', async function(e){ } }) -$(document).on('click mousedown', '.launch-search, .launch-popover', function(e){ +$(document).on('click mousedown', '.launch-search, .launch-popover', function (e) { $(this).focus(); e.stopPropagation(); e.preventDefault(); @@ -1674,36 +1723,36 @@ $(document).on('click mousedown', '.launch-search, .launch-popover', function(e) e.stopImmediatePropagation(); }) -$(document).on('focus', '.launch-search', function(e){ +$(document).on('focus', '.launch-search', function (e) { // remove all selected items in start menu $('.launch-app-selected').removeClass('launch-app-selected'); // scroll popover to top $('.launch-popover').scrollTop(0); }) -$(document).on('change keyup keypress keydown paste', '.launch-search', function(e){ +$(document).on('change keyup keypress keydown paste', '.launch-search', function (e) { // search window.launch_apps.recommended for query const query = $(this).val().toLowerCase(); - if(query === ''){ + if (query === '') { $('.launch-search-clear').hide(); $(`.start-app-card`).show(); $('.launch-apps-recent').show(); $('.start-section-heading').show(); - }else{ + } else { $('.launch-apps-recent').hide(); $('.start-section-heading').hide(); $('.launch-search-clear').show(); - window.launch_apps.recommended.forEach((app)=>{ - if(app.title.toLowerCase().includes(query.toLowerCase())){ + window.launch_apps.recommended.forEach((app) => { + if (app.title.toLowerCase().includes(query.toLowerCase())) { $(`.start-app-card[data-name="${app.name}"]`).show(); - }else{ + } else { $(`.start-app-card[data-name="${app.name}"]`).hide(); } }) } }) -$(document).on('click', '.launch-search-clear', function(e){ +$(document).on('click', '.launch-search-clear', function (e) { $('.launch-search').val(''); $('.launch-search').trigger('change'); $('.launch-search').focus(); @@ -1725,33 +1774,33 @@ document.addEventListener('fullscreenchange', (event) => { } }) -window.set_desktop_background = function(options){ - if(options.fit){ +window.set_desktop_background = function (options) { + if (options.fit) { let fit = options.fit; - if(fit === 'cover' || fit === 'contain'){ + if (fit === 'cover' || fit === 'contain') { $('body').css('background-size', fit); $('body').css('background-repeat', `no-repeat`); $('body').css('background-position', `center center`); } - else if(fit === 'center'){ + else if (fit === 'center') { $('body').css('background-size', 'auto'); $('body').css('background-repeat', `no-repeat`); $('body').css('background-position', `center center`); } - else if( fit === 'repeat'){ + else if (fit === 'repeat') { $('body').css('background-size', `auto`); $('body').css('background-repeat', `repeat`); } window.desktop_bg_fit = fit; } - if(options.url){ + if (options.url) { $('body').css('background-image', `url(${options.url})`); window.desktop_bg_url = options.url; window.desktop_bg_color = undefined; } - else if(options.color){ + else if (options.color) { $('body').css({ 'background-image': `none`, 'background-color': options.color, @@ -1761,11 +1810,11 @@ window.set_desktop_background = function(options){ } } -window.update_taskbar = function(){ +window.update_taskbar = function () { let items = [] - $('.taskbar-item-sortable[data-keep-in-taskbar="true"]').each(function(index){ + $('.taskbar-item-sortable[data-keep-in-taskbar="true"]').each(function (index) { items.push({ - name: $( this ).attr('data-app'), + name: $(this).attr('data-app'), type: 'app', }) }) @@ -1780,20 +1829,20 @@ window.update_taskbar = function(){ async: true, contentType: "application/json", headers: { - "Authorization": "Bearer "+window.auth_token + "Authorization": "Bearer " + window.auth_token }, }) } -window.remove_taskbar_item = function(item){ - $(item).find('*').fadeOut(100, function(){}); +window.remove_taskbar_item = function (item) { + $(item).find('*').fadeOut(100, function () { }); - $(item).animate({width: 0}, 200, function(){ + $(item).animate({ width: 0 }, 200, function () { $(item).remove(); }) } -window.enter_fullpage_mode = (el_window)=>{ +window.enter_fullpage_mode = (el_window) => { $('.taskbar').hide(); $(el_window).find('.window-head').hide(); $('body').addClass('fullpage-mode'); @@ -1806,14 +1855,14 @@ window.enter_fullpage_mode = (el_window)=>{ }); } -window.exit_fullpage_mode = (el_window)=>{ +window.exit_fullpage_mode = (el_window) => { $('body').removeClass('fullpage-mode'); window.taskbar_height = window.default_taskbar_height; $('.taskbar').css('height', window.taskbar_height); $('.taskbar').show(); - refresh_item_container($('.desktop.item-container'), {fadeInItems: true}); + refresh_item_container($('.desktop.item-container'), { fadeInItems: true }); $(el_window).removeAttr('data-is_fullpage'); - if(el_window){ + if (el_window) { window.reset_window_size_and_position(el_window) $(el_window).find('.window-head').show(); } @@ -1828,7 +1877,7 @@ window.exit_fullpage_mode = (el_window)=>{ window.refresh_desktop_background(); } -window.reset_window_size_and_position = (el_window)=>{ +window.reset_window_size_and_position = (el_window) => { $(el_window).css({ width: 680, height: 380, @@ -1837,5 +1886,5 @@ window.reset_window_size_and_position = (el_window)=>{ left: 'calc(50% - 340px)', }); } - + export default UIDesktop; \ No newline at end of file diff --git a/src/gui/src/css/style.css b/src/gui/src/css/style.css index 5e2b98ae9..58c50d19a 100644 --- a/src/gui/src/css/style.css +++ b/src/gui/src/css/style.css @@ -4718,4 +4718,9 @@ fieldset[name=number-code] { } .device-phone .window-body.item-container * { touch-action: pan-y; +} + +/* Hide desktop icons when the desktop-icons-hidden class is applied */ +.desktop.item-container.desktop-icons-hidden > .item { + visibility: hidden; } \ No newline at end of file