Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dropdown in tabsets #1405

Merged
merged 6 commits into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ rmarkdown 1.11 (unreleased)

* Fix for `run()` to work if `file = NULL` and multiple .Rmd files are present in the search path (#1406) (thanks, @aronatkins #906)

* Added the ability to generate tabset dropdowns, usable by adding the `.tabset-dropdown` class to a header (e.g., `# Heading {.tabset .tabset-dropdown}`) (#1405). Thanks @stefanfritsch for contributing the necessary code for this (#1116).


rmarkdown 1.10
--------------------------------------------------------------------------------
Expand Down
62 changes: 61 additions & 1 deletion inst/rmd/h/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,71 @@
<div class="container-fluid main-container">

<!-- tabsets -->

<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
background: white;
border: 1px solid #ddd;
border-radius: 4px;
}

.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "&#xe258;";
border: none;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}

.tabset-dropdown > .nav-tabs > li.active {
display: block;
}

.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}

.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>

<script>
$$(document).ready(function () {
window.buildTabsets("$idprefix$TOC");
});

$$(document).ready(function () {
$$('.tabset-dropdown > .nav-tabs > li').click(function () {
$$(this).parent().toggleClass('nav-tabs-open')
});
});
Copy link
Member

@jcheng5 jcheng5 Jul 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (295-299) can be improved using jQuery event delegation, it's a good habit to get into:

https://learn.jquery.com/events/event-delegation/

What I'm suggesting is $(document).on("click", ".tabset-dropdown > .nav-tabs > li", ...)

</script>

<!-- code folding -->
Expand All @@ -256,7 +317,6 @@
$endif$



$if(toc_float)$

<script>
Expand Down