Skip to content

Commit

Permalink
Show current tab in URL
Browse files Browse the repository at this point in the history
This way it is possible to link to a specific part of the documentation,
not just the list. The whole page is in the history only once, so if
user goes from API root to a resource and clicks all tabs there, a
single click on back button will bring them back to API root.

JIRA: PDC-1011
  • Loading branch information
lubomir committed Sep 16, 2015
1 parent ce15935 commit 130fdf1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pdc/apps/common/templates/browsable_api/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,20 @@ <h3>Browsable GET</h3>

</div>
<!-- END Content -->

<script type="text/javascript">
$(document).ready(function() {
if (location.hash !== '') {
$('a[href="' + location.hash + '"]').tab('show');
}
$('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
var hash = '#' + $(e.target).attr('href').substr(1);
if (history.pushState) {
history.replaceState(null, '', hash);
} else {
location.hash = hash;
}
});
});
</script>
{% endblock %}

0 comments on commit 130fdf1

Please sign in to comment.