A pure javascript class for paginating through any number of DOM elements

Overview

PurePajinate

A pure javascript class for paginating through any number of DOM elements.
Inspired by Pajinate, a plugin for jQuery.

Image

Options

Option Type Description
containerSelector String Default: '.items'.
The items' container selector.
itemSelector String Default: '.item'.
The individual item's selector.
navigationSelector String Default: '.page_navigation'.
The pagination container selector.
itemsPerPage integer Default: 10.
The number of items that will show at once.
pageLinksToDisplay integer Default: 10.
The number of page links to display at once. All other pages will be hidden and replaced with ...
startPage integer Default: 0.
The first page to show. To show page 3, the value will be 2
wrapAround Boolean Default: false.
Determine if the pages should loop or not.
navLabelFirst String Default: 'First'.
The label for the first control.
navLabelPrev String Default: 'Prev'.
The label for the previous control.
navLabelNext String Default: 'Next'.
The label for the next control.
navLabelLast String Default: 'Last'.
The label for the last control.
navAriaLabelFirst String Default: 'First'.
The aria label for the first control.
navAriaLabelPrev String Default: 'Prev'.
The aria label for the previous control.
navAriaLabelNext String Default: 'Next'.
The aria label for the next control.
navAriaLabelLast String Default: 'Last'.
The aria label for the last control.
navOrder Array Default: ["first", "prev", "num", "next", "last"].
The order of the controls. 'num' represents the page links.
showFirstLast Boolean Default: false.
Determine if the first and last controls will show or not.
showPrevNext Boolean Default: true.
Determine if the previous and next controls will show or not.
hideOnSmall Boolean Default: false.
Determine if the pagination shows when the number of items is smaller than the number of items per page.
defaultClass String Default: ''.
A class to apply to all control elements.
activeClass String Default: 'active'.
A class to apply to the active page link.
disabledClass String Default: 'disabled'.
A class to apply to disabled controls.
onInit Function Default: false.
Callback to be run on initialization.
onPageDisplayed Function Default: false.
Callback to be run once a page is displayed.

Usage

Wrap your items (div, a, img, span, li, ...) within a container element (div, ul, ...).

<div class="items">
  <div class="item"> Your Content </div>
  <div class="item"> Your Content </div>
  <div class="item"> Your Content </div>
  <div class="item"> Your Content </div>
  <div class="item"> Your Content </div>
  <div class="item"> Your Content </div>
  <div class="item"> Your Content </div>
</div>
<div class="page_navigation"></div>

Call the class once the DOM is ready.

document.addEventListener('DOMContentLoaded', function() {
  var my_example = new purePajinate({ itemsPerPage: 2 });
});

The CSS class loaded is added to the container once the pagination has finished initializing.

Browser Support

When using the Ecmascript 5 version, supports goes all the way back to Internet Explorer 10. I have used Babel to convert the code into Ecmascript 5 compatible code.

License

GNU General Public License version 3 or later.
See License details

You might also like...

Javascript library for switching fixed elements on scroll through sections. Like Midnight.js, but without jQuery

Library for Switching Fixed Elements on Scroll Sometimes designers create complex logic and fix parts of the interface. Also they colour page sections

Sep 19, 2022

curtains.js is a lightweight vanilla WebGL javascript library that turns HTML DOM elements into interactive textured planes.

curtains.js is a lightweight vanilla WebGL javascript library that turns HTML DOM elements into interactive textured planes.

What is it ? Shaders are the new front-end web developpment big thing, with the ability to create very powerful 3D interactions and animations. A lot

Jan 1, 2023

A Drag-and-Drop library for all JavaScript frameworks implementing an enhanced transformation mechanism to manipulate DOM elements

A Drag-and-Drop library for all JavaScript frameworks implementing an enhanced transformation mechanism to manipulate DOM elements

JavaScript Project to Manipulate DOM Elements DFlex A Drag-and-Drop library for all JavaScript frameworks implementing an enhanced transformation mech

Jan 8, 2023

JavaScript library to resize, reduce, or change ranges of DOM elements.

Range.js JavaScript library to resize, reduce, or change ranges of DOM elements using the HTML5 input type="range" element. Usage: Include range.js

Jun 3, 2021

A super tiny Javascript library to make DOM elements draggable and movable. ~500 bytes and no dependencies.

dragmove.js A super tiny Javascript library to make DOM elements draggable and movable. Has touch screen support. Zero dependencies and 500 bytes Gzip

Dec 29, 2022

🖱 A JavaScript library for interactively picking DOM elements

🖱 A JavaScript library for interactively picking DOM elements

pick-dom-element A JavaScript library (written in TypeScript) for interactively picking DOM elements. Usage Create an instance of the ElementPicker cl

Dec 4, 2022

A pure JavaScript Web Page to retrieve real-time OTP through a web page and generate/scan QR codes.

A pure JavaScript Web Page to retrieve real-time OTP through a web page and generate/scan QR codes.

2FA-Solver A pure JavaScript Web Page to retrieve real-time OTP through a web page and generate/scan QR codes. It can be used as an offline web page b

Dec 7, 2022

Adds `swiped` events to the DOM in 0.7k of pure JavaScript

Adds `swiped` events to the DOM in 0.7k of pure JavaScript

swiped-events A 0.7k script that adds swiped-left, swiped-right, swiped-up and swiped-down events to the DOM using CustomEvent and pure JS. Based on t

Jan 8, 2023

Adds `long-press` event to the DOM in 1k of pure JavaScript

long-press-event A 1k script that adds a long-press event to the DOM using CustomEvent and pure JavaScript. Works in IE9+, Chrome, Firefox, Safari as

Jan 2, 2023
Owner
Olivier Buisard
Olivier Buisard
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Create a deep copy of a set of matched elements with the dynamic state of all form elements copied to the cloned elements.

jq-deepest-copy FUNCTION: Create a deep copy of a set of matched elements while preserving the dynamic state of any matched form elements. Example Use

Michael Coughlin 5 Oct 28, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Multiplies a number by zero. Useful for when you need to multiply a number by zero

multiply-by-zero Multiplies a number by zero. Useful for when you need to multiply a number by zero Please consider checking out the links of this pro

Dheirya Tyagi 2 Jul 3, 2022
jquery-input-mask-phone-number.js - A simple, easy jquery format phone number mask library

jquery-input-mask-phone-number A jQuery Plugin to make masks on input field to US phone format. Quick start 1. Add latest jQuery and jquery-input-mask

Raja Rama Mohan Thavalam 12 Aug 25, 2022
Pure JavaScript library that add .is-hover class instead of css :hover for mobile and desktop.

MultiDeviceHover Pure JavaScript library that add .is-hover class instead of css :hover for mobile and desktop. Usage Install Using npm, install multi

Ryuta Sakai 1 Oct 5, 2021
Kuldeep 2 Jun 21, 2022
A Bootstrap plugin to create input spinner elements for number input

bootstrap-input-spinner A Bootstrap / jQuery plugin to create input spinner elements for number input. Demo page with examples Examples with floating-

Stefan Haack 220 Nov 7, 2022
Prop-Proxy allows you to intercept getters and setters of class attributes through decorators

Prop-Proxy Proxy for class properties Prop-Proxy allows you to intercept getters and setters of class attributes through decorators Installation This

Leonardo Kaynan 6 Dec 15, 2022