Skip to content

Commit ec59290

Browse files
committed
Tag selection with JavaScript.
1 parent 5d361e7 commit ec59290

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

_includes/tags.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ul>
33
{% for tag in post.tags %}
44
<li>
5-
<a href="tags.html#{{ tag }}" title="Voir les posts ayant le tag {{ tag }} ">{{ tag }}</a>
5+
<a href="tags.html#{{ tag }}" title="Voir les posts ayant le tag {{ tag }}">{{ tag }}</a>
66
</li>
77
{% endfor %}
88
</ul>

public/css/style.css

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,11 @@ article > footer {
382382
}
383383

384384
.tags li {
385-
font-weight: bold;
386385
display: inline-block;
387386
background-color: #6db900;
388387
border-radius: 4px;
389388
padding: 0 0.6em;
390-
margin: 0 0.2em;
389+
margin: 0.1em 0.2em;
391390
}
392391

393392
.tags li a, .tags li a:hover, .tags li a:visited {
@@ -472,6 +471,21 @@ article > footer {
472471
border-radius: 4px;
473472
}
474473

474+
/* ---- Tags ---- */
475+
476+
#tags header {
477+
font-size: 80%;
478+
margin-bottom: 1em;
479+
}
480+
481+
#tags header ul {
482+
margin: 0;
483+
}
484+
485+
#tags header li.selected {
486+
background-color: #5cb0cc;
487+
}
488+
475489
/* ---- Site footer ---- */
476490

477491
#container > footer {

public/js/tags.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
function selectTag(tag) {
2+
window.location.hash = '#!' + tag.html();
3+
$('#tags header li').removeClass('selected');
4+
tag.parent().addClass('selected');
5+
$('#tag-list > li').hide().filter('#' + tag.html()).slideDown();
6+
}
7+
18
$(function() {
2-
if ($('#tag-list').length) {
9+
if ($('#tags').length) {
310
var hash = window.location.hash.substr(1);
11+
hash = hash.indexOf('!') == 0 ? hash.substr(1) : hash;
412
if (hash != '') {
5-
$('#tag-list > li[id!=' + hash + ']').remove();
6-
$(window).scrollTop(0);
13+
if ($('#tag-' + hash).length) {
14+
$(window).scrollTop(0);
15+
selectTag($('#tag-' + hash + ' a'));
16+
}
717
}
18+
19+
$('#tags header a').click(function() {
20+
selectTag($(this));
21+
return false;
22+
});
823
}
924
});

tags.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
---
55
<section id="tags">
66
<h1>Tags</h1>
7+
<header>
8+
<ul class="tags">
9+
{% for tag in site.tags %}
10+
<li id="tag-{{ tag[0] }}">
11+
<a href="tags.html#{{ tag[0] }}" title="Voir les posts ayant le tag {{ tag[0] }}">{{ tag[0] }}</a>
12+
</li>
13+
{% endfor %}
14+
</ul>
15+
</header>
716
<ul id="tag-list">
817
{% for tag in site.tags %}
918
<li id="{{ tag[0] }}">{{ tag[0] }}:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy