Skip to content

Commit 0d67f61

Browse files
author
NooBxGockeL
committed
Add Support for Tooltips on Categories and Tags.
This will hopefully clear up the confusion some, especially newcomer, could have.
1 parent 24a2540 commit 0d67f61

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

pages/patterns.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@
5757
All<span class="my-badge"> {{ allPatterns | size }}</span>
5858
</a>
5959
{% for category in site.data.categories %}
60-
<a href="javascript:;" class="sidebar-list-item cat-button" category="{{ category.name }}">
60+
<a href="javascript:;" class="sidebar-list-item cat-button" category="{{ category.name }}"
61+
<!-- add tooltip only if we have something to display -->
62+
{% if category.description %}
63+
data-toggle="tooltip" data-placement="left" title="{{ category.description }}"
64+
{% endif %}<!-- /tooltip, close the a tag now --> >
6165
{{ category.name }} <span class="my-badge">
6266
{% assign counter=0 %}
6367
{% for page in allPatterns %}
@@ -80,7 +84,11 @@
8084
All<span class="my-badge"> {{ allPatterns | size }}</span>
8185
</a>
8286
{% for tag in site.data.tags %}
83-
<a href="javascript:;" class="sidebar-list-item tag-button" tag="{{ tag.name }}">
87+
<a href="javascript:;" class="sidebar-list-item tag-button" tag="{{ tag.name }}"
88+
<!-- add tooltip only if we have something to display -->
89+
{% if tag.description %}
90+
data-toggle="tooltip" data-placement="left" title="{{ tag.description }}"
91+
{% endif %}<!-- /tooltip, close the a tag now --> >
8492
{{ tag.name }} <span class="my-badge">
8593
{% assign counter=0 %}
8694
{% for page in allPatterns %}

static/css/index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,3 +437,7 @@ hr.dashed {
437437
.float-right {
438438
float: right;
439439
}
440+
441+
.tooltip {
442+
font-weight: 500;
443+
}

static/js/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ $(document).ready(function() {
22
categoryAndTagDisplay();
33
generateContent();
44
backToTop();
5+
initBootstrapTooltips();
56
});
67

78
function fixFooterInit() {
@@ -68,7 +69,6 @@ function backToTop() {
6869
});
6970
}
7071

71-
7272
function generateContent() {
7373

7474
// console.log($('#markdown-toc').html());
@@ -86,3 +86,8 @@ function generateContent() {
8686
}
8787
console.log("myAffix!!!");
8888
}
89+
90+
function initBootstrapTooltips() {
91+
// Select all elements with data-toggle="tooltips" in the document
92+
$('[data-toggle="tooltip"]').tooltip();
93+
}

0 commit comments

Comments
 (0)