ds2-core/src/js/scaffolding.js

81 lines
2.5 KiB
JavaScript
Raw Normal View History

2024-07-12 22:19:12 -04:00
// core and prism
2024-07-11 21:05:34 -04:00
import * as core from './_core.js';
2024-06-13 00:00:00 -04:00
import * as Prism from "../../node_modules/prismjs/prism";
import '../../node_modules/prismjs/components/prism-json';
import '../../node_modules/prismjs/components/prism-pug';
2024-07-11 21:05:34 -04:00
import '../../node_modules/prismjs/components/prism-sass';
2024-06-13 00:00:00 -04:00
import "../../node_modules/prismjs/plugins/toolbar/prism-toolbar";
import "../../node_modules/prismjs/plugins/line-numbers/prism-line-numbers";
2024-07-12 22:19:12 -04:00
// import pattern stuff.
2024-06-13 00:00:00 -04:00
import * as swtch from "../pg/patterns/components/switch-core/_switch.js";
2024-07-11 21:05:34 -04:00
import * as stickynote from "../pg/patterns/components/sticky-note-core/_sticky-note.js";
2024-06-13 00:00:00 -04:00
import * as tabs from "../pg/patterns/layouts/tabs-core/_tabs.js";
2024-07-12 22:19:12 -04:00
// init core
core.init({
success: (a) => {
tabs.init(a);
swtch.init(a);
stickynote.init(a);
},
notFound: (a, path) => {
a.innerHTML = `${a.innerHTML}<div class='notification-box error'><p>This pattern appears to be missing.<br><small>(${path} returned http status 404)</small></p></div>`;
}
});
2024-06-13 00:00:00 -04:00
2024-07-11 21:05:34 -04:00
2024-07-12 22:19:12 -04:00
// handler for the deprecated switch
/*
2024-06-13 00:00:00 -04:00
// selectable content
jQuery.fn.OneClickSelect = function () {
return jQuery(this).on('click', function () {
2024-07-11 21:05:34 -04:00
// In here, "this" is the element
2024-06-13 00:00:00 -04:00
var range, selection;
if (window.getSelection) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(this);
selection.removeAllRanges();
selection.addRange(range);
} else if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(this);
range.select();
}
});
};
2024-07-12 22:19:12 -04:00
*/
2024-06-13 00:00:00 -04:00
jQuery(document).ready(function($){
// show deprecated switch
function flipDeprecated() {
setTimeout(function(){
if ($("#deprecated").attr("aria-checked") == "false") {
$(".status-deprecated").closest("article").addClass("status-deprecated");
2024-07-12 22:19:12 -04:00
core.cookie.set("show-deprecated", false, 30, "/");
2024-06-13 00:00:00 -04:00
} else {
$("article.status-deprecated").removeClass("status-deprecated");
2024-07-12 22:19:12 -04:00
core.cookie.set("show-deprecated", true, 30, "/");
2024-06-13 00:00:00 -04:00
}
}, 50);
}
$("#deprecated").on("click", flipDeprecated).on("keypress", flipDeprecated);
setTimeout( function() {
2024-07-12 22:19:12 -04:00
if (core.cookie.get("show-deprecated") == "true") {
2024-06-13 00:00:00 -04:00
$("#deprecated").attr("aria-checked", "true");
flipDeprecated();
}
}, 200);
2024-07-12 22:19:12 -04:00
console.log("hide deprecated", { "type": (typeof core.cookie.get("show-deprecated")), "value": core.cookie.get("show-deprecated") });
2024-06-13 00:00:00 -04:00
// /hide deprecated switch
2024-07-11 21:05:34 -04:00
})
2024-07-12 22:19:12 -04:00
// import("../pg/patterns/layouts/main-navigation/_main-navigation.js");