Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/docs/_includes/js/custom.js
Views: 11623
// Handle opening/closing module overview list items1jtd.onReady(function(ready) {2var forEach = function (list, callback) {3for (var i = 0; i < list.length; i++) {4callback(list[i])5}6};78// Bind listeners for expand all / collapse all functionality9var bindToggleAll = function (selector, options) {10var isOpen = options.open;11var expandAllButtons = document.querySelectorAll(selector);12forEach(expandAllButtons, function (button) {13jtd.addEvent(button, 'click', function (e) {14var originalTarget = e.target || e.srcElement || e.originalTarget;15if (originalTarget.tagName !== 'A') { return; }1617var moduleList = originalTarget.closest('.module-list');18forEach(moduleList.querySelectorAll('.folder > ul'), function (list) {19if (isOpen) {20list.classList.add('open');21} else {22list.classList.remove('open');23}24})2526e.preventDefault();27});28});29};30bindToggleAll('.module-list [data-expand-all]', { open: true })31bindToggleAll('.module-list [data-collapse-all]', { open: false })3233// Bind listeners for collapsing module navigation items34var moduleStructureElements = document.querySelectorAll('.module-structure');35forEach(moduleStructureElements, function (moduleStructure) {36jtd.addEvent(moduleStructure, 'click', function (e) {37var originalTarget = e.target || e.srcElement || e.originalTarget;38if (originalTarget.tagName !== 'A') { return; }3940var parentListItem = originalTarget.closest('li');41if (parentListItem.className.indexOf('folder') === -1) { return; }4243toggleChildModuleList(parentListItem)44e.preventDefault();45});46})4748var toggleChildModuleList = function (parent) {49var list = parent.querySelector('ul');50if (!list) {51return;52}53list.classList.toggle('open');54// Recursively automatically open any nested lists of size 155if (list.children.length === 1) {56toggleChildModuleList(list.children[0])57}58}59});606162