Sha256: 60be48b34815e72ca09aea22b6ebd9a7ac9499957b0bebc402dd852cff607d09

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

import morph from "./utils/morph";

export default function () {
  return {
    clearFilter() {
      this.$store.nav.filter = "";
    },
    init() {
      this.$watch("$store.nav.filter", (value) => {
        const nav = this.$store.nav;
        nav.filterText = value.replace(/\s/g, "").toLowerCase();
        nav.filtering = nav.filterText.length > 0;
      });
    },
    updateNav(event) {
      const nav = document.getElementById("nav");
      nav.style.height = `${this.$refs.shim.offsetHeight}px`;
      morph(nav, event.detail.doc.getElementById("nav"));
      Promise.resolve().then(() => {
        this.$refs.shim.style.height = "auto";
        this.$dispatch("nav:updated");
      });
    },
    navigate($event) {
      history.pushState({}, null, $event.currentTarget.href);
      this.$dispatch("popstate");
    },
    focusFilter() {
      this.currentFocus = this.$refs.filter;
      setTimeout(() => this.$refs.filter.focus(), 0);
    },
    unfocusFilter() {
      this.$refs.filter.blur();
    },
  };
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lookbook-0.3.0.beta.1 app/assets/lookbook/js/nav.js
lookbook-0.3.0.beta.0 app/assets/lookbook/js/nav.js