Skip to content

Instantly share code, notes, and snippets.

@Richienb
Last active April 17, 2019 06:08
Show Gist options
  • Save Richienb/0fc224502155f1f69973c473d5b5c90b to your computer and use it in GitHub Desktop.
Save Richienb/0fc224502155f1f69973c473d5b5c90b to your computer and use it in GitHub Desktop.
PyMdown Extensions Details Polyfill CDN

DEPRECATED

Moved to Richienb/pedp.


Pymdown extensions - Details polyfill CDN

Static Fast Loading Version

Minified Files

https://gistcdn.githack.com/Richienb/0fc224502155f1f69973c473d5b5c90b/raw/ef234f31347da21d59bf05df308c7f46de7b2807/pymdown-details-polyfill.min.css
https://gistcdn.githack.com/Richienb/0fc224502155f1f69973c473d5b5c90b/raw/1595668df391647b3db06c4179600a29c463870b/pymdown-details-polyfill.min.js

Original Files

https://gistcdn.githack.com/Richienb/0fc224502155f1f69973c473d5b5c90b/raw/ef234f31347da21d59bf05df308c7f46de7b2807/pymdown-details-polyfill.css
https://gistcdn.githack.com/Richienb/0fc224502155f1f69973c473d5b5c90b/raw/ef234f31347da21d59bf05df308c7f46de7b2807/pymdown-details-polyfill.js

Always Up To Date Version

Minified Files

https://gist.githack.com/Richienb/0fc224502155f1f69973c473d5b5c90b/raw/f59855a5253f7684bcef8f987a933719956cdd50/pymdown-details-polyfill.min.css
https://gist.githack.com/Richienb/0fc224502155f1f69973c473d5b5c90b/raw/f59855a5253f7684bcef8f987a933719956cdd50/pymdown-details-polyfill.min.js

Original Files

https://gist.githack.com/Richienb/0fc224502155f1f69973c473d5b5c90b/raw/f59855a5253f7684bcef8f987a933719956cdd50/pymdown-details-polyfill.css
https://gist.githack.com/Richienb/0fc224502155f1f69973c473d5b5c90b/raw/f59855a5253f7684bcef8f987a933719956cdd50/pymdown-details-polyfill.js
details {
display: block;
}
details[open] > summary::before {
content: "\25BC";
}
details summary {
display: block;
cursor: pointer;
}
details summary:focus {
outline: none;
}
details summary::before {
content: "\25B6";
padding-right: 0.5em;
}
details summary::-webkit-details-marker {
display: none;
}
/* Attach the "no-details" class to details tags
in browsers that do not support them to get
open/show functionality. */
details.no-details:not([open]) > * {
display: none;
}
details.no-details:not([open]) summary {
display: block;
}
(function () {
'use strict';
/**
* Converts details/summary tags into working elements in browsers that don't yet support them.
* @return {void}
*/
var details = (function () {
var isDetailsSupported = function () {
// https://mathiasbynens.be/notes/html5-details-jquery#comment-35
// Detect if details is supported in the browser
var el = document.createElement("details");
var fake = false;
if (!("open" in el)) {
return false;
}
var root = document.body || function () {
var de = document.documentElement;
fake = true;
return de.insertBefore(document.createElement("body"), de.firstElementChild || de.firstChild);
}();
el.innerHTML = "<summary>a</summary>b";
el.style.display = "block";
root.appendChild(el);
var diff = el.offsetHeight;
el.open = true;
diff = diff !== el.offsetHeight;
root.removeChild(el);
if (fake) {
root.parentNode.removeChild(root);
}
return diff;
}();
if (!isDetailsSupported) {
var blocks = document.querySelectorAll("details>summary");
for (var i = 0; i < blocks.length; i++) {
var summary = blocks[i];
var details = summary.parentNode;
// Apply "no-details" to for unsupported details tags
if (!details.className.match(new RegExp("(\\s|^)no-details(\\s|$)"))) {
details.className += " no-details";
}
summary.addEventListener("click", function (e) {
var node = e.target.parentNode;
if (node.hasAttribute("open")) {
node.removeAttribute("open");
} else {
node.setAttribute("open", "open");
}
});
}
}
});
(function () {
var onReady = function onReady(fn) {
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", fn);
} else {
document.attachEvent("onreadystatechange", function () {
if (document.readyState === "interactive") {
fn();
}
});
}
};
onReady(function () {
details();
});
})();
}());
details{display:block}details[open]>summary::before{content:"\25BC"}details summary{display:block;cursor:pointer}details summary:focus{outline:0}details summary::before{content:"\25B6";padding-right:.5em}details summary::-webkit-details-marker{display:none}details.no-details:not([open])>*{display:none}details.no-details:not([open]) summary{display:block}
(function(){function g(){if(!function(){var a=document.createElement("details"),c=!1;if(!("open"in a))return!1;var b;(b=document.body)||(b=document.documentElement,c=!0,b=b.insertBefore(document.createElement("body"),b.firstElementChild||b.firstChild));a.innerHTML="<summary>a</summary>b";a.style.display="block";b.appendChild(a);var d=a.offsetHeight;a.open=!0;d=d!==a.offsetHeight;b.removeChild(a);c&&b.parentNode.removeChild(b);return d}())for(var c=document.querySelectorAll("details>summary"),d=0;d<
c.length;d++){var f=c[d],e=f.parentNode;e.className.match(/(\s|^)no-details(\s|$)/)||(e.className+=" no-details");f.addEventListener("click",function(a){a=a.target.parentNode;a.hasAttribute("open")?a.removeAttribute("open"):a.setAttribute("open","open")})}}(function(){(function(c){document.addEventListener?document.addEventListener("DOMContentLoaded",c):document.attachEvent("onreadystatechange",function(){"interactive"===document.readyState&&c()})})(function(){g()})})()})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment