2018-04-21 04:59:30 -04:00
|
|
|
(function() {
|
|
|
|
"use strict";
|
2012-04-05 00:53:10 -04:00
|
|
|
var switched = false;
|
2018-04-21 04:59:30 -04:00
|
|
|
|
|
|
|
document.querySelectorAll(":not(.syntaxhighlighter)>table").forEach(function(element) {
|
|
|
|
element.classList.add("responsive");
|
|
|
|
});
|
|
|
|
|
2012-04-05 00:53:10 -04:00
|
|
|
var updateTables = function() {
|
2018-04-21 04:59:30 -04:00
|
|
|
if (document.documentElement.clientWidth < 767 && !switched) {
|
2012-04-05 00:53:10 -04:00
|
|
|
switched = true;
|
2018-04-21 04:59:30 -04:00
|
|
|
document.querySelectorAll("table.responsive").forEach(splitTable);
|
|
|
|
} else {
|
2012-04-05 00:53:10 -04:00
|
|
|
switched = false;
|
2018-04-21 04:59:30 -04:00
|
|
|
document.querySelectorAll(".table-wrapper table.responsive").forEach(unsplitTable);
|
2012-04-05 00:53:10 -04:00
|
|
|
}
|
2018-04-21 04:59:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", updateTables);
|
|
|
|
window.addEventListener("resize", updateTables);
|
|
|
|
|
|
|
|
var splitTable = function(original) {
|
|
|
|
wrap(original, createElement("div", "table-wrapper"));
|
|
|
|
|
|
|
|
var $copy = original.cloneNode(true);
|
|
|
|
$copy.querySelectorAll("td:not(:first-child), th:not(:first-child)").forEach(function(element) {
|
|
|
|
element.style.display = "none";
|
|
|
|
});
|
|
|
|
$copy.classList.remove("responsive");
|
|
|
|
|
|
|
|
original.parentNode.append($copy);
|
|
|
|
wrap($copy, createElement("div", "pinned"))
|
|
|
|
wrap(original, createElement("div", "scrollable"));
|
|
|
|
}
|
2012-04-05 00:53:10 -04:00
|
|
|
|
2018-04-21 04:59:30 -04:00
|
|
|
var unsplitTable = function(original) {
|
|
|
|
document.querySelectorAll(".table-wrapper .pinned").forEach(function(element) {
|
|
|
|
element.parentNode.removeChild(element);
|
|
|
|
});
|
|
|
|
unwrap(original.parentNode);
|
|
|
|
unwrap(original);
|
|
|
|
}
|
|
|
|
}).call(this);
|