Refactor row definitions.

This commit is contained in:
kor 2018-11-04 00:35:09 +13:00
parent e8855ff976
commit bd830ddc0c
2 changed files with 89 additions and 108 deletions

View File

@ -121,8 +121,6 @@ body {
position: fixed; position: fixed;
top: 50%; top: 50%;
left: 50%; left: 50%;
/*width: 154px;
height: 154px;*/
font-size: 128px; font-size: 128px;
transform: translateY(-50%) translateX(-50%); transform: translateY(-50%) translateX(-50%);
display: none; display: none;
@ -243,6 +241,7 @@ nav::-webkit-scrollbar {
color: var(--color-itemascent); color: var(--color-itemascent);
} }
/* MAIN */
.container { .container {
background: var(--background); background: var(--background);
margin-left: calc(var(--size-menu) + var(--size-grid-gutter)); margin-left: calc(var(--size-menu) + var(--size-grid-gutter));
@ -250,8 +249,6 @@ nav::-webkit-scrollbar {
} }
main { main {
margin: var(--size-grid-gutter) auto; margin: var(--size-grid-gutter) auto;
-webkit-transition: opacity 1000ms linear;
transition: opacity 1000ms linear;
} }
main:after { main:after {
/* clearfix (reset) */ /* clearfix (reset) */
@ -271,9 +268,6 @@ article, .griditem-wide {
position: relative; position: relative;
float: left; float: left;
} }
article:hover, .griditem-wide:hover {
opacity: var(--alpha-ascent);
}
@media screen and (min-width: 886px) { @media screen and (min-width: 886px) {
.griditem-wide { .griditem-wide {
width: calc(var(--size-grid-column) * 2 + var(--size-grid-gutter)); width: calc(var(--size-grid-column) * 2 + var(--size-grid-gutter));
@ -281,7 +275,6 @@ article:hover, .griditem-wide:hover {
} }
article:hover { article:hover {
background: var(--color-itembg); background: var(--color-itembg);
opacity: 1;
} }
article::selection { article::selection {
background: var(--b_high); background: var(--b_high);
@ -368,7 +361,6 @@ article::selection {
/* TITLE */ /* TITLE */
.griditem-title { .griditem-title {
opacity: var(--alpha-enabled);
color: var(--color-item); color: var(--color-item);
font-size: var(--size-font-title); font-size: var(--size-font-title);
text-decoration: none; text-decoration: none;
@ -399,7 +391,7 @@ article::selection {
} }
.griditem-linktitle { .griditem-linktitle {
/*opacity: var(--alpha-idle);*/ opacity: var(--alpha-idle);
color: var(--color-item); color: var(--color-item);
font-size: var(--size-font-body); font-size: var(--size-font-body);
float: left; float: left;
@ -408,27 +400,18 @@ article::selection {
background-color: var(--color-itemascent); background-color: var(--color-itemascent);
color: var(--color-itembg); color: var(--color-itembg);
} }
.griditem-linktitle {
opacity: var(--alpha-idle);
}
.griditem-linkicon { .griditem-linkicon {
margin-right: var(--size-item-elem-sep); width: 23px;
font-size: 15px;
color: var(--color-item); color: var(--color-item);
opacity: calc(var(--alpha-idleicon) - 0.1);
float: left; float: left;
} }
.griditem-linktitle {
opacity: var(--alpha-idle);
}
.griditem-link:hover .griditem-linktitle {
opacity: var(--alpha-ascent);
}
article:hover .griditem-linkicon {
opacity: var(--alpha-enabledicon);
}
article:hover .griditem-linktitle { article:hover .griditem-linktitle {
opacity: var(--alpha-enabled); opacity: var(--alpha-enabled);
} }
.griditem-link:hover .griditem-linktitle {
opacity: var(--alpha-ascent);
}
/* TYPE */ /* TYPE */
.griditem-typecontainer { .griditem-typecontainer {
@ -438,7 +421,6 @@ article:hover .griditem-linktitle {
margin-right: var(--size-grid-gutter); margin-right: var(--size-grid-gutter);
} }
.griditem-type { .griditem-type {
opacity: var(--alpha-idle);
width: calc(var(--size-font-bodytypes)*2); width: calc(var(--size-font-bodytypes)*2);
color: var(--color-item); color: var(--color-item);
padding-bottom: var(--size-grid-gutter); padding-bottom: var(--size-grid-gutter);
@ -449,23 +431,18 @@ article:hover .griditem-linktitle {
float: right; float: right;
text-decoration: none; text-decoration: none;
} }
.griditem-typeicon {
opacity: var(--alpha-idleicon);
}
.griditem-image .griditem-typeicon { .griditem-image .griditem-typeicon {
display: none; display: none;
} }
.griditem-image:hover .griditem-typeicon { .griditem-image:hover .griditem-typeicon {
display: initial; display: initial;
color: var(--color-image); color: var(--color-image);
opacity: var(--alpha-enabledicon);
} }
.griditem-type .griditem-typeicon { .griditem-typeicon {
opacity: var(--alpha-idleicon); opacity: var(--alpha-idleicon);
color: var(--color-item);
} }
article:hover .griditem-type { article:hover .griditem-typeicon {
opacity: var(--alpha-enabled); opacity: var(--alpha-enabledicon);
color: var(--color-item); color: var(--color-item);
} }
.griditem-type:hover .griditem-typeicon { .griditem-type:hover .griditem-typeicon {
@ -473,57 +450,41 @@ article:hover .griditem-type {
color: var(--color-itemascent); color: var(--color-itemascent);
} }
/* NOTE, QUOTE, TERM, TAGS, AUTH, PROG */ /* DATE, NOTE, QUOTE, TERM, TAGS, AUTH, PROG etc */
.griditem-date, .article-icon {
.griditem-note, float: left;
.griditem-quote, opacity: var(--alpha-idleicon);
.griditem-term, }
.griditem-tags, article:hover .article-icon {
.griditem-proj, opacity: var(--alpha-enabledicon);
.griditem-auth, }
.griditem-file, .griditem-row {
.griditem-prog {
opacity: var(--alpha-idle);
padding-top: var(--size-item-elem-padding); padding-top: var(--size-item-elem-padding);
color: var(--color-item); color: var(--color-item);
font-size: var(--size-font-body); font-size: var(--size-font-body);
float: left; float: left;
clear: both; clear: both;
} }
article:hover .griditem-date, article:hover .griditem-row {
article:hover .griditem-note,
article:hover .griditem-quote,
article:hover .griditem-term,
article:hover .griditem-tags,
article:hover .griditem-proj,
article:hover .griditem-auth,
article:hover .griditem-file,
article:hover .griditem-prog {
opacity: var(--alpha-enabled);
color: var(--color-item); color: var(--color-item);
} }
.griditem-image .griditem-link, .griditem-image .griditem-row {
.griditem-image .griditem-date,
.griditem-image .griditem-note,
.griditem-image .griditem-quote,
.griditem-image .griditem-term,
.griditem-image .griditem-tags,
.griditem-image .griditem-proj,
.griditem-image .griditem-auth,
.griditem-image .griditem-file,
.griditem-image .griditem-prog {
color: var(--color-image); color: var(--color-image);
} }
.griditem-rowtext {
display: inline;
opacity: var(--alpha-idle);
}
article:hover .griditem-rowtext {
opacity: var(--alpha-enabled);
}
.griditem-file { .griditem-file {
word-break: break-all; word-break: break-all;
} }
.griditem-file-link { .griditem-file-link {
color: var(--color-item); color: var(--color-item);
text-decoration: none; text-decoration: none;
} }
.griditem-file-link:hover { .griditem-file-link:hover {
background-color: var(--color-itemascent); background-color: var(--color-itemascent);
color: var(--color-itembg); color: var(--color-itembg);
@ -557,12 +518,11 @@ article:hover .griditem-taglink:hover {
/* SMALL ICONS */ /* SMALL ICONS */
.textIcon { .textIcon {
color: #fff;
margin-right: var(--size-item-elem-sep); margin-right: var(--size-item-elem-sep);
opacity: var(--alpha-idleicon);
} }
article:hover .textIcon { article:hover .textIcon {
color: var(--color-item); color: var(--color-item);
opacity: var(--alpha-enabledicon);
} }
/* LIGHTBOX */ /* LIGHTBOX */

View File

@ -41,7 +41,7 @@ function View()
let contentHtml = ''; let contentHtml = '';
while (i < dbKeys.length) while (i < dbKeys.length)
{ {
contentHtml += this.buildEntry(db, dbKeys[i]); contentHtml += this.buildArticle(db, dbKeys[i]);
i++; i++;
} }
this.grid.innerHTML = contentHtml; this.grid.innerHTML = contentHtml;
@ -69,7 +69,7 @@ function View()
} }
} }
this.buildEntry = function(db, key) this.buildArticle = function(db, key)
{ {
let value = db[key]; let value = db[key];
let itemClass = "article"; let itemClass = "article";
@ -97,10 +97,8 @@ function View()
style="cursor: pointer;"`; style="cursor: pointer;"`;
} }
let entry = ``; // ARTICLE
entry += `<article class="${itemClass}" id="${SETTINGS.GRIDITEMIDBASE + value.DIID}">`; let entry = `<article class="${itemClass}" id="${SETTINGS.GRIDITEMIDBASE + value.DIID}">`;
// ITEM DIV
if (this.isDefined(value.LINK)) if (this.isDefined(value.LINK))
{ {
var idUrl = "url"; var idUrl = "url";
@ -141,12 +139,12 @@ function View()
for (let l = 0; l < value.LINK.length; l++) for (let l = 0; l < value.LINK.length; l++)
{ {
entry += `<a class="griditem-link" href="${String(value.LINK[l])}" id="${idUrl}">`; entry += `<a class="griditem-link" href="${String(value.LINK[l])}" id="${idUrl}">`;
entry += `<div class="griditem-linkcontainer"><i title="link" class="griditem-linkicon fas fa-link"></i><div class="griditem-linktitle">${this.extractRootDomain(value.LINK[l])}</div></div></a>`; entry += `<div class="griditem-linkcontainer"><div class="griditem-linkicon">${this.buildIcon('link')}</div><div class="griditem-linktitle">${this.extractRootDomain(value.LINK[l])}</div></div></a>`;
} }
} }
else else
{ {
entry += `<div class="griditem-linkcontainer"><i class="griditem-linkicon fas fa-link"></i><div class="griditem-linktitle">${this.extractRootDomain(value.LINK)}</div></div></a>`; entry += `<div class="griditem-linkcontainer"><div class="griditem-linkicon">${this.buildIcon('link')}</div><div class="griditem-linktitle">${this.extractRootDomain(value.LINK)}</div></div></a>`;
} }
} }
@ -157,12 +155,11 @@ function View()
entry += `<div class="griditem-typecontainer">`; entry += `<div class="griditem-typecontainer">`;
for (let tc = 0; tc < value.TYPE.length; tc++) for (let tc = 0; tc < value.TYPE.length; tc++)
{ {
const icon = getTypeIconName(value.TYPE[tc]);
entry += `<a class="griditem-type" href='#type-${value.TYPE[tc]}'>`; entry += `<a class="griditem-type" href='#type-${value.TYPE[tc]}'>`;
entry += `<i title="${value.TYPE[tc]}" class="griditem-typeicon ${icon}"></i>`; entry += this.buildIcon(value.TYPE[tc], value.TYPE[tc], 'griditem-typeicon');
entry += `</a>`; entry += `</a>`;
} }
entry += `</div>`; // griditem-typecontainer entry += `</div>`;
} }
// UPPER CONTENT END // UPPER CONTENT END
@ -182,7 +179,7 @@ function View()
// TIME // TIME
if (SETTINGS.SHOWDATE && this.isDefined(value.DATE)) if (SETTINGS.SHOWDATE && this.isDefined(value.DATE))
{ {
entry += `<time class="griditem-date"><i title="date" class="fas fa-clock textIcon"></i>${value.DATE}</time>`; entry += this.doRow('date', value.DATE);
} }
// AUTHOR // AUTHOR
@ -190,64 +187,64 @@ function View()
{ {
for (var i = 0; i < value.AUTH.length; i++) for (var i = 0; i < value.AUTH.length; i++)
{ {
entry += `<div class="griditem-auth"><i title="author" class="fas fa-user textIcon"></i>${value.AUTH[i].to_properCase()}</div>`; entry += this.doRow('author', value.AUTH[i].to_properCase());
} }
} }
// TAGS // TAGS
if (SETTINGS.SHOWTAGS && this.isDefined(value.TAGS)) if (SETTINGS.SHOWTAGS && this.isDefined(value.TAGS))
{ {
entry += `<div class="griditem-tags"><i title="tags" class="fas fa-tag textIcon"></i>`; let content = '';
for (var i = 0; i < value.TAGS.length; i++) for (var i = 0; i < value.TAGS.length; i++)
{ {
entry += `<a class="griditem-taglink" href="#tag-${value.TAGS[i]}">${value.TAGS[i]}</a>`; content += `<a class="griditem-taglink" href="#tag-${value.TAGS[i]}">${value.TAGS[i]}</a>`;
if (i+1 !== value.TAGS.length) if (i + 1 !== value.TAGS.length)
{ {
entry += `, `; content += `, `;
} }
}; };
entry += `</div>`; entry += this.doRow('tags', content);
} }
// PROJECT // PROJECT
if (SETTINGS.SHOWPROJ && this.isDefined(value.PROJ)) if (SETTINGS.SHOWPROJ && this.isDefined(value.PROJ))
{ {
entry += `<div class="griditem-proj"><i title="project" class="fas fa-leaf textIcon"></i>`; let content = '';
for (var i = 0; i < value.PROJ.length; i++) for (var i = 0; i < value.PROJ.length; i++)
{ {
entry += `<a class="griditem-taglink" href="#proj-${value.PROJ[i]}">${value.PROJ[i].to_properCase()}</a>`; content += `<a class="griditem-taglink" href="#proj-${value.PROJ[i]}">${value.PROJ[i].to_properCase()}</a>`;
if (i + 1 != value.PROJ.length) if (i + 1 != value.PROJ.length)
{ {
entry += `, `; content += `, `;
} }
} }
entry += `</div>`; entry += this.doRow('project', content);
} }
// TERM // TERM
if (SETTINGS.SHOWTERM && this.isDefined(value.TERM)) if (SETTINGS.SHOWTERM && this.isDefined(value.TERM))
{ {
entry += this.doMultilineFormatting(value.TERM, "term", "griditem-term", "fas fa-ribbon textIcon"); entry += this.doMultilineFormatting('term', value.TERM);
} }
// NOTE // NOTE
if (SETTINGS.SHOWNOTE && this.isDefined(value.NOTE)) if (SETTINGS.SHOWNOTE && this.isDefined(value.NOTE))
{ {
entry += this.doMultilineFormatting(value.NOTE, "note", "griditem-note", "fas fa-sticky-note textIcon"); entry += this.doMultilineFormatting('note', value.NOTE);
} }
// QUOTE // QUOTE
if (SETTINGS.SHOWQOTE && this.isDefined(value.QOTE)) if (SETTINGS.SHOWQOTE && this.isDefined(value.QOTE))
{ {
entry += this.doMultilineFormatting(value.QOTE, "quote", "griditem-quote", "fas fa-comment textIcon"); entry += this.doMultilineFormatting('quote', value.QOTE);
} }
// PROGRESS // PROGRESS
if (SETTINGS.SHOWPROG && this.isDefined(value.PROG)) if (SETTINGS.SHOWPROG && this.isDefined(value.PROG))
{ {
entry += `<div class="griditem-prog"><i title="progress" class="fas fa-clock textIcon"></i>${value.PROG}</div>`; entry += this.doRow('progress', value.PROG);
} }
// IMAGE - for non-image-type-entry // IMAGE - for non-image-type-entry
if (SETTINGS.SHOWIMAG if (SETTINGS.SHOWIMAG
&& !this.isType(value.TYPE, 'image') && !this.isType(value.TYPE, 'image')
@ -266,13 +263,13 @@ function View()
{ {
for (var i = 0; i < value.FILE.length; i++) for (var i = 0; i < value.FILE.length; i++)
{ {
entry += `<div class="griditem-file"><i title="file" class="fas fa-folder-open textIcon"></i><a class="griditem-file-link" href="content/media/${value.FILE[i]}">${value.FILE[i]}</a></div>`; entry += this.doRow('file', `<a class="griditem-file-link" href="content/media/${value.FILE[i]}">${value.FILE[i]}</a>`, 'griditem-file');
} }
} }
else else
{ {
// single // single
entry += `<div class="griditem-file"><i title="file" class="fas fa-folder-open textIcon"></i><a class="griditem-file-link" href="content/media/${value.FILE}">${value.FILE}</a></div>`; entry += this.doRow('file', `<a class="griditem-file-link" href="content/media/${value.FILE}">${value.FILE}</a>`, 'griditem-file');
} }
} }
@ -298,6 +295,14 @@ function View()
return entry; return entry;
} }
this.doRow = function(type, content, extraClass)
{
return `<div class="griditem-row${extraClass != undefined ? ' '+extraClass : ''}">
${type != undefined ? this.buildIcon(type) : ''}
<div class="griditem-rowtext">${content}</div>
</div>`;
}
this.stats = function(value) this.stats = function(value)
{ {
let menuContent = ``; let menuContent = ``;
@ -339,7 +344,7 @@ function View()
{ {
const type = value.types[ty][0]; const type = value.types[ty][0];
const count = value.types[ty][1]; const count = value.types[ty][1];
const icon = getTypeIconName(type); const icon = this.getIcon(type);
menuContent += `<a href='#type-${type}' class="menu-item">`; menuContent += `<a href='#type-${type}' class="menu-item">`;
menuContent += `<div class="menu-itemcount">${count}</div>`; menuContent += `<div class="menu-itemcount">${count}</div>`;
menuContent += `<i title="${type}" class="menu-itemicon ${icon}"></i>`; menuContent += `<i title="${type}" class="menu-itemicon ${icon}"></i>`;
@ -368,7 +373,6 @@ function View()
for (var t = 0; t < Math.min(value.tags.length, SETTINGS.STATSNUMTAGS); t++) for (var t = 0; t < Math.min(value.tags.length, SETTINGS.STATSNUMTAGS); t++)
{ {
menuContent += `<a class="menu-tag" href='#tag-${value.tags[t][0]}'>`; menuContent += `<a class="menu-tag" href='#tag-${value.tags[t][0]}'>`;
// menuContent += `<i class="fas fa-tag textIcon"></i>`;
menuContent += `<div class="menu-tagcount">${value.tags[t][1]}</div>`; menuContent += `<div class="menu-tagcount">${value.tags[t][1]}</div>`;
menuContent += `<div class="menu-taglabel">${value.tags[t][0]}</div>`; menuContent += `<div class="menu-taglabel">${value.tags[t][0]}</div>`;
menuContent += `</a>`; menuContent += `</a>`;
@ -392,7 +396,7 @@ function View()
} }
} }
this.doMultilineFormatting = function(data, title, className, iconName) this.doMultilineFormatting = function(type, data)
{ {
let result = ''; let result = '';
if (Array.isArray(data)) if (Array.isArray(data))
@ -409,39 +413,47 @@ function View()
{ {
titleSplit[e] = titleSplit[e].trim(); titleSplit[e] = titleSplit[e].trim();
} }
result += `<div class="${className}"><i title="${title}" class="${iconName}"></i><b>${titleSplit[0]}</b>: ${titleSplit[1]}</div>`; result += this.doRow(type, `<b>${titleSplit[0]}</b>: ${titleSplit[1]}`);
} }
else else
{ {
result += `<div class="${className}"><i title="${title}" class="${iconName}"></i>${data[i].substring(2)}</div>`; result += this.doRow(type, data[i].substring(2));
} }
} }
else if (data[i].substring(0, 2) === "& ") else if (data[i].substring(0, 2) === "& ")
{ {
// New line in current item // New line in current item
result += `<div class="${className}">${data[i].substring(2)}</div>`; result += this.doRow(null, data[i].substring(2));
} }
else if (data[i].substring(0, 2) == "- ") else if (data[i].substring(0, 2) == "- ")
{ {
// Bullet point // Bullet point
result += `<div class="${className}"><i class="fas fa-caret-right textIcon"></i>${data[i].substring(2)}</div>`; result += this.doRow('dash', data[i].substring(2));
} }
else else
{ {
// Handle unformatted // Handle unformatted
result += `<div class="${className}"><i title="${title}" class="${iconName}"></i>${data[i]}</div>`; result += this.doRow(type, data[i]);
} }
} }
} }
else else
{ {
// Handle not array // Handle not array
result += `<div class="${className}"><i title="${title}" class="${iconName}"></i>${data}</div>`; result += this.doRow(type, data);
} }
return result; return result;
} }
getTypeIconName = function(type) this.buildIcon = function(type, label, altClass)
{
if (label == undefined) { label = type; }
let labelElem = label != null ? `title="${label}" ` : ``;
let iconClass = altClass == undefined ? 'article-icon' : altClass;
return `<i ${labelElem}class="${this.getIcon(type)} textIcon ${iconClass}"></i>`;
}
this.getIcon = function(type)
{ {
let icon = ''; let icon = '';
switch (type) switch (type)
@ -460,6 +472,15 @@ function View()
case 'image': icon = 'fas fa-image'; break; case 'image': icon = 'fas fa-image'; break;
case 'encyclopedia': icon = 'fas fa-globe'; break; case 'encyclopedia': icon = 'fas fa-globe'; break;
case 'term': icon = 'fas fa-ribbon'; break; case 'term': icon = 'fas fa-ribbon'; break;
case 'note': icon = 'fas fa-sticky-note'; break;
case 'date': icon = 'fas fa-clock'; break;
case 'author': icon = 'fas fa-user'; break;
case 'tags': icon = 'fas fa-tag'; break;
case 'project': icon = 'fas fa-leaf'; break;
case 'progress': icon = 'fas fa-clock'; break;
case 'file': icon = 'fas fa-folder-open'; break;
case 'dash': icon = 'fas fa-caret-right'; break;
case 'link': icon = 'fas fa-link'; break;
} }
return icon; return icon;
} }