Skip to content

Commit

Permalink
docs: collapse all categories button
Browse files Browse the repository at this point in the history
  • Loading branch information
arturoc committed May 1, 2013
1 parent 56a985b commit 1278628
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
4 changes: 2 additions & 2 deletions _templates/documentation.mako
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

<div class="page-wide sectiontitle">
<h2>core</h2>
<a class="hide_core_functions">hide functions</a>
<a class="hide_core_functions">hide functions</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="collapse_core">collapse all</a>
</div><!-- End Page Wide -->

<div class="page-wide core">
Expand All @@ -64,7 +64,7 @@
</div><!-- End Page Wide -->

<div class="page-wide sectiontitle">
<h2>addons</h2> <a class="hide_addons_functions">hide functions</a>
<h2>addons</h2> <a class="hide_addons_functions">hide functions</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="collapse_addons">collapse all</a>
</div><!-- End Page Wide -->

<div class="page-wide addons">
Expand Down
2 changes: 1 addition & 1 deletion _templates/documentation_index_block.mako
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%page args="block"/>
<div class="documentation_group">
<div class="documentation_group_head show">
<h2>- ${block.name}<h2>
<h2>${block.name}<h2>
</div>

<!-- fileFuncs -->
Expand Down
2 changes: 1 addition & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ div.sectiontitle h2{
padding: 0px 0px 10px 0px;
position: relative;
}
.hide_core_functions, .hide_addons_functions{
.hide_core_functions, .hide_addons_functions, .collapse_core, .collapse_addons{
cursor:pointer;cursor:hand;
}
#editdocs{
Expand Down
52 changes: 45 additions & 7 deletions js/documentation_index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
var currentHidding=null;
var coreFunctionsHidden=false;
var addonsFunctionsHidden=false;
var coreCollapsed=false;
var addonsCollapsed = false;

$(function(){
$('.documentation_index_group').masonry({
itemSelector: '.box',
Expand All @@ -12,27 +15,28 @@ $(function(){

$(document).ready(
function(){
// collapse one
$('div.documentation_group_head').click(function () {
if(currentHidding!=null) return;
currentHidding = $(this);
if($(this).hasClass('show')){
$(this).next('div.documentation_index_group').hide("blind", { direction: "vertical" }, 500, function(){
currentHidding.children('h2').first().text("+"+currentHidding.children('h2').first().text().substring(1));
$(this).next('.documentation_index_group').hide("blind", { direction: "vertical" }, 500, function(){
currentHidding.removeClass('show');
currentHidding.addClass('hide');
currentHidding = null;
});
}else{
$(this).next('div.documentation_index_group').show("blind", { direction: "vertical" }, 500, function(){
currentHidding.children('h2').first().text("-"+currentHidding.children('h2').first().text().substring(1));
$(this).next('.documentation_index_group').show("blind", { direction: "vertical" }, 500, function(){
currentHidding.removeClass('hide');
currentHidding.addClass('show');
currentHidding = null;
$('.documentation_index_group').masonry( 'reload' );
$(this).masonry( 'reload' );
});
}
});


// hide show functions
$('a.hide_core_functions').click(function(){
if(coreFunctionsHidden){
$('.core ul.documentation_class li.method').show();
Expand All @@ -41,9 +45,9 @@ $(document).ready(
$(this).text('hide functions');
}else{
$('.core ul.documentation_class li.method').hide();
$('.core .documentation_index_group').masonry( 'reload' );
coreFunctionsHidden = true;
$(this).text('show functions');
$('.core .documentation_index_group').masonry( 'reload' );
}
});
$('a.hide_addons_functions').click(function(){
Expand All @@ -54,9 +58,43 @@ $(document).ready(
$(this).text('hide functions');
}else{
$('.addons ul.documentation_class li.method').hide();
$('.addons .documentation_index_group').masonry( 'reload' );
addonsFunctionsHidden = true;
$(this).text('show functions');
$('.addons .documentation_index_group').masonry( 'reload' );
}
});

// collapse all
$('a.collapse_core').click(function(){
if(coreCollapsed){
$('.core .documentation_index_group').show();
$('.core .documentation_index_group').masonry( 'reload' );
$('.core .documentation_group_head').addClass('show');
$('.core .documentation_group_head').removeClass('hide');
coreCollapsed = false;
$(this).text('collapse all');
}else{
$('.core div.documentation_index_group').hide();
$('.core .documentation_group_head').addClass('hide');
$('.core .documentation_group_head').removeClass('show');
coreCollapsed = true;
$(this).text('open all');
}
});
$('a.collapse_addons').click(function(){
if(addonsCollapsed){
$('.addons .documentation_index_group').show();
$('.addons .documentation_index_group').masonry( 'reload' );
$('.addons .documentation_group_head').addClass('show');
$('.addons .documentation_group_head').removeClass('hide');
addonsCollapsed = false;
$(this).text('collapse all');
}else{
$('.addons .documentation_index_group').hide();
$('.addons .documentation_group_head').addClass('hide');
$('.addons .documentation_group_head').removeClass('show');
addonsCollapsed = true;
$(this).text('open all');
}
});
});

0 comments on commit 1278628

Please sign in to comment.