Skip to content
This repository has been archived by the owner on Jun 24, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: do not attempt to push state when there are no tabs
  • Loading branch information
Christian Kruse committed Jun 14, 2016
1 parent 280ae70 commit ec36c36
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/assets/javascripts/auto/tabs.js
@@ -1,6 +1,10 @@
/* -*- coding: utf-8 -*- */

$(document).ready(function() {
if($('.cf-tab-content').length == 0) {
return;
}

var targetlist = '<nav><ul class="tabswitcher"></ul></nav>', targets = '';
$('.cf-tab-content').prepend(targetlist);
$('.cf-tab-pane').each(function(){
Expand All @@ -13,6 +17,11 @@ $(document).ready(function() {
var hash = document.location.hash;
if(!hash && history.pushState) {
var first = $(".tabswitcher li a:first");

if(first.length == 0) {
return;
}

hash = first.attr("href");
history.pushState({}, first.text(), hash);
}
Expand Down

0 comments on commit ec36c36

Please sign in to comment.