~xdavidwu/xdavidwu.link

ref: 11358a12c763501d74f61e7e798cfbeceb3d7c35 xdavidwu.link/assets/js/_main.js -rw-r--r-- 3.3 KiB
11358a12xdavidwu tweak light footer color 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//window.$ = window.jQuery = require('jquery');
//require('magnific-popup');
//require('./plugins/jquery.fitvids');
require('./_greedy-navigation');
//const Gumshoe = require('gumshoejs');
/* ==========================================================================
   jQuery plugin settings and other scripts
   ========================================================================== */

document.addEventListener('DOMContentLoaded', () => {
  // FitVids init
  //$("#main").fitVids();

  // Close search screen with Esc key
  document.addEventListener('keyup', (e) => {
    if (e.keyCode === 27) {
      if (document.getElementsByClassName("initial-content")[0].classList.contains("is--hidden")) {
        document.getElementsByClassName("search-content")[0].classList.toggle("is--visible");
        document.getElementsByClassName("initial-content")[0].classList.toggle("is--hidden");
      }
    }
  });

  // Search toggle
  document.getElementsByClassName("search__toggle")[0].addEventListener("click", () => {
    document.getElementsByClassName("search-content")[0].classList.toggle("is--visible");
    document.getElementsByClassName("initial-content")[0].classList.toggle("is--hidden");
    // set focus on input
    setTimeout(function() {
      document.querySelector(".search-content input").focus();
    }, 400);
  });

  // Gumshoe scroll spy init
  /*if($("nav.toc").length > 0) {
    var spy = new Gumshoe("nav.toc a", {
      // Active classes
      navClass: "active", // applied to the nav list item
      contentClass: "active", // applied to the content

      // Nested navigation
      nested: false, // if true, add classes to parents of active link
      nestedClass: "active", // applied to the parent items

      // Offset & reflow
      offset: 20, // how far from the top of the page to activate a content area
      reflow: true, // if true, listen for reflows

      // Event support
      events: true // if true, emit custom events
    });
  }*/

  // add lightbox class to all image links
  /*$(
    "a[href$='.jpg'],a[href$='.jpeg'],a[href$='.JPG'],a[href$='.png'],a[href$='.gif']"
  ).addClass("image-popup");

  // Magnific-Popup options
  $(".image-popup").magnificPopup({
    // disableOn: function() {
    //   if( $(window).width() < 500 ) {
    //     return false;
    //   }
    //   return true;
    // },
    type: "image",
    tLoading: "Loading image #%curr%...",
    gallery: {
      enabled: true,
      navigateByImgClick: true,
      preload: [0, 1] // Will preload 0 - before current, and 1 after the current image
    },
    image: {
      tError: '<a href="%url%">Image #%curr%</a> could not be loaded.'
    },
    removalDelay: 500, // Delay in milliseconds before popup is removed
    // Class that is added to body when popup is open.
    // make it unique to apply your CSS animations just to this exact popup
    mainClass: "mfp-zoom-in",
    callbacks: {
      beforeOpen: function() {
        // just a hack that adds mfp-anim class to markup
        this.st.image.markup = this.st.image.markup.replace(
          "mfp-figure",
          "mfp-figure mfp-with-anim"
        );
      }
    },
    closeOnContentClick: true,
    midClick: true // allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source.
  })*/;
});