Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Re-arrange some furniture in preparation
  • Loading branch information
derrickreimer committed Sep 6, 2018
1 parent 3d76ebe commit 460eee9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
9 changes: 7 additions & 2 deletions assets/js/app.js
Expand Up @@ -19,9 +19,10 @@ import "phoenix_html";
import * as Main from "./modules/main";
import * as Home from "./modules/home";
import * as SvgToElm from "./modules/svg_to_elm";
import "@webcomponents/custom-elements";
import "./rendered_html";
import * as Notifications from "./notifications";
import "./custom_elements/rendered_html";

// Initialize the current page module
const moduleNode = document.head.querySelector("meta[name='module']");

if (moduleNode) {
Expand All @@ -42,10 +43,14 @@ if (moduleNode) {
}
}

// Track scroll position and set a .scrolled-top class
setInterval(() => {
if (window.scrollY < 5) {
document.body.classList.add("scrolled-top");
} else {
document.body.classList.remove("scrolled-top");
}
}, 100);

// Initialize notifications
Notifications.initialize();
@@ -1,3 +1,5 @@
import "@webcomponents/custom-elements";

customElements.define(
"rendered-html",
class RenderedHtml extends HTMLElement {
Expand Down
11 changes: 11 additions & 0 deletions assets/js/notifications.js
@@ -0,0 +1,11 @@
const isSupported = () => {
if (!('serviceWorker' in navigator)) return false;
if (!('PushManager' in window)) return false;
return true;
};

export function initialize() {
if (!isSupported()) return;

// TODO: do the work
};
Empty file added assets/js/service_worker.js
Empty file.

0 comments on commit 460eee9

Please sign in to comment.