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

restables

v1.0.0

Published

The jQuery plugin for responsive tables.

Downloads

29

Readme

resTables - jQuery plugin for responsive tables

The resTables jQuery plugin allows you to easily make your table responsive. It has been created based on the stacktable.js concept by John Polacek.

View demo at http://codefog.github.io/restables/

Installation

You can download the plugin regular way or use the npm to install it:

npm install restables --save 

Usage

The initialization of the plugin is simple:

$(document).ready(function () {
    $('table').resTables();
});

Make sure to add the necessary CSS classes to display and hide both tables under certain window sizes:

table.restables-clone {
    display: none;
}

@media (max-width: 991px) {
    table.restables-origin {
        display: none;
    }
    
    table.restables-clone {
        display: table;
    }
}

How it works

When the script is initialized it will create a sibling table but with 2-column layout only. Consider the following table structure:

<table>
    <thead>
        <tr>
            <th>Header 1</th>
            <th>Header 2</th>
            <th>Header 3</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Value A1</td>
            <td>Value A2</td>
            <td>Value A3</td>
        </tr>
        <tr>
            <td>Value B1</td>
            <td>Value B2</td>
            <td>Value B3</td>
        </tr>
    </tbody>
</table>

Based on the above the plugin will create a new table with this structure:

<table>
    <tbody>
        <tr>
            <td>Header 1</td>
            <td>Value A1</td>
        </tr>
        <tr>
            <td>Header 2</td>
            <td>Value A2</td>
        </tr>
        <tr>
            <td>Header 3</td>
            <td>Value A3</td>
        </tr>
    </tbody>
    <tbody>
        <tr>
            <td>Header 1</td>
            <td>Value B1</td>
        </tr>
        <tr>
            <td>Header 2</td>
            <td>Value B2</td>
        </tr>
        <tr>
            <td>Header 3</td>
            <td>Value B3</td>
        </tr>
    </tbody>
</table>

Options

merge

Default value: {}

An object containing columns that will be merged with other columns. In the below example columns with indexes $2 and $3 will be merged with column $1 and column $6 will be merged with column $5.

// Example
$('#my-table').resTables({
    merge: {
        1: [2, 3], 
        5: [6]
    }
});

move

Default value: {}

An object containing columns that will be moved. In the below example column with index $1 will be placed at the top of the new table (index $0) and column $6 as the second row with index $1.

// Example
$('#my-table').resTables({
    move: {
        1: 0,
        6: 1
    }
});

skip

Default value: []

An array of columns that should be skipped in the cloned table. In the below example columns with indexes $3 and $5 will not be present in the new table.

// Example
$('#my-table').resTables({
    skip: [3, 5]
});

span

Default value: []

An array of columns that should be spanned - the colspan="2" attribute will be added. In the below example columns with indexes $2 and $4 will have the colspan="2" attribute added and will appear as one cell.

// Example
$('#my-table').resTables({
    span: [2, 4]
});

cssClassOrigin

Default value: restables-origin

The CSS class that will be added to origin table.

// Example
$('#my-table').resTables({
    cssClassOrigin: 'my-origin-table'
});

cssClassClone

Default value: restables-clone

The CSS class that will be added to cloned table.

// Example
$('#my-table').resTables({
    cssClassClone: 'my-cloned-table'
});

uniqueAttributes

Default value: ['id', 'for']

The list of attributes that should remain unique. Each cloned element containing those attributes will have them updated by adding the suffix (see attributeSuffix below).

// Example
$('#my-table').resTables({
    uniqueAttributes: ['id', 'for', 'data-my-id']
});

attributeSuffix

Default value: '-restables-clone'

The suffix that will be added to the unique attributes in the cloned elements.

// Example
$('#my-table').resTables({
    attributeSuffix: '-my-suffix'
});

cloneCallback

Default value: null

The callback that is triggered just before the cloned table is inserted into DOM.

// Example
$('#my-table').resTables({
    cloneCallback: function (clone) {
        clone.find('.checkbox').addClass('checkbox-mobile');
    }
});