Comparing version 1.0.7 to 1.0.8
{ | ||
"name": "timbles", | ||
"version": "1.0.7", | ||
"description": "an p chill jQuery table plugin, made by someone who literally did not invent tables", | ||
"version": "1.0.8", | ||
"description": "a p chill jQuery table plugin, made by someone who literally did not invent tables", | ||
"main": "timbles", | ||
@@ -6,0 +6,0 @@ "directories": { |
@@ -247,2 +247,14 @@ timbles.js | ||
## Changelog | ||
* 1.0.8 adds page number tracker to pagination tools | ||
* 1.0.7 bug fix | ||
* 1.0.6 adds pagination tools | ||
* 1.0.5 bug fix | ||
* 1.0.4 bug fix | ||
* 1.0.3 adds data-filter property to columns, sort by data-value if exists | ||
* 1.0.2 bug fix | ||
* 1.0.1 bug fix | ||
* 1.0.0 a baby is born | ||
## Note | ||
@@ -249,0 +261,0 @@ |
136
timbles.js
@@ -6,3 +6,3 @@ /** | ||
* | ||
* @version 1.0.7 | ||
* @version 1.0.8 | ||
* @author jenn schiffer http://jennmoney.biz | ||
@@ -36,6 +36,8 @@ */ | ||
var copy = { | ||
firstPage : ' << ', | ||
prevPage : ' < ', | ||
nextPage : ' > ', | ||
lastPage : ' >> ' | ||
firstPageArrow : ' << ', | ||
prevPageArrow : ' < ', | ||
nextPageArrow : ' > ', | ||
lastPageArrow : ' >> ', | ||
page : 'page', | ||
of : 'of' | ||
}; | ||
@@ -216,3 +218,3 @@ | ||
var $sortedRecords; | ||
if (order === 'asc') { | ||
@@ -264,3 +266,3 @@ $sortHeader.addClass(classes.sortASC); | ||
} | ||
// remove current unsorted records | ||
@@ -273,3 +275,3 @@ if ( $recordsToSort ) { | ||
$this.append($sortedRecords); | ||
// if table was paginated, reenable | ||
@@ -285,24 +287,24 @@ if ( data.pagination ) { | ||
var $this = $(this); | ||
var data = $this.data(pluginName); | ||
// don't paginate if there are no records | ||
if (!data || !data.$records || data.$records.length === 0 ) { return; } | ||
var data = $this.data(pluginName); | ||
// don't paginate if there are no records | ||
if (!data || !data.$records || data.$records.length === 0 ) { return; } | ||
data.pagination.recordsPerPage = count; | ||
var $recordsToPaginate = data.$records; | ||
var paginatedRecordsArray = []; | ||
for ( var i = 0; i < count; i++ ) { | ||
if ( data.$records[i] ) { | ||
paginatedRecordsArray.push(data.$records[i]); | ||
} | ||
} | ||
var $recordsToPaginate = data.$records; | ||
var paginatedRecordsArray = []; | ||
// remove records if they exist | ||
if ( $recordsToPaginate ) { | ||
$recordsToPaginate.remove(); | ||
} | ||
for ( var i = 0; i < count; i++ ) { | ||
if ( data.$records[i] ) { | ||
paginatedRecordsArray.push(data.$records[i]); | ||
} | ||
} | ||
// show first page | ||
$this.append(paginatedRecordsArray); | ||
// remove records if they exist | ||
if ( $recordsToPaginate ) { | ||
$recordsToPaginate.remove(); | ||
} | ||
// show first page | ||
$this.append(paginatedRecordsArray); | ||
// set current page | ||
@@ -336,10 +338,10 @@ data.pagination.currentPage = 1; | ||
if (!data) { return; } | ||
// create pagination container and place after table | ||
data.$paginationToolsContainer = $('<div class="' + classes.paginationToolsContainer + '">'); | ||
$this.after(data.$paginationToolsContainer); | ||
// save it all | ||
$this.data(pluginName, data); | ||
if ( !data.pagination.nav ) { | ||
@@ -357,7 +359,7 @@ // by default, just show arrow nav | ||
break; | ||
// row count choice | ||
// row count choice | ||
case "rowCountChoice": | ||
methods.generatePaginationNavRowCountChoice.call($this); | ||
break; | ||
}; | ||
} | ||
} | ||
@@ -369,3 +371,3 @@ } | ||
}, | ||
generatePaginationNavArrows : function() { | ||
@@ -375,8 +377,12 @@ var $this = $(this); | ||
if (!data) { return; } | ||
var thisPage = 1; | ||
var lastPage = Math.ceil(data.$records.length / data.pagination.recordsPerPage); | ||
data.$paginationNavArrows = $('<div class="' + classes.paginationNavArrows + '">'); | ||
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>'); | ||
data.$linkFirstPage = $('<button role="button">' + copy.firstPageArrow + '</button>'); | ||
data.$linkPrevPage = $('<button role="button">' + copy.prevPageArrow + '</a>'); | ||
data.$linkNextPage = $('<button role="button">' + copy.nextPageArrow + '</a>'); | ||
data.$linkLastPage = $('<button role="button">' + copy.lastPageArrow + '</a>'); | ||
data.$pageNumberTracker = $('<span class="page-number-tracker">' + copy.page + ' <span class="pointer-this-page">' + thisPage + '</span> ' + copy.of + ' <span class="pointer-last-page">' + lastPage + '</span></span>'); | ||
@@ -386,2 +392,3 @@ data.$paginationNavArrows | ||
.append(data.$linkPrevPage) | ||
.append(data.$pageNumberTracker) | ||
.append(data.$linkNextPage) | ||
@@ -416,3 +423,7 @@ .append(data.$linkLastPage); | ||
data.$paginationToolsContainer.append(data.$paginationNavArrows); | ||
data.$pointerThisPage = data.$paginationToolsContainer.find('.pointer-this-page'); | ||
data.$pointerLastPage = data.$paginationToolsContainer.find('.pointer-last-page'); | ||
console.log(data.$pointerThisPage, data.$pointerLastPage); | ||
// save it all | ||
@@ -422,3 +433,3 @@ $this.data(pluginName, data); | ||
}, | ||
generatePaginationNavRowCountChoice : function() { | ||
@@ -428,29 +439,29 @@ var $this = $(this); | ||
if (!data) { return; } | ||
var optionCount = data.pagination.nav.rowCountChoice.length; | ||
var arrayOfChoices = []; | ||
var arrayOfChoices = []; | ||
for ( var i = 0; i < optionCount; i++ ) { | ||
arrayOfChoices.push('<button role="button">' + data.pagination.nav.rowCountChoice[i] + '</button>'); | ||
} | ||
for ( var i = 0; i < optionCount; i++ ) { | ||
arrayOfChoices.push('<button role="button">' + data.pagination.nav.rowCountChoice[i] + '</button>'); | ||
} | ||
data.$paginationNavRowCountChoice = $('<div>').attr('class', classes.paginationNavRowCountChoice).append(arrayOfChoices); | ||
// event listeners | ||
data.$paginationNavRowCountChoice.find('button').click(function(){ | ||
data.$paginationNavRowCountChoice.find('button').removeClass(classes.active); | ||
$(this).addClass(classes.active); | ||
var newRowCount = $(this).text(); | ||
if ( newRowCount.toLowerCase() == 'all' ) { | ||
newRowCount = data.$records.length; | ||
} | ||
methods.enablePagination.call($this, newRowCount); | ||
}); | ||
data.$paginationNavRowCountChoice = $('<div>').attr('class', classes.paginationNavRowCountChoice).append(arrayOfChoices); | ||
// event listeners | ||
data.$paginationNavRowCountChoice.find('button').click(function(){ | ||
data.$paginationNavRowCountChoice.find('button').removeClass(classes.active); | ||
$(this).addClass(classes.active); | ||
var newRowCount = $(this).text(); | ||
if ( newRowCount.toLowerCase() == 'all' ) { | ||
newRowCount = data.$records.length; | ||
} | ||
methods.enablePagination.call($this, newRowCount); | ||
}); | ||
data.$paginationToolsContainer.append(data.$paginationNavRowCountChoice); | ||
// save it all | ||
$this.data(pluginName, data); | ||
$this.data(pluginName, data); | ||
}, | ||
@@ -485,2 +496,5 @@ | ||
// update page number tracker | ||
data.$pointerThisPage.text(data.pagination.currentPage); | ||
data.$pointerLastPage.text(max); | ||
}, | ||
@@ -522,7 +536,7 @@ | ||
// update pagination tools | ||
// update pagination tools | ||
methods.updatePaginationTools.call($this); | ||
// update data | ||
$this.data(pluginName, data); | ||
// update data | ||
$this.data(pluginName, data); | ||
}, | ||
@@ -529,0 +543,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
204070
3198
264