Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

timbles

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timbles - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

.npmignore

2

package.json
{
"name": "timbles",
"version": "1.0.4",
"version": "1.0.5",
"description": "an p chill jQuery table plugin, made by someone who literally did not invent tables",

@@ -5,0 +5,0 @@ "main": "timbles",

/**
* timbles.js
* definitely the most lightweight jquery table plugin ever
* like, all you can do is generate a table and allow sorting lol that's it
* except probably not
*
* @version 1.0.5
* @author jenn schiffer http://jennmoney.biz

@@ -76,3 +78,5 @@ */

var headerId = $(this).attr('id');
data.$records.find('td:nth-child(' + (i + 1) + ')').addClass(headerId);
data.$records.each(function(j){
$(this).find('td').eq(i).addClass(headerId);
});
});

@@ -295,6 +299,9 @@

// create footer to hold tools
data.$footerRow = $this.find('tfoot');
// set current page
data.pagination.currentPage = 1;
if ( data.$footerRow.length === 0 ) {
// create footer to hold tools
data.$footerRow = $this.find('tfoot');
if ( data.$footerRow.length === 0 ) {
var $footer = $('<tfoot>');

@@ -304,8 +311,12 @@ data.$footerRow = $footer;

// create tools if they don't exist already
if ( !data.$paginationToolsContainer ) {
// create tools if they don't exist already
if ( !data.$paginationToolsContainer ) {
methods.generatePaginationTools.call($this);
}
}
else {
// update existing pagination tools
methods.updatePaginationTools.call($this);
}
// save it all
// save it all
$this.data(pluginName, data);

@@ -320,6 +331,6 @@ },

data.$paginationToolsContainer = $('<div class="' + classes.paginationTools + '">');
data.$linkFirstPage = $('<a href="#">' + copy.firstPage + '</a>');
data.$linkPrevPage = $('<a href="#">' + copy.prevPage + '</a>');
data.$linkNextPage = $('<a href="#">' + copy.nextPage + '</a>');
data.$linkLastPage = $('<a href="#">' + copy.lastPage + '</a>');
data.$linkFirstPage = $('<button role="button">' + copy.firstPage + '</button>');
data.$linkPrevPage = $('<button role="button">' + copy.prevPage + '</a>');
data.$linkNextPage = $('<button role="button">' + copy.nextPage + '</a>');
data.$linkLastPage = $('<button role="button">' + copy.lastPage + '</a>');

@@ -338,7 +349,15 @@ data.$paginationToolsContainer

data.$linkPrevPage.click(function(){
methods.goToPage.call($this, data.pagination.currentPage - 1);
var newPage = data.pagination.currentPage - 1;
if ( newPage >= 1 ) {
methods.goToPage.call($this, newPage);
}
});
data.$linkNextPage.click(function(){
methods.goToPage.call($this, data.pagination.currentPage + 1);
var newPage = data.pagination.currentPage + 1;
if ( newPage <= Math.ceil(data.$records.length / data.pagination.recordsPerPage) ) {
methods.goToPage.call($this, newPage);
}
});

@@ -354,4 +373,36 @@

$this.data(pluginName, data);
// update tools
methods.updatePaginationTools.call($this);
},
updatePaginationTools : function() {
var $this = $(this);
var data = $this.data(pluginName);
if (!data) { return; }
var min = 1;
var max = Math.ceil(data.$records.length / data.pagination.recordsPerPage);
// set buttons inactive if appropriate
if ( data.pagination.currentPage === min ) {
data.$linkFirstPage.attr('disabled', true);
data.$linkPrevPage.attr('disabled', true);
}
else {
data.$linkFirstPage.attr('disabled', false);
data.$linkPrevPage.attr('disabled', false);
}
if ( data.pagination.currentPage === max ) {
data.$linkLastPage.attr('disabled', true);
data.$linkNextPage.attr('disabled', true);
}
else {
data.$linkLastPage.attr('disabled', false);
data.$linkNextPage.attr('disabled', false);
}
},
goToPage : function(page) {

@@ -362,31 +413,34 @@ var $this = $(this);

// check for valid page number
var pageCount = Math.ceil(data.$records.length / data.pagination.recordsPerPage);
if ( page < 1 || page > pageCount ) {
return;
}
// check for valid page number
var pageCount = Math.ceil(data.$records.length / data.pagination.recordsPerPage);
if ( page < 1 || page > pageCount ) {
return;
}
// move to next page
data.pagination.currentPage = page;
data.pagination.currentPage = page;
$this.find('tr').not('.'+classes.headerRow).remove();
$this.find('tr').not('.'+classes.headerRow).remove();
var paginatedRecordsArray = [];
var paginatedRecordsArray = [];
var newFirstRowNum = (page - 1) * (data.pagination.recordsPerPage) + 1,
newLastRowNum = page * data.pagination.recordsPerPage;
if ( newLastRowNum > data.$records.length ) {
newLastRowNum = data.$records.length;
}
if ( newLastRowNum > data.$records.length ) {
newLastRowNum = data.$records.length;
}
// get new page's records
for ( var i = newFirstRowNum - 1; i < newLastRowNum; i++ ) {
if ( data.$records[i] ) {
paginatedRecordsArray.push(data.$records[i]);
}
}
// get new page's records
for ( var i = newFirstRowNum - 1; i < newLastRowNum; i++ ) {
if ( data.$records[i] ) {
paginatedRecordsArray.push(data.$records[i]);
}
}
// add rows to table
data.$headerRow.after(paginatedRecordsArray);
// add rows to table
data.$headerRow.after(paginatedRecordsArray);
// update pagination tools
methods.updatePaginationTools.call($this);
// update data

@@ -393,0 +447,0 @@ $this.data(pluginName, data);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc