cinera_search_pre.js: Default to the List View
Also fix the 𝑛-ary Grid traversal PrevAscends case when the search page contains only one project at the top-level.
This commit is contained in:
parent
e4c2ae4ffa
commit
05b7883033
|
@ -23,7 +23,7 @@ typedef struct
|
|||
version CINERA_APP_VERSION = {
|
||||
.Major = 0,
|
||||
.Minor = 8,
|
||||
.Patch = 10
|
||||
.Patch = 11
|
||||
};
|
||||
|
||||
#include <stdarg.h> // NOTE(matt): varargs
|
||||
|
@ -13308,7 +13308,7 @@ SearchToBuffer(buffers *CollationBuffers, db_header_project *StoredP, project *P
|
|||
|
||||
OpenNodeNewLine(B, &IndentationLevel, NODE_DIV, 0);
|
||||
AppendStringToBuffer(B, Wrap0(" class=\"cineraMenuItem view\">"));
|
||||
AppendStringToBuffer(B, Wrap0("View: Grid"));
|
||||
AppendStringToBuffer(B, Wrap0("View: List"));
|
||||
CloseNode(B, &IndentationLevel, NODE_DIV);
|
||||
|
||||
OpenNodeNewLine(B, &IndentationLevel, NODE_DIV, 0);
|
||||
|
|
|
@ -673,7 +673,7 @@ var Nav = {
|
|||
GridRowGap: null,
|
||||
|
||||
SortChronological: true,
|
||||
ViewType: view_type.GRID,
|
||||
ViewType: view_type.LIST,
|
||||
List: null,
|
||||
Grid: null,
|
||||
|
||||
|
@ -921,6 +921,25 @@ InitHelpKeys(HelpDocumentation)
|
|||
Nav.Controls.HelpKeys = Paragraph.querySelectorAll(".help_key");
|
||||
}
|
||||
|
||||
function
|
||||
InitView()
|
||||
{
|
||||
// NOTE(matt): Nav.ViewType is initialised to view_type.LIST and InitNexus() leaves the List View visible
|
||||
if(!StateBitIsSet(state_bit.VIEW_LIST))
|
||||
{
|
||||
if(GridSizeIsSupported(Nav.GridSize))
|
||||
{
|
||||
PickGridView();
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE(matt): Silently swap the state bits, leaving the default List View visible
|
||||
ClearStateBit(state_bit.VIEW_GRID);
|
||||
SetStateBit(state_bit.VIEW_LIST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function
|
||||
SyncNavState()
|
||||
{
|
||||
|
@ -931,31 +950,27 @@ SyncNavState()
|
|||
{
|
||||
if(StateBitIsSet(state_bit.DISABLE_ANIMATIONS)) { ToggleAnimations(); }
|
||||
if(StateBitIsSet(state_bit.SORT_REVERSED)) { Sort(true); }
|
||||
|
||||
// Nav.ViewType is initialised to view_type.GRID, so we needn't do anything if the Nav.State is also on Grid
|
||||
if(StateBitIsSet(state_bit.VIEW_LIST) || !GridSizeIsSupported(Nav.GridSize))
|
||||
{
|
||||
ToggleView();
|
||||
}
|
||||
InitView();
|
||||
}
|
||||
else
|
||||
{
|
||||
Nav.Controls.Save.textContent = "Save Settings: ✘";
|
||||
// Nav.ViewType was initialised to view_type.GRID
|
||||
if(!GridSizeIsSupported(Nav.GridSize))
|
||||
// Nav.ViewType was initialised to view_type.LIST
|
||||
if(Nav.ViewType == view_type.GRID && GridSizeIsSupported(Nav.GridSize))
|
||||
{
|
||||
ToggleView();
|
||||
PickGridView();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Nav.State = 0;
|
||||
SetStateBit(state_bit.VIEW_GRID); // NOTE(matt): Nav.ViewType was initialised to view_type.GRID
|
||||
if(!GridSizeIsSupported(Nav.GridSize))
|
||||
switch(Nav.ViewType)
|
||||
{
|
||||
ToggleView();
|
||||
case view_type.LIST: SetStateBit(state_bit.VIEW_LIST); break
|
||||
case view_type.GRID: SetStateBit(state_bit.VIEW_GRID); break
|
||||
}
|
||||
InitView();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -976,7 +991,11 @@ InitTraversalStack()
|
|||
if(Projects.length === 1)
|
||||
{
|
||||
// NOTE(matt): Automatically descend into the lone project
|
||||
Level.Projects = Projects[0].querySelectorAll(":scope > .cineraIndexProject");
|
||||
var QueriedProjects = Projects[0].querySelectorAll(":scope > .cineraIndexProject");
|
||||
if(QueriedProjects.length > 0)
|
||||
{
|
||||
Level.Projects = QueriedProjects;
|
||||
}
|
||||
Level.Entries = Projects[0].querySelectorAll(":scope > .cineraIndexEntries > div");
|
||||
}
|
||||
else
|
||||
|
@ -2861,13 +2880,18 @@ InitNexus()
|
|||
|
||||
// NOTE(matt): We ResetButtonsContainerClone() anyway, but without cycling this classList Safari seems to do transitions
|
||||
// based on the wrong size grid
|
||||
|
||||
Nav.GridContainer.classList.add("hidden");
|
||||
ResetButtonsContainerClone();
|
||||
Nav.GridContainer.classList.remove("hidden");
|
||||
|
||||
switch(Nav.ViewType)
|
||||
{
|
||||
case view_type.LIST: { Nav.List.classList.remove("hidden"); ScrollCondition = false; } break;
|
||||
case view_type.GRID: { Nav.Grid.classList.remove("hidden"); ScrollCondition = true; } break;
|
||||
}
|
||||
|
||||
Nav.Nexus.classList.add("anim");
|
||||
|
||||
ScrollCondition = true; // NOTE(matt): Variable in cinera_pre.js, we init with the Grid which is the view we want to auto-scroll
|
||||
if(CineraProps.IsMobile)
|
||||
{
|
||||
CineraProps.Orientation = GetRealOrientation(orientations.LANDSCAPE_LEFT, CineraProps.IsMobile);
|
||||
|
@ -3412,13 +3436,45 @@ ScrollToWithOffset(Element, Offset)
|
|||
}
|
||||
|
||||
function
|
||||
ToggleView()
|
||||
PickGridView()
|
||||
{
|
||||
// NOTE(matt): While we only have two views, a toggle will suffice
|
||||
clearTimeout(ScrollerFunction);
|
||||
ScrollTicking = false;
|
||||
if(Nav.ViewType == view_type.GRID)
|
||||
if(GridSizeIsSupported(Nav.GridSize))
|
||||
{
|
||||
Nav.Controls.View.textContent = "View: 𝑛-ary Grid";
|
||||
Nav.ViewType = view_type.GRID;
|
||||
if(MaintainingState())
|
||||
{
|
||||
ClearStateBit(state_bit.VIEW_LIST);
|
||||
SetStateBit(state_bit.VIEW_GRID);
|
||||
}
|
||||
|
||||
if(!IsQuery())
|
||||
{
|
||||
var TargetLevel = ComputeTargetLevelForViewport();
|
||||
EmptyTraversalStack();
|
||||
if(TargetLevel.Projects || TargetLevel.Entries)
|
||||
{
|
||||
var ProjectsStack = BuildProjectsStack(TargetLevel);
|
||||
DeriveTraversalStack(ProjectsStack, TargetLevel);
|
||||
}
|
||||
Nav.List.classList.add("hidden");
|
||||
Nav.GridContainer.classList.remove("hidden");
|
||||
|
||||
UpdateButtons();
|
||||
|
||||
ScrollToWithOffset(Nav.Controls.GridTraversal.Header, Nav.Controls.Header.offsetHeight);
|
||||
}
|
||||
ScrollCondition = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO(matt): Inform user that grid view is unavailable
|
||||
}
|
||||
}
|
||||
|
||||
function
|
||||
PickListView()
|
||||
{
|
||||
Nav.Controls.View.textContent = "View: List";
|
||||
Nav.ViewType = view_type.LIST;
|
||||
if(MaintainingState())
|
||||
|
@ -3446,42 +3502,23 @@ ToggleView()
|
|||
ScrollToWithOffset(Element, Nav.Controls.Header.offsetHeight);
|
||||
}
|
||||
}
|
||||
ScrollCondition = false;
|
||||
}
|
||||
|
||||
function
|
||||
ToggleView()
|
||||
{
|
||||
// NOTE(matt): While we only have two views, a toggle will suffice.
|
||||
clearTimeout(ScrollerFunction);
|
||||
ScrollTicking = false;
|
||||
if(Nav.ViewType == view_type.GRID)
|
||||
{
|
||||
PickListView();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(GridSizeIsSupported(Nav.GridSize))
|
||||
{
|
||||
Nav.Controls.View.textContent = "View: Grid";
|
||||
Nav.ViewType = view_type.GRID;
|
||||
if(MaintainingState())
|
||||
{
|
||||
ClearStateBit(state_bit.VIEW_LIST);
|
||||
SetStateBit(state_bit.VIEW_GRID);
|
||||
PickGridView();
|
||||
}
|
||||
|
||||
if(!IsQuery())
|
||||
{
|
||||
var TargetLevel = ComputeTargetLevelForViewport();
|
||||
EmptyTraversalStack();
|
||||
if(TargetLevel.Projects || TargetLevel.Entries)
|
||||
{
|
||||
var ProjectsStack = BuildProjectsStack(TargetLevel);
|
||||
DeriveTraversalStack(ProjectsStack, TargetLevel);
|
||||
}
|
||||
Nav.List.classList.add("hidden");
|
||||
Nav.GridContainer.classList.remove("hidden");
|
||||
|
||||
UpdateButtons();
|
||||
|
||||
ScrollToWithOffset(Nav.Controls.GridTraversal.Header, Nav.Controls.Header.offsetHeight);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO(matt): Inform user that grid view is unavailable
|
||||
}
|
||||
}
|
||||
ScrollCondition = Nav.ViewType == view_type.GRID;
|
||||
}
|
||||
|
||||
function
|
||||
|
@ -3804,7 +3841,7 @@ ResizeFunction()
|
|||
}
|
||||
else if(Nav.ViewType == view_type.GRID)
|
||||
{
|
||||
ToggleView();
|
||||
PickListView();
|
||||
// TODO(matt): Inform user that we've switched to the list view
|
||||
}
|
||||
ScrollToWithOffset(Nav.Nexus, 0);
|
||||
|
|
Loading…
Reference in New Issue