// bigblow.js --- BigBlow JS file
//
// Copyright (C) 2011-2016 All Right Reserved, Fabrice Niessen
//
// This file is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// This file is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// Author: Fabrice Niessen <(concat "fniessen" at-sign "pirilampo.org")>
// URL: https://github.com/fniessen/org-html-themes/
// Version: 20140515.1841
$(function() {
$('p').
html(function(index, old) {
return old.replace('FIXME',
'FIXME');
});
$('p').
html(function(index, old) {
return old.replace('XXX',
'XXX');
});
});
// Remove leading section number
$(function() {
$('.section-number-2').text("");
for (var i = 3; i <= 5; i++) {
$('.section-number-' + i).each(function() {
$(this).text($(this).text().replace(/^[0-9]+\./g, ""));
});
}
});
$(function() {
$('
').prependTo('body');
});
// generate contents of minitoc
function generateMiniToc(divId) {
$('#minitoc').empty().append('In this section
');
$('#' + divId).find('h3').each(function(i) {
let pos = $(this).text().search(" ");
let text = $(this).text().substring(0, pos);
$("#minitoc").append(""
+ text + "");
});
// Ensure that the target is expanded (hideShow)
$('#minitoc a[href^="#"]').click(function() {
var href = $(this).attr('href');
hsExpandAnchor(href);
});
}
// display tabs
function tabifySections() {
// hide TOC (if present)
$('#table-of-contents').hide();
// grab the list of `h2' from the page
var allSections = [];
$('h2')
.each(function() {
// Remove TODO keywords and tags (contained in spans)
var tabText = $(this).clone().find('span').remove().end()
.text().trim();
var tabId = $(this).parent().attr('id');
if (tabText) {
// - remove heading number (all leading digits)
// - remove progress logging (between square brackets)
// - remove leading and trailing spaces
tabText = tabText.replace(/^\d+\s+/, '').replace(/\[[\d/%]+\]/, '').trim();
allSections.push({
text: tabText,
id: tabId
});
}
});
// create the tab links
var tabs = $('');
for (i = 0; i < allSections.length; i++) {
var item = allSections[i];
html = $('' + item.text + '');
tabs.append(html);
}
// insert tabs menu after title (`h1'), or at the beginning of the content
if($('.title').length !== 0) {
$('.title').after(tabs);
}
else {
$('#content').prepend(tabs);
}
}
function selectTabAndScroll(href) {
// At this point we assume that href is local (starts with #)
// alert(href);
// Find the tab to activate
var targetTab = $(href).closest('.ui-tabs-panel');
var targetTabId = targetTab.attr('id');
var targetTabAriaLabel = targetTab.attr('aria-labelledby');
var targetTabIndex = $("#content ul li")
.index($('[aria-labelledby="' + targetTabAriaLabel + '"]'));
// Activate target tab
$('#content').tabs('option', 'active', targetTabIndex);
// Rebuild minitoc
generateMiniToc(targetTabId);
// Set the location hash
// document.location.hash = href;
// Scroll to top if href was a tab
if (href == '#' + targetTabId) {
// alert(targetTabId);
$.scrollTo(0);
}
// Scroll to href if href was not a tab
else {
$.scrollTo(href);
}
}
$(document).ready(function() {
$('#preamble').remove();
$('#table-of-contents').remove();
// Prepare for tabs
tabifySections();
// Build the tabs from the #content div
$('#content').tabs();
// Set default animation
$('#content').tabs('option', 'show', true);
// Rebuild minitoc when a tab is activated
$('#content').tabs({
activate: function(event, ui) {
var divId = ui.newTab.attr('aria-controls');
generateMiniToc(divId);
}
});
// Required to get the link of the tab in URL
$('#content ul').localScroll({
target: '#content',
duration: 0,
hash: true
});
// Handle hash in URL
if ($('#content') && document.location.hash) {
hsExpandAnchor(document.location.hash);
selectTabAndScroll(document.location.hash);
}
// If no hash, build the minitoc anyway for selected tab
else {
var divId = $('#content div[aria-expanded=true]').attr('id');
generateMiniToc(divId);
}
// Handle click on internal links
$('.ui-tabs-panel a[href^="#"]').click(function(e) {
var href = $(this).attr('href');
hsExpandAnchor(href);
selectTabAndScroll(href);
e.preventDefault();
});
// Initialize hideShow
hsInit();
// add sticky headers to tables
$('table').stickyTableHeaders();
});
$(document).ready(function() {
// Add copy to clipboard snippets
$('.org-src-container').prepend('[copy]
');
// Display/hide snippets on source block mouseenter/mouseleave
$(document).on('mouseenter', '.org-src-container', function () {
$(this).find('.snippet-copy-to-clipboard').show();
});
$(document).on('mouseleave', '.org-src-container', function () {
$(this).find('.snippet-copy-to-clipboard').hide();
});
$('.copy-to-clipboard-button').click( function() {
var element = $(this).parent().parent().find('.src');
var val = element.text();
val = val.replace(/\n/g, "\r\n");
var $copyElement = $("