« get me outta code hell

content, test: linkThing: tooltip -> tooltipStyle - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-01-13 19:11:28 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-13 21:19:10 -0400
commita3dca62ee1cd0c1da0a8952bbbf62fb55ce7319f (patch)
treed8377c4ae82027146548b06a06ab18a5ca6bb8f0 /src/content
parenteb8670ee11fd0a68c02ef96227b4475f08157ace (diff)
content, test: linkThing: tooltip -> tooltipStyle
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateChronologyLinks.js4
-rw-r--r--src/content/dependencies/generatePreviousNextLinks.js4
-rw-r--r--src/content/dependencies/linkThing.js29
3 files changed, 19 insertions, 18 deletions
diff --git a/src/content/dependencies/generateChronologyLinks.js b/src/content/dependencies/generateChronologyLinks.js
index 16e4f999..8ec6ee0a 100644
--- a/src/content/dependencies/generateChronologyLinks.js
+++ b/src/content/dependencies/generateChronologyLinks.js
@@ -61,13 +61,13 @@ export default {
               html.tag('span', {class: 'buttons'},
                 language.formatUnitList([
                   previousLink?.slots({
-                    tooltip: true,
+                    tooltipStyle: 'browser',
                     color: false,
                     content: language.$('misc.nav.previous'),
                   }),
 
                   nextLink?.slots({
-                    tooltip: true,
+                    tooltipStyle: 'browser',
                     color: false,
                     content: language.$('misc.nav.next'),
                   }),
diff --git a/src/content/dependencies/generatePreviousNextLinks.js b/src/content/dependencies/generatePreviousNextLinks.js
index d3e529bf..9771de39 100644
--- a/src/content/dependencies/generatePreviousNextLinks.js
+++ b/src/content/dependencies/generatePreviousNextLinks.js
@@ -28,7 +28,7 @@ export default {
     if (!html.isBlank(slots.previousLink)) {
       previousNext.push(
         slots.previousLink.slots({
-          tooltip: true,
+          tooltipStyle: 'browser',
           color: false,
           attributes: {id: slots.id && 'previous-button'},
           content: language.$('misc.nav.previous'),
@@ -38,7 +38,7 @@ export default {
     if (!html.isBlank(slots.nextLink)) {
       previousNext.push(
         slots.nextLink.slots({
-          tooltip: true,
+          tooltipStyle: 'browser',
           color: false,
           attributes: {id: slots.id && 'next-button'},
           content: language.$('misc.nav.next'),
diff --git a/src/content/dependencies/linkThing.js b/src/content/dependencies/linkThing.js
index 2c3b0369..4c38c51d 100644
--- a/src/content/dependencies/linkThing.js
+++ b/src/content/dependencies/linkThing.js
@@ -36,9 +36,9 @@ export default {
       default: false,
     },
 
-    tooltip: {
-      validate: v => v.anyOf(v.isBoolean, v.isHTML),
-      default: false,
+    tooltipStyle: {
+      validate: v => v.is('none', 'browser'),
+      default: 'none',
     },
 
     color: {
@@ -69,10 +69,19 @@ export default {
     const path =
       slots.path ?? data.path;
 
-    const name =
+    const showShortName =
       (slots.preferShortName
-        ? data.nameShort ?? data.name ?? null
-        : data.name ?? null);
+        ? data.nameShort && data.nameShort !== data.name
+        : false);
+
+    const name =
+      (showShortName
+        ? data.nameShort
+        : data.name);
+
+    if (slots.tooltipStyle === 'browser') {
+      attributes.add('title', data.name);
+    }
 
     const content =
       (html.isBlank(slots.content)
@@ -91,19 +100,11 @@ export default {
       attributes.add(colorStyle);
     }
 
-    let tooltip = null;
-    if (slots.tooltip === true) {
-      tooltip = name;
-    } else if (typeof slots.tooltip === 'string') {
-      tooltip = slots.tooltip;
-    }
-
     return relations.linkTemplate
       .slots({
         path: slots.anchor ? [] : path,
         href: slots.anchor ? '' : null,
         content,
-        tooltip,
         attributes,
         hash: slots.hash,
         linkless: slots.linkless,