From bd830ddc0c71cc79f05046470fba462997dcf76e Mon Sep 17 00:00:00 2001 From: kor Date: Sun, 4 Nov 2018 00:35:09 +1300 Subject: [PATCH] Refactor row definitions. --- docs/asset/style.css | 98 +++++++++++++------------------------------ docs/logic/view.js | 99 +++++++++++++++++++++++++++----------------- 2 files changed, 89 insertions(+), 108 deletions(-) diff --git a/docs/asset/style.css b/docs/asset/style.css index d3107df..4130acc 100644 --- a/docs/asset/style.css +++ b/docs/asset/style.css @@ -121,8 +121,6 @@ body { position: fixed; top: 50%; left: 50%; - /*width: 154px; - height: 154px;*/ font-size: 128px; transform: translateY(-50%) translateX(-50%); display: none; @@ -243,6 +241,7 @@ nav::-webkit-scrollbar { color: var(--color-itemascent); } +/* MAIN */ .container { background: var(--background); margin-left: calc(var(--size-menu) + var(--size-grid-gutter)); @@ -250,8 +249,6 @@ nav::-webkit-scrollbar { } main { margin: var(--size-grid-gutter) auto; - -webkit-transition: opacity 1000ms linear; - transition: opacity 1000ms linear; } main:after { /* clearfix (reset) */ @@ -271,9 +268,6 @@ article, .griditem-wide { position: relative; float: left; } -article:hover, .griditem-wide:hover { - opacity: var(--alpha-ascent); -} @media screen and (min-width: 886px) { .griditem-wide { width: calc(var(--size-grid-column) * 2 + var(--size-grid-gutter)); @@ -281,7 +275,6 @@ article:hover, .griditem-wide:hover { } article:hover { background: var(--color-itembg); - opacity: 1; } article::selection { background: var(--b_high); @@ -368,7 +361,6 @@ article::selection { /* TITLE */ .griditem-title { - opacity: var(--alpha-enabled); color: var(--color-item); font-size: var(--size-font-title); text-decoration: none; @@ -399,7 +391,7 @@ article::selection { } .griditem-linktitle { - /*opacity: var(--alpha-idle);*/ + opacity: var(--alpha-idle); color: var(--color-item); font-size: var(--size-font-body); float: left; @@ -408,27 +400,18 @@ article::selection { background-color: var(--color-itemascent); color: var(--color-itembg); } -.griditem-linktitle { - opacity: var(--alpha-idle); -} .griditem-linkicon { - margin-right: var(--size-item-elem-sep); + width: 23px; + font-size: 15px; color: var(--color-item); - opacity: calc(var(--alpha-idleicon) - 0.1); 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 { opacity: var(--alpha-enabled); } +.griditem-link:hover .griditem-linktitle { + opacity: var(--alpha-ascent); +} /* TYPE */ .griditem-typecontainer { @@ -438,7 +421,6 @@ article:hover .griditem-linktitle { margin-right: var(--size-grid-gutter); } .griditem-type { - opacity: var(--alpha-idle); width: calc(var(--size-font-bodytypes)*2); color: var(--color-item); padding-bottom: var(--size-grid-gutter); @@ -449,23 +431,18 @@ article:hover .griditem-linktitle { float: right; text-decoration: none; } -.griditem-typeicon { - opacity: var(--alpha-idleicon); -} .griditem-image .griditem-typeicon { display: none; } .griditem-image:hover .griditem-typeicon { display: initial; color: var(--color-image); - opacity: var(--alpha-enabledicon); } -.griditem-type .griditem-typeicon { +.griditem-typeicon { opacity: var(--alpha-idleicon); - color: var(--color-item); } -article:hover .griditem-type { - opacity: var(--alpha-enabled); +article:hover .griditem-typeicon { + opacity: var(--alpha-enabledicon); color: var(--color-item); } .griditem-type:hover .griditem-typeicon { @@ -473,57 +450,41 @@ article:hover .griditem-type { color: var(--color-itemascent); } -/* NOTE, QUOTE, TERM, TAGS, AUTH, PROG */ -.griditem-date, -.griditem-note, -.griditem-quote, -.griditem-term, -.griditem-tags, -.griditem-proj, -.griditem-auth, -.griditem-file, -.griditem-prog { - opacity: var(--alpha-idle); +/* DATE, NOTE, QUOTE, TERM, TAGS, AUTH, PROG etc */ +.article-icon { + float: left; + opacity: var(--alpha-idleicon); +} +article:hover .article-icon { + opacity: var(--alpha-enabledicon); +} +.griditem-row { padding-top: var(--size-item-elem-padding); color: var(--color-item); font-size: var(--size-font-body); float: left; clear: both; } -article:hover .griditem-date, -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); +article:hover .griditem-row { color: var(--color-item); } -.griditem-image .griditem-link, -.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 { +.griditem-image .griditem-row { color: var(--color-image); } - +.griditem-rowtext { + display: inline; + opacity: var(--alpha-idle); +} +article:hover .griditem-rowtext { + opacity: var(--alpha-enabled); +} .griditem-file { word-break: break-all; } - .griditem-file-link { color: var(--color-item); text-decoration: none; } - .griditem-file-link:hover { background-color: var(--color-itemascent); color: var(--color-itembg); @@ -557,12 +518,11 @@ article:hover .griditem-taglink:hover { /* SMALL ICONS */ .textIcon { + color: #fff; margin-right: var(--size-item-elem-sep); - opacity: var(--alpha-idleicon); } article:hover .textIcon { color: var(--color-item); - opacity: var(--alpha-enabledicon); } /* LIGHTBOX */ diff --git a/docs/logic/view.js b/docs/logic/view.js index a830c28..25e5f6b 100644 --- a/docs/logic/view.js +++ b/docs/logic/view.js @@ -41,7 +41,7 @@ function View() let contentHtml = ''; while (i < dbKeys.length) { - contentHtml += this.buildEntry(db, dbKeys[i]); + contentHtml += this.buildArticle(db, dbKeys[i]); i++; } 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 itemClass = "article"; @@ -97,10 +97,8 @@ function View() style="cursor: pointer;"`; } - let entry = ``; - entry += `
`; - - // ITEM DIV + // ARTICLE + let entry = `
`; if (this.isDefined(value.LINK)) { var idUrl = "url"; @@ -141,12 +139,12 @@ function View() for (let l = 0; l < value.LINK.length; l++) { entry += ``; - entry += ``; + entry += ``; } } else { - entry += ``; + entry += ``; } } @@ -157,12 +155,11 @@ function View() entry += `
`; for (let tc = 0; tc < value.TYPE.length; tc++) { - const icon = getTypeIconName(value.TYPE[tc]); entry += ``; - entry += ``; + entry += this.buildIcon(value.TYPE[tc], value.TYPE[tc], 'griditem-typeicon'); entry += ``; } - entry += `
`; // griditem-typecontainer + entry += ``; } // UPPER CONTENT END @@ -182,7 +179,7 @@ function View() // TIME if (SETTINGS.SHOWDATE && this.isDefined(value.DATE)) { - entry += ``; + entry += this.doRow('date', value.DATE); } // AUTHOR @@ -190,64 +187,64 @@ function View() { for (var i = 0; i < value.AUTH.length; i++) { - entry += `
${value.AUTH[i].to_properCase()}
`; + entry += this.doRow('author', value.AUTH[i].to_properCase()); } } // TAGS if (SETTINGS.SHOWTAGS && this.isDefined(value.TAGS)) { - entry += `
`; + let content = ''; for (var i = 0; i < value.TAGS.length; i++) { - entry += `${value.TAGS[i]}`; - if (i+1 !== value.TAGS.length) + content += `${value.TAGS[i]}`; + if (i + 1 !== value.TAGS.length) { - entry += `, `; + content += `, `; } }; - entry += `
`; + entry += this.doRow('tags', content); } // PROJECT if (SETTINGS.SHOWPROJ && this.isDefined(value.PROJ)) { - entry += `
`; + let content = ''; for (var i = 0; i < value.PROJ.length; i++) { - entry += `${value.PROJ[i].to_properCase()}`; + content += `${value.PROJ[i].to_properCase()}`; if (i + 1 != value.PROJ.length) { - entry += `, `; + content += `, `; } } - entry += `
`; + entry += this.doRow('project', content); } // 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 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 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 if (SETTINGS.SHOWPROG && this.isDefined(value.PROG)) { - entry += `
${value.PROG}
`; + entry += this.doRow('progress', value.PROG); } - + // IMAGE - for non-image-type-entry if (SETTINGS.SHOWIMAG && !this.isType(value.TYPE, 'image') @@ -266,13 +263,13 @@ function View() { for (var i = 0; i < value.FILE.length; i++) { - entry += ``; + entry += this.doRow('file', `${value.FILE[i]}`, 'griditem-file'); } } else { // single - entry += ``; + entry += this.doRow('file', `${value.FILE}`, 'griditem-file'); } } @@ -298,6 +295,14 @@ function View() return entry; } + this.doRow = function(type, content, extraClass) + { + return `
+ ${type != undefined ? this.buildIcon(type) : ''} +
${content}
+
`; + } + this.stats = function(value) { let menuContent = ``; @@ -339,7 +344,7 @@ function View() { const type = value.types[ty][0]; const count = value.types[ty][1]; - const icon = getTypeIconName(type); + const icon = this.getIcon(type); menuContent += ``; menuContent += ``; menuContent += ``; @@ -368,7 +373,6 @@ function View() for (var t = 0; t < Math.min(value.tags.length, SETTINGS.STATSNUMTAGS); t++) { menuContent += ``; - // menuContent += ``; menuContent += ``; menuContent += ``; menuContent += ``; @@ -392,7 +396,7 @@ function View() } } - this.doMultilineFormatting = function(data, title, className, iconName) + this.doMultilineFormatting = function(type, data) { let result = ''; if (Array.isArray(data)) @@ -409,39 +413,47 @@ function View() { titleSplit[e] = titleSplit[e].trim(); } - result += `
${titleSplit[0]}: ${titleSplit[1]}
`; + result += this.doRow(type, `${titleSplit[0]}: ${titleSplit[1]}`); } else { - result += `
${data[i].substring(2)}
`; + result += this.doRow(type, data[i].substring(2)); } } else if (data[i].substring(0, 2) === "& ") { // New line in current item - result += `
${data[i].substring(2)}
`; + result += this.doRow(null, data[i].substring(2)); } else if (data[i].substring(0, 2) == "- ") { // Bullet point - result += `
${data[i].substring(2)}
`; + result += this.doRow('dash', data[i].substring(2)); } else { // Handle unformatted - result += `
${data[i]}
`; + result += this.doRow(type, data[i]); } } } else { // Handle not array - result += `
${data}
`; + result += this.doRow(type, data); } 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 ``; + } + + this.getIcon = function(type) { let icon = ''; switch (type) @@ -460,6 +472,15 @@ function View() case 'image': icon = 'fas fa-image'; break; case 'encyclopedia': icon = 'fas fa-globe'; 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; }