shortArchives/js/accordion.js

23 lines
860 B
JavaScript
Raw Normal View History

2015-04-25 18:38:55 +00:00
$(document).ready(function(){
2015-05-29 22:50:40 +00:00
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>') ;
});
2015-04-25 18:38:55 +00:00
$(".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") });
2015-05-29 22:50:40 +00:00
$(".shortArchives li:first").removeClass('open');
2015-04-25 18:38:55 +00:00
} else {
$(".shortArchives li ul").slideUp("normal", function () { $(this).parent().removeClass("open") });
$(this).next("ul").slideDown("normal", function () { $(this).parent().addClass("open") });
}
return false;
});
2015-05-29 22:50:40 +00:00
});