Sha256: a70c2b428881a4d23a7c99abaada6779347796af90bfd0ce9dc846564df69fc2
Contents?: true
Size: 1.17 KB
Versions: 77
Compression:
Stored size: 1.17 KB
Contents
// This code is to implement the tabs on the home page // navigate to the selected tab or the first tab function tabNavigation(e) { var activeTab = $('[href="' + location.hash + '"]'); if (activeTab.length) { activeTab.tab('show'); } else { var firstTab = $('.nav-tabs a:first'); // select the first tab if it has an id and is expected to be selected if ((firstTab[0] !== undefined) && (firstTab[0].id != "")){ $(firstTab).tab('show'); } } } Blacklight.onLoad(function () { // When we visit a link to a tab, open that tab. var url = document.location.toString(); if (url.match('#')) { $('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show'); } // Change the url when a tab is clicked. $('a[data-toggle="tab"]').on('click', function(e) { // Set turbolinks: true so that turbolinks can handle the back requests // See https://github.com/turbolinks/turbolinks/blob/master/src/turbolinks/history.coffee#L28 history.pushState({turbolinks: true}, null, $(this).attr('href')); }); // navigate to a tab when the history changes (back button) window.addEventListener("popstate", tabNavigation); });
Version data entries
77 entries across 77 versions & 1 rubygems