Sha256: af8c15ce908fb7e9123f4cf31d1840be4a1394b46ebceb247d3be48302d91e73

Contents?: true

Size: 913 Bytes

Versions: 6

Compression:

Stored size: 913 Bytes

Contents

//= require thredded/core/thredded
//= require thredded/core/on_page_load

(() => {
  const Thredded = window.Thredded;

  const COMPONENT_SELECTOR = '[data-thredded-currently-online]';
  const EXPANDED_CLASS = 'thredded--is-expanded';

  const handleMouseEnter = (evt) => {
    evt.target.classList.add(EXPANDED_CLASS);
  };

  const handleMouseLeave = (evt) => {
    evt.target.classList.remove(EXPANDED_CLASS);
  };

  const handleTouchStart = (evt) => {
    evt.target.classList.toggle(EXPANDED_CLASS);
  };

  const initCurrentlyOnline = (node) => {
    node.addEventListener('mouseenter', handleMouseEnter);
    node.addEventListener('mouseleave', handleMouseLeave);
    node.addEventListener('touchstart', handleTouchStart);
  };

  Thredded.onPageLoad(() => {
    Array.prototype.forEach.call(document.querySelectorAll(COMPONENT_SELECTOR), (node) => {
      initCurrentlyOnline(node);
    });
  });
})();

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
thredded-1.1.0 app/assets/javascripts/thredded/components/currently_online.es6
thredded-1.0.1 app/assets/javascripts/thredded/components/currently_online.es6
thredded-1.0.0 app/assets/javascripts/thredded/components/currently_online.es6
thredded-0.16.16 app/assets/javascripts/thredded/components/currently_online.es6
thredded-0.16.15 app/assets/javascripts/thredded/components/currently_online.es6
thredded-0.16.14 app/assets/javascripts/thredded/components/currently_online.es6