Skip to content

Commit

Permalink
Merge pull request #20 from theohbrothers/enhancement/gallery-add-key…
Browse files Browse the repository at this point in the history
…board-shortcut-s-to-toggle-sort-mode

Enhancement (gallery): Add keyboard shortcut 'S' to toggle sort mode
  • Loading branch information
leojonathanoh authored Aug 27, 2021
2 parents 189569f + 5a9d172 commit 6f88173
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ Keyboard shortcuts:
| `=` | Mode: Tile larger
| `L` | Mode: Show / Hide label
| `P` | Menu: Pin / Unpin menu
| `S` | Menu: Toggle sort mode
16 changes: 10 additions & 6 deletions webize
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ if [ -n "$GALLERY" ]; then
<tilelarger title="Tile larger (+)" alt="Tile larger (=)">🦕</tilelarger>
<imagelabeller title="Show / Hide label (L)" alt="Show / Hide label (L)">🏷</imagelabeller>
<pin title="Pin / Unpin menu (P)" alt="Pin / Unpin menu (P)">📌</pin>
<sort title="Change sort order" alt="Change sort order"></sort><!-- innerHTML will be injected on DOMContentLoaded -->
<sort title="Toggle sort mode" alt="Toggle sort mode"></sort><!-- innerHTML will be injected on DOMContentLoaded -->
</menu>
<content>
<gallery></gallery>
Expand Down Expand Up @@ -340,6 +340,10 @@ cat - >> "$indexHtm" <<'EOF'
if (keyCode === 80) {
togglePinHandler();
}
// s key
if (keyCode === 83) {
toggleSortMode();
}
// console.log(keyCode);
};
Expand Down Expand Up @@ -523,7 +527,7 @@ cat - >> "$indexHtm" <<'EOF'
}
};
var setMode = function(value) {
var setMode = function(value, preserve) {
var modePrev = mode;
if (value) {
mode = value;
Expand All @@ -537,16 +541,16 @@ cat - >> "$indexHtm" <<'EOF'
break;
case "tilesmaller":
if (modePrev === "tilesmaller" || modePrev === "tilelarger") {
tilesmaller();
tilesmaller(preserve);
}else {
tilesmaller(true);
}
break;
case "tilelarger":
if (modePrev === "tilesmaller" || modePrev === "tilelarger") {
tilelarger();
tilesmaller(preserve);
}else {
tilelarger(true);
tilesmaller(true);
}
break;
default:
Expand Down Expand Up @@ -633,7 +637,7 @@ cat - >> "$indexHtm" <<'EOF'
var sort = function(sortMode) {
createImageComponents(sortMode);
setMode(mode);
setMode(mode, true);
}
var keyHandler = function(event) {
Expand Down

0 comments on commit 6f88173

Please sign in to comment.