+ style:top="{top > screenHeight - 2*required_height ? `-${(item.items.length-2)*100}%` : '0'} ">
{#each item.items as item}
+ {#if item}
{
@@ -113,9 +114,12 @@
item.action();
}
}}>
-
+
{#if item.icon}

+ {:else if item.check}
+
{/if}
+ {:else}
+
+ {/if}
{/each}
{/if}
diff --git a/src/lib/components/xp/context_menu/CMDesktop.js b/src/lib/components/xp/context_menu/CMDesktop.js
index e8a1d41..a684b17 100644
--- a/src/lib/components/xp/context_menu/CMDesktop.js
+++ b/src/lib/components/xp/context_menu/CMDesktop.js
@@ -1,30 +1,55 @@
import { queueProgram, clipboard, hardDrive } from '../../../store';
import { get } from 'svelte/store';
-import { recycle_bin_id, protected_items } from '../../../system';
+import { recycle_bin_id, protected_items, SortOptions, SortOrders } from '../../../system';
import * as fs from '../../../fs';
export let make = ({type, originator}) => {
- //originator: program
+
+ let sort_menu_items = [
+ {name: 'None', value: SortOptions.NONE},
+ {name: 'Name', value: SortOptions.NAME},
+ {name: 'Size', value: SortOptions.SIZE},
+ {name: 'Date Created', value: SortOptions.DATE_CREATED},
+ {name: 'Date Modified', value: SortOptions.DATE_MODIFIED}
+ ]
+ let sort_order_menu_items = [
+ {name: 'Ascending', value: SortOrders.ASCENDING},
+ {name: 'Descending', value: SortOrders.DESCENDING}
+ ]
+
return {
required_width: 180 + 20,
required_height: 27*6 + 20,
menu: [
[
{
- name: 'Arrange Icons By',
+ name: 'Sort By',
items: [
- {
- name: 'Name'
- },
- {
- name: 'Size'
- },
- {
- name: 'Type'
- },
- {
- name: 'Modified'
- }
+ ...sort_menu_items.map(item => {
+ return {
+ ...item,
+ check: item.value == get(hardDrive)[originator.id].sort_option,
+ action: () => {
+ hardDrive.update(data => {
+ data[originator.id].sort_option = item.value;
+ return data;
+ })
+ }
+ }
+ }),
+ null,
+ ...sort_order_menu_items.map(item => {
+ return {
+ ...item,
+ check: item.value == get(hardDrive)[originator.id].sort_order,
+ action: () => {
+ hardDrive.update(data => {
+ data[originator.id].sort_order = item.value;
+ return data;
+ })
+ }
+ }
+ }),
]
},
{
diff --git a/src/lib/components/xp/context_menu/CMFSVoid.js b/src/lib/components/xp/context_menu/CMFSVoid.js
index 0fb5631..a202a89 100644
--- a/src/lib/components/xp/context_menu/CMFSVoid.js
+++ b/src/lib/components/xp/context_menu/CMFSVoid.js
@@ -1,34 +1,55 @@
import { queueProgram, clipboard, hardDrive } from '../../../store';
-import { recycle_bin_id} from '../../../system';
+import { recycle_bin_id, SortOptions, SortOrders} from '../../../system';
import { get } from 'svelte/store';
import * as fs from '../../../fs';
export let make = ({type, originator}) => {
- //originator: viewer
-
+ let sort_menu_items = [
+ {name: 'None', value: SortOptions.NONE},
+ {name: 'Name', value: SortOptions.NAME},
+ {name: 'Size', value: SortOptions.SIZE},
+ {name: 'Date Created', value: SortOptions.DATE_CREATED},
+ {name: 'Date Modified', value: SortOptions.DATE_MODIFIED}
+ ]
+ let sort_order_menu_items = [
+ {name: 'Ascending', value: SortOrders.ASCENDING},
+ {name: 'Descending', value: SortOrders.DESCENDING}
+ ]
- //originator: program
return {
required_width: 180 + 20,
required_height: 27*6 + 20,
menu: [
[
{
- name: 'Arrange Icons By',
+ name: 'Sort By',
items: [
- {
- name: 'Name'
- },
- {
- name: 'Size'
- },
- {
- name: 'Type'
- },
- {
- name: 'Modified'
- }
+ ...sort_menu_items.map(item => {
+ return {
+ ...item,
+ check: item.value == get(hardDrive)[originator.id].sort_option,
+ action: () => {
+ hardDrive.update(data => {
+ data[originator.id].sort_option = item.value;
+ return data;
+ })
+ }
+ }
+ }),
+ null,
+ ...sort_order_menu_items.map(item => {
+ return {
+ ...item,
+ check: item.value == get(hardDrive)[originator.id].sort_order,
+ action: () => {
+ hardDrive.update(data => {
+ data[originator.id].sort_order = item.value;
+ return data;
+ })
+ }
+ }
+ }),
]
},
{
diff --git a/src/lib/system.js b/src/lib/system.js
index d9f85bc..9fb10cf 100644
--- a/src/lib/system.js
+++ b/src/lib/system.js
@@ -82,7 +82,7 @@ export let SortOptions = Object.freeze({
DATE_MODIFIED: 4,
})
-export let SortOptionOrders = Object.freeze({
+export let SortOrders = Object.freeze({
ASCENDING: 0,
DESCENDING: 1
})
diff --git a/src/routes/xp/starting.svelte b/src/routes/xp/starting.svelte
index 5f8d657..3364753 100644
--- a/src/routes/xp/starting.svelte
+++ b/src/routes/xp/starting.svelte
@@ -4,7 +4,7 @@
import {set, get} from 'idb-keyval';
import axios from 'axios';
import { hardDrive, wallpaper, contextMenu } from '../../lib/store';
- import { bliss_wallpaper, wallpapers_folder, SortOptions, SortOptionOrders } from '../../lib/system';
+ import { bliss_wallpaper, wallpapers_folder, SortOptions, SortOrders } from '../../lib/system';
let dispatcher = createEventDispatcher();
let assets_loaded = false;
@@ -85,8 +85,8 @@
if(obj.sort_option == null){
obj.sort_option = SortOptions.NONE;
}
- if(obj.sort_option_order == null){
- obj.sort_option_order = SortOptionOrders.ASCENDING;
+ if(obj.sort_order == null){
+ obj.sort_order = SortOrders.ASCENDING;
}
}
}