cinera: Handle sorting state separately from UI

Also add user-select: none
This commit is contained in:
Matt Mascarenhas 2018-01-21 19:30:54 +00:00
parent d7d27f59b7
commit 3d7add5b66
3 changed files with 16 additions and 14 deletions

View File

@ -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
" <div id=\"cineraResults\"></div>\n"
"\n"
" <div id=\"cineraIndex\" class=\"%s\">\n"
" <div id=\"cineraIndexSort\" data-id=\"chronal\">Sort: Old to New &#9206;</div>\n"
" <div id=\"cineraIndexSort\">Sort: Old to New &#9206;</div>\n"
" <div id=\"cineraIndexEntries\">\n",
StringsDiffer(Config.Theme, "") ? Config.Theme : Config.ProjectID,
StringsDiffer(Config.Theme, "") ? Config.Theme : Config.ProjectID);

View File

@ -45,6 +45,9 @@
display: inline-block;
padding: 5px;
cursor: pointer;
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
}
#cineraIndex #cineraIndexEntries {

View File

@ -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 = [];