Skip to content

Commit

Permalink
Format and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jhildenbiddle committed Dec 21, 2023
1 parent 2edf117 commit 30d32fa
Show file tree
Hide file tree
Showing 49 changed files with 3,446 additions and 2,931 deletions.
12 changes: 6 additions & 6 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"default": true,
"MD001": false,
"MD004": { "style": "consistent" },
"MD013": false,
"MD033": false,
"MD036": false
"default": true,
"MD001": false,
"MD004": { "style": "consistent" },
"MD013": false,
"MD033": false,
"MD036": false
}
24 changes: 12 additions & 12 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"cSpell.words": [
"Codacy",
"copycode",
"coverpage",
"jhildenbiddle",
"ponyfill",
"preprocessors",
"prismjs",
"readytransition",
"themeable"
]
}
"cSpell.words": [
"Codacy",
"copycode",
"coverpage",
"jhildenbiddle",
"ponyfill",
"preprocessors",
"prismjs",
"readytransition",
"themeable"
]
}
60 changes: 31 additions & 29 deletions docs/assets/css/main.css
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
.markdown-section iframe[src*="buttons.github.io"] {
margin: 0;
.markdown-section iframe[src*='buttons.github.io'] {
margin: 0;
}

figure.thumbnails img {
margin: 0.75em 0;
border-radius: 3px;
box-shadow: 0 2px 6px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.15);
margin: 0.75em 0;
border-radius: 3px;
box-shadow:
0 2px 6px rgba(0, 0, 0, 0.1),
0 4px 12px rgba(0, 0, 0, 0.15);
}

