Sha256: 4f74a4a8282d104cc6bcdfa9c2f2d4534e174fab81fdcb44682a5bebcbc01472

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

document.addEventListener('DOMContentLoaded', function() {
  // Handle clickable rows
  document.body.addEventListener('mouseup', function(event) {
    const target = event.target.closest('[data-href]');

    if (target) {
      event.preventDefault();
      const href = target.getAttribute('data-href');

      if (event.metaKey || event.ctrlKey || event.button === 1) {
        window.open(href, '_blank', 'noopener, noreferrer');
      } else if (event.button === 0) {
        window.location.href = href;
      }
    }
  });

  // Format dates
  document.querySelectorAll('[data-date]').forEach(function(element) {
    const dateString = element.textContent.trim();
    const date = new Date(dateString);

    if (isNaN(date.getTime())) return;

    const formattedDate = new Intl.DateTimeFormat('en-US', {
      year: undefined,
      month: 'short',
      day: 'numeric',
      hour: '2-digit',
      minute: '2-digit',
      second: '2-digit',
      hour12: false
    }).format(date);

    element.textContent = formattedDate;
    element.setAttribute('title', dateString); // Add original date as title
  });

  // Handle auto-submit elements
  document.querySelectorAll('[data-auto-submit]').forEach(function(element) {
    element.addEventListener('change', function() {
      const form = element.closest('form');
      if (form) form.submit();
    });
  });
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solid_queue_dashboard-0.1.1 app/assets/javascripts/solid_queue_dashboard/application.js
solid_queue_dashboard-0.1.0 app/assets/javascripts/solid_queue_dashboard/application.js