From 3d7add5b66944b0474b011bdd048f904cff7ea4c Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Sun, 21 Jan 2018 19:30:54 +0000 Subject: [PATCH] cinera: Handle sorting state separately from UI Also add user-select: none --- cinera/cinera.c | 4 ++-- cinera/cinera.css | 3 +++ cinera/cinera_search.js | 23 +++++++++++------------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cinera/cinera.c b/cinera/cinera.c index 472f146..cae5b8d 100644 --- a/cinera/cinera.c +++ b/cinera/cinera.c @@ -14,7 +14,7 @@ typedef struct version CINERA_APP_VERSION = { .Major = 0, .Minor = 5, - .Patch = 28 + .Patch = 29 }; // TODO(matt): Copy in the DB 3 stuff from cinera_working.c @@ -4388,7 +4388,7 @@ IndexToBuffer(buffers *CollationBuffers) // NOTE(matt): This guy malloc's Collat "
\n" "\n" "
\n" - "
Sort: Old to New ⏶
\n" + "
Sort: Old to New ⏶
\n" "
\n", StringsDiffer(Config.Theme, "") ? Config.Theme : Config.ProjectID, StringsDiffer(Config.Theme, "") ? Config.Theme : Config.ProjectID); diff --git a/cinera/cinera.css b/cinera/cinera.css index eca11be..0f22a0c 100644 --- a/cinera/cinera.css +++ b/cinera/cinera.css @@ -45,6 +45,9 @@ display: inline-block; padding: 5px; cursor: pointer; + user-select: none; + -moz-user-select: none; + -webkit-user-select: none; } #cineraIndex #cineraIndexEntries { diff --git a/cinera/cinera_search.js b/cinera/cinera_search.js index 86ee431..2af9ed4 100644 --- a/cinera/cinera_search.js +++ b/cinera/cinera_search.js @@ -9,22 +9,21 @@ if (location.hash && location.hash.length > 0) { var indexContainer = document.getElementById("cineraIndex"); var indexSort = indexContainer.querySelector("#cineraIndexSort"); var indexEntries = indexContainer.querySelector("#cineraIndexEntries"); +var indexSortChronological = true; indexSort.addEventListener("click", function(ev) { - switch(this.getAttribute("data-id")) + if(indexSortChronological) { - case "chronal": - this.setAttribute("data-id", "reverse_chronal"); - this.firstChild.nodeValue = "Sort: New to Old ⏷" - indexEntries.classList.add("sort_reverse"); - break; - case "reverse_chronal": - this.setAttribute("data-id", "chronal"); - this.firstChild.nodeValue = "Sort: Old to New ⏶" - indexEntries.classList.remove("sort_reverse"); - break; + this.firstChild.nodeValue = "Sort: New to Old ⏷" + indexEntries.classList.add("sort_reverse"); } -}) + else + { + this.firstChild.nodeValue = "Sort: Old to New ⏶" + indexEntries.classList.remove("sort_reverse"); + } + indexSortChronological = !indexSortChronological; +}); var lastQuery = null; var resultsToRender = [];