@media (min-width: 30em) {
figure.thumbnails:after {
content: "";
display: table;
clear: both;
}
figure.thumbnails:after {
content: '';
display: table;
clear: both;
}

figure.thumbnails img {
float: left;
width: calc(50% - 0.75em);
}
figure.thumbnails img {
float: left;
width: calc(50% - 0.75em);
}

figure.thumbnails img:nth-child(even) {
margin-left: 1.5em;
}
figure.thumbnails img:nth-child(even) {
margin-left: 1.5em;
}

@supports (display: flex) {
figure.thumbnails {
display: flex;
align-items: center;
}
@supports (display: flex) {
figure.thumbnails {
display: flex;
align-items: center;
}

figure.thumbnails img {
flex-grow: 1;
width: 0;
}
figure.thumbnails img {
flex-grow: 1;
width: 0;
}

figure.thumbnails img + img {
margin: 0 0 0 1.5em;
}
figure.thumbnails img + img {
margin: 0 0 0 1.5em;
}
}
}
253 changes: 137 additions & 116 deletions docs/assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1,127 +1,148 @@
(function() {
// Functions
// =========================================================================
/**
* Adds event listeners to change active stylesheet and restore previously
* activated stylesheet on reload.
*
* @example
*
* This link:
* <a href="#" data-style-href="path/to/file.css" data-style-group="foo">Bar</a>
* Activates an existing matched <link> (href + group match):
* <link rel="stylesheet alternate" data-style-group="foo" href="deep/path/to/file.css" >
* Generates a new <link> if needed (no href + group match):
* <link rel="stylesheet" data-style-group="foo" href="path/to/file.css" >
* Disables <link> elements that match group but not href
* <link rel="stylesheet" data-style-group="foo" href="some/other/file.css" >
* Ignores <link> elements that do not match href and group
* <link rel="stylesheet" data-style-group="bar" href="some/other/file.css" >
*/
function initStyleSwitcher() {
var SESSION_STORAGE_KEY = 'activeStylesheetHref';
var SESSION_VAL_SEPARATOR = '||';

var isInitialized = false;

function createLinkedStylesheet(styleHref, styleGroup) {
var activeElm = document.createElement('link');

activeElm.setAttribute('rel', 'stylesheet');
activeElm.setAttribute('href', styleHref);
activeElm.setAttribute('data-style-group', styleGroup || '');

document.head.appendChild(activeElm);

activeElm.addEventListener('load', function linkOnLoad() {
activeElm.removeEventListener('load', linkOnLoad);
handleSwitch(styleHref, styleGroup);
});

return activeElm;
}

function handleSwitch(styleHref, styleGroup) {
var activeElm = styleGroup
? document.querySelector('link[href*="' + styleHref +'"][data-style-group="' + styleGroup + '"]')
: document.querySelector('link[href*="' + styleHref +'"]');

if (!activeElm) {
activeElm = createLinkedStylesheet(styleHref, styleGroup);

// Stylesheet will call this function after loading is complete
return;
}

// Remove "alternate" keyword and media attribute
activeElm.setAttribute('rel', (activeElm.rel || '').replace(/\s*alternate/g, '').trim());
activeElm.removeAttribute('media');

// Force enable stylesheet (required for some browsers)
activeElm.disabled = true;
activeElm.disabled = false;

// Store active style sheet
sessionStorage.setItem(SESSION_STORAGE_KEY, styleGroup ? styleHref + SESSION_VAL_SEPARATOR + styleGroup : styleHref);

var inactiveElms = styleGroup
? document.querySelectorAll('link:not([href*="' + styleHref +'"])[data-style-group="' + styleGroup + '"]')
: document.querySelectorAll('link:not([href*="' + styleHref +'"])');
(function () {
// Functions
// =========================================================================
/**
* Adds event listeners to change active stylesheet and restore previously
* activated stylesheet on reload.
*
* @example
*
* This link:
* <a href="#" data-style-href="path/to/file.css" data-style-group="foo">Bar</a>
* Activates an existing matched <link> (href + group match):
* <link rel="stylesheet alternate" data-style-group="foo" href="deep/path/to/file.css" >
* Generates a new <link> if needed (no href + group match):
* <link rel="stylesheet" data-style-group="foo" href="path/to/file.css" >
* Disables <link> elements that match group but not href
* <link rel="stylesheet" data-style-group="foo" href="some/other/file.css" >
* Ignores <link> elements that do not match href and group
* <link rel="stylesheet" data-style-group="bar" href="some/other/file.css" >
*/
function initStyleSwitcher() {
var SESSION_STORAGE_KEY = 'activeStylesheetHref';
var SESSION_VAL_SEPARATOR = '||';

var isInitialized = false;

function createLinkedStylesheet(styleHref, styleGroup) {
var activeElm = document.createElement('link');

activeElm.setAttribute('rel', 'stylesheet');
activeElm.setAttribute('href', styleHref);
activeElm.setAttribute('data-style-group', styleGroup || '');

document.head.appendChild(activeElm);

activeElm.addEventListener('load', function linkOnLoad() {
activeElm.removeEventListener('load', linkOnLoad);
handleSwitch(styleHref, styleGroup);
});

return activeElm;
}

// Disable other elms
for (var i = 0; i < inactiveElms.length; i++) {
var elm = inactiveElms[i];
function handleSwitch(styleHref, styleGroup) {
var activeElm = styleGroup
? document.querySelector(
'link[href*="' +
styleHref +
'"][data-style-group="' +
styleGroup +
'"]'
)
: document.querySelector('link[href*="' + styleHref + '"]');

if (!activeElm) {
activeElm = createLinkedStylesheet(styleHref, styleGroup);

// Stylesheet will call this function after loading is complete
return;
}

// Remove "alternate" keyword and media attribute
activeElm.setAttribute(
'rel',
(activeElm.rel || '').replace(/\s*alternate/g, '').trim()
);
activeElm.removeAttribute('media');

// Force enable stylesheet (required for some browsers)
activeElm.disabled = true;
activeElm.disabled = false;

// Store active style sheet
sessionStorage.setItem(
SESSION_STORAGE_KEY,
styleGroup ? styleHref + SESSION_VAL_SEPARATOR + styleGroup : styleHref
);

var inactiveElms = styleGroup
? document.querySelectorAll(
'link:not([href*="' +
styleHref +
'"])[data-style-group="' +
styleGroup +
'"]'
)
: document.querySelectorAll('link:not([href*="' + styleHref + '"])');

// Disable other elms
for (var i = 0; i < inactiveElms.length; i++) {
var elm = inactiveElms[i];

elm.disabled = true;

// Fix for browsersync and alternate stylesheet updates. Will
// cause FOUC when switching stylesheets during development, but
// required to properly apply style updates when alternate
// stylesheets are enabled.
if (window.browsersyncObserver) {
var linkRel = elm.getAttribute('rel') || '';
var linkRelAlt =
linkRel.indexOf('alternate') > -1
? linkRel
: (linkRel + ' alternate').trim();

elm.setAttribute('rel', linkRelAlt);
}
}

elm.disabled = true;
// CSS custom property ponyfill
if ((window.$docsify || {}).themeable) {
window.$docsify.themeable.util.cssVars();
}
}

// Fix for browsersync and alternate stylesheet updates. Will
// cause FOUC when switching stylesheets during development, but
// required to properly apply style updates when alternate
// stylesheets are enabled.
if (window.browsersyncObserver) {
var linkRel = elm.getAttribute('rel') || '';
var linkRelAlt = linkRel.indexOf('alternate') > -1 ? linkRel : (linkRel + ' alternate').trim();
// Event listeners
if (!isInitialized) {
isInitialized = true;

elm.setAttribute('rel', linkRelAlt);
}
}
// Restore active stylesheet
document.addEventListener('DOMContentLoaded', function () {
var storedData = sessionStorage.getItem(SESSION_STORAGE_KEY) || '';
var storedVals = storedData.split(SESSION_VAL_SEPARATOR);
var styleHref = storedVals[0] || '';
var styleGroup = storedVals[1] || '';

// CSS custom property ponyfill
if ((window.$docsify || {}).themeable) {
window.$docsify.themeable.util.cssVars();
}
if (styleHref) {
handleSwitch(styleHref, styleGroup);
}
});

// Update active stylesheet
document.addEventListener('click', function (evt) {
var styleHref = evt.target.getAttribute('data-style-href');
var styleGroup = evt.target.getAttribute('data-style-group');

// Event listeners
if (!isInitialized) {
isInitialized = true;

// Restore active stylesheet
document.addEventListener('DOMContentLoaded', function() {
var storedData = sessionStorage.getItem(SESSION_STORAGE_KEY) || '';
var storedVals = storedData.split(SESSION_VAL_SEPARATOR);
var styleHref = storedVals[0] || '';
var styleGroup = storedVals[1] || '';

if (styleHref) {
handleSwitch(styleHref, styleGroup);
}
});

// Update active stylesheet
document.addEventListener('click', function(evt) {
var styleHref = evt.target.getAttribute('data-style-href');
var styleGroup = evt.target.getAttribute('data-style-group');

if (styleHref) {
handleSwitch(styleHref, styleGroup);
evt.preventDefault();
}
});
if (styleHref) {
handleSwitch(styleHref, styleGroup);
evt.preventDefault();
}
});
}
}

// Main
// =========================================================================
initStyleSwitcher();
// Main
// =========================================================================
initStyleSwitcher();
})();
Loading

0 comments on commit 30d32fa

Please sign in to comment.