"use strict";

var $ = require('jquery');

// Tab functions on jquery
require('bootstrap');

module.exports = function (tabList) {
    // Use hash to determine which tab to go to
    var hash = window.location.hash;
    if (hash) {
        $(tabList).find('a[href="' + hash + '"]').tab('show');
    }

    // bootstrap swallows events so the url doesn't change
    // add our own here
    $(tabList).on('click', 'a', function (e) {
        $(this).tab('show');

        var originalScrollPosition = $('body').scrollTop();
        window.location.hash = this.hash;
        $('html,body').scrollTop(originalScrollPosition);
    });
};

@@ -120,24 +120,61 @@
 (tabList) %7B%0A
+    function changeTabToHash() %7B%0A    
     // Use h
@@ -209,16 +209,20 @@
 o go to%0A
+    
     var 
@@ -246,24 +246,28 @@
 ation.hash;%0A
+    
     if (hash
@@ -266,24 +266,28 @@
 if (hash) %7B%0A
+    
         $(ta
@@ -341,17 +341,50 @@
 ');%0A    
-%7D
+    %7D%0A    %7D%0A    changeTabToHash();
 %0A%0A    //
@@ -705,11 +705,106 @@
     %7D);%0A
+    if (%22onhashchange%22 in window) %7B%0A        $(window).on(%22hashchange%22, changeTabToHash);%0A    %7D%0A
 %7D;%0A

Change tabs on browser back/forward to match hash