npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

table-link

v1.3.0

Published

A simple way to add links on your tableish elements like tr, th and td.

Downloads

51

Readme

Table Link

Build Status Coverage Status Made with vim

The easiest way to add links in your table rows, cells or elements that are not anchors!

Yeah man... Html can't do that for you out of the box. And it's sad. Very sad.

I KNOW THAT FEEL BRO...

Don't worry bro here is the solution:

Instalation

With npm:

npm install --save table-link

With bower:

bower install --save table-link

Or you can just download a ZIP.

Setup

Browserify
var TableLink = require('table-link');
Browser (Global)
<script src="table-link.min.js"></script>
Some CSS (Optional)
[data-href] {
  cursor: pointer;
}

table [data-href]:hover,
table [data-href]:hover > * {
  background-color: #AAB7D1; // Put whatever color you want... Or none.
}

Usage

In your table:

<tr data-href="http://google.com">
    <td>Some random crazy data.</td>
</tr>

In your Javascript file:

TableLink.init();
// Soooooo simple...

You can make use of blank and self (default) for targeting the link:

<tr data-href="http://google.com" data-target="self">
    <td>Some random crazy data.</td>
</tr>
<tr data-href="http://google.com" data-target="blank">
    <td>Some random crazy data.</td>
</tr>

Using in other elements

Put the selector to find those as the first TableLink.init() parameter like this:
TableLink.init('h1, div, span');
<h1 data-href="http://google.com"></h1>

<div data-href="http://google.com"></div>

<span data-href="http://google.com"></span>

Before and After events

The 'before' event can cancel the link opening by returning false.

The "element" argument is the delegate target, which can be td, tr, th or any element that matches the selector, if it was passed. The "target" argument is the real event target. The sencond can be used to see if the clicked element is the delegated element or some other element inside the delegated element.

TableLink.before(function(element, target) {
    return confirm('Can i open this link?');
});
TableLink.before(function(element, target) {
  // Cancel the action if the clicked element (maybe a cell inside a row[data-href])
  // has the ```.no-link``` class.
  return !target.classList.contains('no-link');
});
TableLink.after(function(element, target) {
    console.log('The link was opened!');
});

License

This repository is under the MIT License