Files
shaka-player/docs/jsdoc-template/static/scripts/show-widget.js
T
Joey Parrish c2472dcffc Allow the user to show/hide parts of the docs
This adds custom CSS classes and a widget to show/hide various parts
of the docs.  By default, we show exported interfaces only.  The user
can also select "public" (all public interfaces, even those not
exported), and "everything" (even private members).

Issue #1259

Change-Id: Iff8f4d84658a3d19ad8f2f979ab37b256393589f
2018-02-01 21:55:01 +00:00

44 lines
1.3 KiB
JavaScript

function onShowChange() {
var value = document.getElementById('show').value;
localStorage.setItem('show', value);
var setVisibilityByAccess = function(access, visible) {
var selector = '.access-' + access;
var list = document.querySelectorAll(selector);
// querySelectorAll returns an array-like object, not an array.
Array.prototype.forEach.call(list, function(element) {
if (visible) {
element.classList.add('show');
} else {
element.classList.remove('show');
}
});
};
if (value == 'exported') {
setVisibilityByAccess('public', false);
setVisibilityByAccess('private', false);
} else if (value == 'public') {
setVisibilityByAccess('public', true);
setVisibilityByAccess('private', false);
} else {
setVisibilityByAccess('public', true);
setVisibilityByAccess('private', true);
}
}
function initShowWidget() {
// get the previous setting from storage and populate the form.
var storedSetting = localStorage.getItem('show');
document.getElementById('show').value = storedSetting;
if (!document.getElementById('show').value) {
// fix nonsense, missing, or corrupted values.
document.getElementById('show').value = 'exported';
}
// enact the setting we loaded.
onShowChange();
}