Sha256: ccc8bf9fc3ccd3418625f11e8a9c5eb17c04231702a684e2c8bff6b4030c4e91

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

const loadEvent = () => {
  try {
    if (Turbolinks) return 'turbolinks:load'
  } catch {
    return 'DOMContentLoaded'
  }
}

document.addEventListener(loadEvent(), () => {
  document.querySelectorAll('.print').forEach(print => {
    print.addEventListener('click', e => {
      event.preventDefault();
      event.stopPropagation();
      window.print();
    });
  });

  document.querySelectorAll('.share').forEach(share => {
    share.addEventListener('click', event => {
      if (!Navigator.share) return;

      event.preventDefault();
      event.stopPropagation();

      const title = document.querySelector('title').text;

      try {
        const text = document.querySelector('meta[property="og:description"]').content;
      } catch {
        const text = '';
      }

      try {
        const url = document.querySelector('link[rel=canonical]').href;
      } catch {
        const url = document.location.href;
      }

      const data = { title: title, text: text, url: url };

      if (Navigator.canShare(data)) Navigator.share(data).then();
    });
  });

  document.querySelectorAll("a[href^='http://'],a[href^='https://'],a[href^='//']").forEach(a => {
    a.rel = "noopener";
    a.target = "_blank";
  });
});

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
adhesiones-jekyll-theme-0.4.1 assets/js/script.js
adhesiones-jekyll-theme-0.4.0 assets/js/script.js
adhesiones-jekyll-theme-0.3.2 assets/js/script.js
adhesiones-jekyll-theme-0.3.1 assets/js/script.js
adhesiones-jekyll-theme-0.3.0 assets/js/script.js
adhesiones-jekyll-theme-0.2.6 assets/js/script.js
adhesiones-jekyll-theme-0.2.5 assets/js/script.js
adhesiones-jekyll-theme-0.2.4 assets/js/script.js
adhesiones-jekyll-theme-0.2.3 assets/js/script.js
adhesiones-jekyll-theme-0.2.2 assets/js/script.js