mirror of
https://github.com/HeyPuter/puter.git
synced 2026-10-02 01:51:55 +00:00
adding ability to customise desktop by arranging items
This commit is contained in:
@@ -623,8 +623,28 @@ async function UIDesktop(options){
|
||||
{
|
||||
html: "Sort by",
|
||||
items: [
|
||||
{
|
||||
html: `Auto Arrange`,
|
||||
icon: is_auto_arrange_enabled ? '✓' : '',
|
||||
onClick: async function(){
|
||||
is_auto_arrange_enabled = !is_auto_arrange_enabled;
|
||||
store_auto_arrange_preference(is_auto_arrange_enabled);
|
||||
if(is_auto_arrange_enabled){
|
||||
sort_items(el_desktop, $(el_desktop).attr('data-sort_by'), $(el_desktop).attr('data-sort_order'));
|
||||
set_sort_by(options.desktop_fsentry.uid, $(el_desktop).attr('data-sort_by'), $(el_desktop).attr('data-sort_order'))
|
||||
clear_desktop_item_positions(el_desktop);
|
||||
}else{
|
||||
set_desktop_item_positions(el_desktop)
|
||||
}
|
||||
}
|
||||
},
|
||||
// -------------------------------------------
|
||||
// -
|
||||
// -------------------------------------------
|
||||
'-',
|
||||
{
|
||||
html: `Name`,
|
||||
disabled: !is_auto_arrange_enabled,
|
||||
icon: $(el_desktop).attr('data-sort_by') === 'name' ? '✓' : '',
|
||||
onClick: async function(){
|
||||
sort_items(el_desktop, 'name', $(el_desktop).attr('data-sort_order'));
|
||||
@@ -633,6 +653,7 @@ async function UIDesktop(options){
|
||||
},
|
||||
{
|
||||
html: `Date modified`,
|
||||
disabled: !is_auto_arrange_enabled,
|
||||
icon: $(el_desktop).attr('data-sort_by') === 'modified' ? '✓' : '',
|
||||
onClick: async function(){
|
||||
sort_items(el_desktop, 'modified', $(el_desktop).attr('data-sort_order'));
|
||||
@@ -641,6 +662,7 @@ async function UIDesktop(options){
|
||||
},
|
||||
{
|
||||
html: `Type`,
|
||||
disabled: !is_auto_arrange_enabled,
|
||||
icon: $(el_desktop).attr('data-sort_by') === 'type' ? '✓' : '',
|
||||
onClick: async function(){
|
||||
sort_items(el_desktop, 'type', $(el_desktop).attr('data-sort_order'));
|
||||
@@ -649,6 +671,7 @@ async function UIDesktop(options){
|
||||
},
|
||||
{
|
||||
html: `Size`,
|
||||
disabled: !is_auto_arrange_enabled,
|
||||
icon: $(el_desktop).attr('data-sort_by') === 'size' ? '✓' : '',
|
||||
onClick: async function(){
|
||||
sort_items(el_desktop, 'size', $(el_desktop).attr('data-sort_order'));
|
||||
@@ -661,6 +684,7 @@ async function UIDesktop(options){
|
||||
'-',
|
||||
{
|
||||
html: `Ascending`,
|
||||
disabled: !is_auto_arrange_enabled,
|
||||
icon: $(el_desktop).attr('data-sort_order') === 'asc' ? '✓' : '',
|
||||
onClick: async function(){
|
||||
const sort_by = $(el_desktop).attr('data-sort_by')
|
||||
@@ -670,6 +694,7 @@ async function UIDesktop(options){
|
||||
},
|
||||
{
|
||||
html: `Descending`,
|
||||
disabled: !is_auto_arrange_enabled,
|
||||
icon: $(el_desktop).attr('data-sort_order') === 'desc' ? '✓' : '',
|
||||
onClick: async function(){
|
||||
const sort_by = $(el_desktop).attr('data-sort_by')
|
||||
|
||||
@@ -187,6 +187,13 @@ function UIItem(options){
|
||||
update_explorer_footer_item_count(el_window);
|
||||
}
|
||||
|
||||
// position
|
||||
if(!is_auto_arrange_enabled && options.position && $(el_item).attr('data-path') !== trash_path){
|
||||
el_item.style.position = 'absolute';
|
||||
el_item.style.left = options.position.left + 'px';
|
||||
el_item.style.top = options.position.top + 'px';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// Dragster
|
||||
// allow dragging of local files on this window, if it's is_dir
|
||||
@@ -335,6 +342,13 @@ function UIItem(options){
|
||||
}
|
||||
},
|
||||
stop: function(event, ui){
|
||||
if(!is_auto_arrange_enabled && $(el_item).attr('data-path') !== trash_path){
|
||||
el_item.style.position = 'absolute';
|
||||
el_item.style.left = ui.position.left + 'px';
|
||||
el_item.style.top = ui.position.top + 'px';
|
||||
$('.ui-draggable-dragging').remove();
|
||||
save_item_position($(el_item).attr('data-uid'), ui.position)
|
||||
}
|
||||
$('.item-selected-clone').remove();
|
||||
$('.draggable-count-badge').remove();
|
||||
// re-enable all droppable UIItems that are not a dir
|
||||
|
||||
Reference in New Issue
Block a user