mirror of
https://github.com/wassname/template.git
synced 2026-07-14 11:18:56 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0463ff769 | ||
|
|
3bccc25805 |
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "distill-template",
|
"name": "distill-template",
|
||||||
"version": "2.2.9",
|
"version": "2.2.10",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "distill-template",
|
"name": "distill-template",
|
||||||
"version": "2.2.9",
|
"version": "2.2.10",
|
||||||
"description": "Template for creating Distill articles.",
|
"description": "Template for creating Distill articles.",
|
||||||
"main": "dist/template.v2.js",
|
"main": "dist/template.v2.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
+16
-15
@@ -50,8 +50,20 @@ const distillMain = function() {
|
|||||||
console.info('Runlevel 1->2.');
|
console.info('Runlevel 1->2.');
|
||||||
window.distillRunlevel += 1;
|
window.distillRunlevel += 1;
|
||||||
|
|
||||||
/* 3. Register components */
|
/* 3. Register Controller listener functions */
|
||||||
/* Article will register controller which takes control from there */
|
/* Needs to happen before components to their connected callbacks have a controller to talk to. */
|
||||||
|
for (const [functionName, callback] of Object.entries(Controller.listeners)) {
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
document.addEventListener(functionName, callback);
|
||||||
|
} else {
|
||||||
|
console.error('Runlevel 2: Controller listeners need to be functions!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.info('Runlevel 2: We can now listen to controller events.');
|
||||||
|
console.info('Runlevel 2->3.');
|
||||||
|
window.distillRunlevel += 1;
|
||||||
|
|
||||||
|
/* 4. Register components */
|
||||||
const components = [
|
const components = [
|
||||||
Abstract, Appendix, Article, Bibliography, Byline, Cite, CitationList, Code,
|
Abstract, Appendix, Article, Bibliography, Byline, Cite, CitationList, Code,
|
||||||
Footnote, FootnoteList, FrontMatter, HoverBox, Title, DMath, References, TOC, Figure,
|
Footnote, FootnoteList, FrontMatter, HoverBox, Title, DMath, References, TOC, Figure,
|
||||||
@@ -71,21 +83,10 @@ const distillMain = function() {
|
|||||||
customElements.define(component.is, component);
|
customElements.define(component.is, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info('Runlevel 2: Distill Template finished registering custom elements.');
|
console.info('Runlevel 3: Distill Template finished registering custom elements.');
|
||||||
console.info('Runlevel 2->3.');
|
|
||||||
window.distillRunlevel += 1;
|
|
||||||
|
|
||||||
/* 4. Register Controller listener functions */
|
|
||||||
for (const [functionName, callback] of Object.entries(Controller.listeners)) {
|
|
||||||
if (typeof callback === 'function') {
|
|
||||||
document.addEventListener(functionName, callback);
|
|
||||||
} else {
|
|
||||||
console.error('Runlevel 3: Controller listeners need to be functions!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.info('Runlevel 3: We can now listen to controller events.');
|
|
||||||
console.info('Runlevel 3->4.');
|
console.info('Runlevel 3->4.');
|
||||||
window.distillRunlevel += 1;
|
window.distillRunlevel += 1;
|
||||||
|
|
||||||
// If template was added after DOMContentLoaded we may have missed that event.
|
// If template was added after DOMContentLoaded we may have missed that event.
|
||||||
// Controller will check for that case, so trigger the event explicitly:
|
// Controller will check for that case, so trigger the event explicitly:
|
||||||
Controller.listeners.DOMContentLoaded();
|
Controller.listeners.DOMContentLoaded();
|
||||||
|
|||||||
Reference in New Issue
Block a user