Sha256: c19f10b818e8cc4882c9e5866687e46b8e3f18be0ec9d6523c0b57744e7e5b8f

Contents?: true

Size: 1.06 KB

Versions: 13

Compression:

Stored size: 1.06 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(path) {
      if (path instanceof Event) {
        path = path.currentTarget.href;
      }
      history.pushState({}, null, path);
      this.$dispatch("popstate");
    },
    focusFilter() {
      this.currentFocus = this.$refs.filter;
      setTimeout(() => this.$refs.filter.focus(), 0);
    },
    unfocusFilter() {
      this.$refs.filter.blur();
    },
  };
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
lookbook-0.4.4 app/assets/lookbook/js/nav.js
lookbook-0.4.3 app/assets/lookbook/js/nav.js
lookbook-0.4.2 app/assets/lookbook/js/nav.js
lookbook-0.4.1 app/assets/lookbook/js/nav.js
lookbook-0.3.5 app/assets/lookbook/js/nav.js
lookbook-0.4.0.beta.2 app/assets/lookbook/js/nav.js
lookbook-0.4.0.beta.1 app/assets/lookbook/js/nav.js
lookbook-0.3.4 app/assets/lookbook/js/nav.js
lookbook-0.3.3 app/assets/lookbook/js/nav.js
lookbook-0.3.2 app/assets/lookbook/js/nav.js
lookbook-0.3.1 app/assets/lookbook/js/nav.js
lookbook-0.3.0 app/assets/lookbook/js/nav.js
lookbook-0.3.0.beta.2 app/assets/lookbook/js/nav.js