1.7 par kozlika & nikrou

This commit is contained in:
brol 2015-05-30 00:50:40 +02:00
parent a8692bb2e7
commit 8347589771
7 changed files with 89 additions and 28 deletions

View file

@ -1,2 +1,7 @@
# shortArchives
Afficher les archives du blog dans un menu accordéon, trié par années.
Widget d'affichage des archives pour le blog des news de Dotclear. Le principe de l'accordéon originel revisité pour un affichage des mois à côté de la date "ouverte".
Todo:
* Ajouter les attributs ARIA kivonbien.

View file

@ -1,10 +1,10 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
# This file is part of shortArchives, a plugin for Dotclear.
#
#
# Copyright (c) 2009-2015 - annso and contributors
# contact@as-i-am.fr
#
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@ -16,7 +16,7 @@ $this->registerModule(
/* Name */ "shortArchives",
/* Description*/ "Display blog archives in an accordion menu, sorted by year",
/* Author */ "annso, Pierre Van Glabeke",
/* Version */ "1.6",
/* Version */ "1.7",
/* Properties */
array(
'permissions' => 'usage,contentadmin',

View file

@ -1,10 +1,10 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
# This file is part of shortArchives, a plugin for Dotclear.
#
#
# Copyright (c) 2009-2015 - annso and contributors
# contact@as-i-am.fr
#
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@ -39,28 +39,38 @@ class tplShortArchives
($w->homeonly == 2 && $core->url->type == 'default')) {
return;
}
$params = array();
$params['type'] = 'month';
$rs = $core->blog->getDates($params);
$rs = $core->blog->getDates($params);
unset($params);
if ($rs->isEmpty()) {
return;
}
$active_year = null;
if (($core->url->type == 'archive') && preg_match('`^/([0-9]{4})/([0-9]{2})$`',$core->url->args,$matches)) {
$active_year = $matches[1];
}
$posts = array();
while ($rs->fetch()) {
$posts[dt::dt2str(__('%Y'),$rs->dt)][] = array('url' => $rs->url($core),
'date' => html::escapeHTML(dt::dt2str(__('%B'),$rs->dt)),
$posts[dt::dt2str(__('%Y'),$rs->dt)][] = array('url' => $rs->url($core),
'date' => html::escapeHTML(dt::dt2str(__('%B'),$rs->dt)),
'nbpost' => $rs->nb_post);
}
$res =
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
'<ul>';
foreach($posts as $annee=>$post) {
$res .= '<li><span>'.$annee.'</span><ul>';
'<ul class="arch-years">';
foreach($posts as $annee => $post) {
if (!is_null($active_year) && $active_year == $annee) {
$res .= '<li class="open">';
} else {
$res .= '<li>';
}
$res .= '<span>'.$annee.'</span><ul class="arch-months">';
for($i=0; $i<sizeof($post); $i++) {
$res .=
'<li><a href="'.$post[$i]['url'].'">'.$post[$i]['date'].'</a>'.
@ -73,4 +83,4 @@ class tplShortArchives
return $w->renderDiv($w->content_only,'shortArchives '.$w->class,'',$res);
}
}
}

View file

@ -1,7 +1,13 @@
v1.7 - 28-05-2015 - Kozlika & Nikrou
* suppression d'image et gestion de l'indicateur via css
* ajout de classes sur chaque liste (année/mois)
* application de la class .open sur l'item ouvert par défaut
* application de la class .open sur l'item correspondant au mois actif en cas de consulation des archives
v1.6 - 25-04-2015 - Pierre Van Glabeke
* modif appel css
* ajout localisation
* ajout identification widget
v1.5 - 14-12-2014 - Pierre Van Glabeke
* compatibilité dc2.7
* compatibilité dc2.7

View file

@ -1,5 +1,41 @@
.shortArchives li a.archives-year {
background: url(index.php?pf=shortArchives/img/bullet_arrow_down.png) left center no-repeat;
padding-left: 20px;
}
.shortArchives li ul li { list-style-type: none;}
@charset "UTF-8";
/* ------------------------ shortArchives styles */
.shortArchives .arch-years,
.shortArchives .arch-months {
margin-left: 0;
list-style-type: none;
}
/* liste années */
.shortArchives .arch-years > li {
padding-left: 0;
}
.shortArchives .arch-months {
margin: .5em 0 .5em 1.5em;
}
/* année fermée */
.shortArchives a.archives-year {
text-decoration: none;
}
.shortArchives a.archives-year:before {
padding-right: .5em;
color: #aaa;
content: "\25b8";
speak: none;
}
/* année ouverte */
.shortArchives .open .archives-year {
font-weight: bold;
text-decoration: none;
}
.shortArchives .open .archives-year:before {
padding-right: .5em;
color: #333;
content: "\25be";
speak: none;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 B

View file

@ -1,18 +1,22 @@
$(document).ready(function(){
$(".shortArchives li ul:not(:first)").hide();
if ($(".shortArchives li.open").length == 0) {
$(".shortArchives li:first").addClass('open');
}
$(".shortArchives li:not(.open) ul").hide();
$(".shortArchives li span").each( function () {
var txt = $(this).text();
$(this).replaceWith('<a href="" class="archives-year">' + txt + '<\/a>') ;
});
$(".shortArchives li span").each( function () {
var txt = $(this).text();
$(this).replaceWith('<a href="" class="archives-year">' + txt + '<\/a>') ;
} ) ;
$(".shortArchives li a.archives-year").click(function(){
if ($(this).next(".shortArchives li ul:visible").length != 0) {
$(".shortArchives li ul:visible").slideUp("normal", function () { $(this).parent().removeClass("open") });
$(".shortArchives li:first").removeClass('open');
} else {
$(".shortArchives li ul").slideUp("normal", function () { $(this).parent().removeClass("open") });
$(this).next("ul").slideDown("normal", function () { $(this).parent().addClass("open") });
}
return false;
});
});
});