Fixed bugs and updated structure
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
// core and prism
|
||||
import * as core from './core/_core.js';
|
||||
import * as Prism from "../../node_modules/prismjs/prism";
|
||||
import "../../node_modules/prismjs/plugins/line-numbers/prism-line-numbers";
|
||||
import "../../node_modules/prismjs/plugins/toolbar/prism-toolbar";
|
||||
import '../../node_modules/prismjs/components/prism-json';
|
||||
import '../../node_modules/prismjs/components/prism-pug';
|
||||
import '../../node_modules/prismjs/components/prism-sass';
|
||||
import "../../node_modules/prismjs/plugins/toolbar/prism-toolbar";
|
||||
import "../../node_modules/prismjs/plugins/line-numbers/prism-line-numbers";
|
||||
|
||||
// import pattern stuff.
|
||||
import * as swtch from "../pg/patterns/core/components/switch/_switch.js";
|
||||
import * as stickynote from "../pg/patterns/core/components/sticky-note/_sticky-note.js";
|
||||
import * as tabs from "../pg/patterns/core/layouts/tabs/_tabs.js";
|
||||
import * as stickynote from "../pg/patterns/core/sticky-note/_sticky-note.js";
|
||||
import * as swtch from "../pg/patterns/core/switch/_switch.js";
|
||||
import * as tabs from "../pg/patterns/core/tabs/_tabs.js";
|
||||
|
||||
// init core
|
||||
core.init({
|
||||
@@ -24,30 +24,33 @@ core.init({
|
||||
}
|
||||
});
|
||||
|
||||
jQuery(document).ready(function($){
|
||||
// show deprecated switch
|
||||
function flipDeprecated() {
|
||||
setTimeout(function(){
|
||||
if ($("#deprecated").attr("aria-checked") == "false") {
|
||||
$(".status-deprecated").closest("article").addClass("status-deprecated");
|
||||
core.cookie.set("show-deprecated", false, 30, "/");
|
||||
} else {
|
||||
$("article.status-deprecated").removeClass("status-deprecated");
|
||||
core.cookie.set("show-deprecated", true, 30, "/");
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
|
||||
$("#deprecated").on("click", flipDeprecated).on("keypress", flipDeprecated);
|
||||
setTimeout( function() {
|
||||
if (core.cookie.get("show-deprecated") == "true") {
|
||||
$("#deprecated").attr("aria-checked", "true");
|
||||
flipDeprecated();
|
||||
}
|
||||
}, 200);
|
||||
console.log("hide deprecated", { "type": (typeof core.cookie.get("show-deprecated")), "value": core.cookie.get("show-deprecated") });
|
||||
// /hide deprecated switch
|
||||
|
||||
})
|
||||
// deprecated switch handler
|
||||
const flipDeprecated = (e, s = e.currentTarget) => {
|
||||
core.cookie.set("show-deprecated", s.getAttribute("aria-checked"), 30, "/");
|
||||
document.querySelector("main").querySelectorAll("article[data-status=deprecated]").forEach((a) => {
|
||||
a.classList[( s.getAttribute("aria-checked") == "true" ? "add" : "remove" )]("show-deprecated")
|
||||
});
|
||||
}
|
||||
|
||||
// import("../pg/patterns/layouts/main-navigation/_main-navigation.js");
|
||||
// create a pure JS mouse click event
|
||||
const click = new MouseEvent('click', {
|
||||
view: window,
|
||||
bubbles: false,
|
||||
cancelable: true
|
||||
});
|
||||
|
||||
// get the switch, initialize it and add the handler
|
||||
let deprecated = document.querySelector("#deprecated");
|
||||
swtch.init(deprecated.parentNode)
|
||||
deprecated.onclick = flipDeprecated;
|
||||
deprecated.keypress = flipDeprecated;
|
||||
|
||||
// check a cookie to get the switch's state
|
||||
if (core.cookie.get("show-deprecated") == "true") {
|
||||
deprecated.dispatchEvent(click);
|
||||
}
|
||||
|
||||
// just for fun... We'll show deprecated if they match the path
|
||||
// document.querySelector(`#${core.url.p.replace(/\//g, "-")}`).classList.add("show-deprecated");
|
||||
|
Reference in New Issue
Block a user