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

s-pagination

v3.0.1

Published

A JavaScript library for pagination using Bootstrap components.

Downloads

58

Readme

S-Pagination

A JavaScript library for creating pagination. The main goal of this library is simple usage, so for initialization is required only specify page size, number of items and place for S-Pagination rendering (other parameters are optional). Page selected by user can be obtained by setting up callback or by redirection to specified URL. The library using Bootstrap components for pagination. This library also contains definition files (.d.ts) for TypeScript.

Demo

S-Pagination usage sample

Usage

The simplest usage is following:

var pagination = new PaginationNs({
    container: document.getElementById("pagination-1") as HTMLDivElement,
    pageClickCallback: function (pageNumber) {
    }
});
pagination.make(itemsCount, itemsOnPage);

The constructor initialize component with options but not render anything. The component is rendered after make() method call. This method can be called repeatedly for the component is rerendering.

Importing in TypeScript

The library can be imported simply using the following statement:

import Pagination from "s-pagination";

Configuration

The library is configured by object passed in the constructor:

  • container - The place in the DOM, where to render this component. The parameter type is HTMLDivElement. This parameter is required.
  • pageClickCallback - The callback function which is called when user change page by this component. The callback function contains one parameter with page number. Page numbers are equal to labels (first page has number 1).
  • pageClickUrl - The URL to which is browser redirected after user change page by this component. If type of specified parameter is string, substring "{{page}}" is replaced by appropriate page number. If type of specified parameter is function, page number is passed as parameter and return type is string.
  • callPageClickCallbackOnInit - If true, pageClickCallback is called immediately after component render (after make method call). Defaults to false.
  • maxVisibleElements - The number of visible buttons in pagination panel (including arrows on the edges and shorting dots). Default value is 13.
  • showInput - If true, show text input box for direct navigation to specified page. Defaults to false.
  • inputTitle - The content of tooltip displayed on text input box.
  • enhancedMode - If false, standard mode is used (show arrows on the edges, border page numbers, shorting dots and page numbers around current page). If true, standard mode is enhanced, so page number between border number and middle area is also displayed. Defaults to false.

Methods

  • constructor(options) - The constructor accepts exactly one object parameter containing configuration.
  • make(itemsCount, itemsOnPage, defaultPageNumber) - Render the component for specified items count and page size. DefaultPageNumber parameter is optional and sets active page.
  • goToPage(pageNumber) - Force "Go to page" action. Component is rerendered to specified page and actions (pageClickCallback, pageClickUrl) are invoked.
  • getPageCount() - Returns current page count.
  • getCurrentPage() - Returns current page number.

Changes

Added support for Bootstrap v5.x