--- layout: null --- /** * Convert the div blocks configured with 'tabber-' classes into Bootstrap * tab/pane structures so they can be treated as Bootstrap tab controls. * * See: * https://getbootstrap.com/docs/4.3/components/navs/#javascript-behavior * https://www.w3schools.com/bootstrap/bootstrap_tabs_pills.asp */ /** Liquid generate JSON object of version handlers block **/ {% assign handlers = site.data.theme.versioning.handlers %} const tabSets = { {% for ts in handlers %} {% if ts[1].verb == "tab" %} "{{ts[0]}}": {{ ts[1] | jsonify }} {% endif %} {% endfor %} } /** Custom jQuery functions **/ // Get the name of a tabset, tab, or pane based on this current element class jQuery.fn.getNameByClass = function() { var classes = this.attr("class").split(" "); for (let i = 0; i < classes.length; ++i) { if (classes[i] !== null) { var nameClass = classes[i] .match(/^((tabs|pane|item|link)\-)([a-z_\-0-9]+$)/) if (nameClass != null) { return classes[i].replace(nameClass[0],nameClass[3]); break; }; }; }; }; /** Document ready **/ $( document ).ready(function() { // Get all the tabbed blocks of the page $(".tabber-tabset").each(function() { $(this).addClass("container") var tabberName = $(this).getNameByClass() var tabSet = tabSets[tabberName]['swap']['opts']; $(this).prepend('
') // Get each tabbed pane $(this).find('.tabber-pane').each(function() { var tabName = $(this).getNameByClass() var tabLabel = tabName.replace("-"," ") $(this).wrap('') if (tabSet !== null) { // use a match from the tabSet to affix labevar tabLabel = ; tabEntry = tabSet.find(opt => { return opt.slug == tabName }); if (typeof tabEntry !== "undefined" && tabEntry['text'] !== null) { tabLabel = tabEntry['text'] } }; // use the caption IF there is one $(this).find('.title').each(function() { tabLabel = $(this).html(); $(this).remove() }); $(this).parent().parent('.content') .addClass("tab-content").siblings('.nav.nav-tabs') .append('