Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "timbles", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "a very simple jQuery plugin for tables, made by the person who literally did not invent tables", | ||
@@ -22,3 +22,4 @@ "main": "timbles", | ||
"jqueries", | ||
"seo" | ||
"seo", | ||
"jquery-plugin" | ||
], | ||
@@ -25,0 +26,0 @@ "author": "Jenn Schiffer <jenn@dotbiz.info> (http://jennmoney.biz)", |
@@ -140,3 +140,2 @@ timbles.js | ||
data: 'data.json', // the json file if dataType is 'json', an array if dataType is 'array' | ||
sorting: true, // if you want columns to be sortable | ||
columns: [ | ||
@@ -152,3 +151,4 @@ | ||
* if you have the non-column property sorting set to true | ||
* | ||
* - dataFilter (function), this function will be applied to the cell value, | ||
* useful for when you want to add currency symbols, html, etc | ||
*/ | ||
@@ -161,4 +161,6 @@ | ||
{ label: 'Notes', id: 'notes', noSorting: true } | ||
{ label: 'Price', id: 'price', dataFilter: function(value) { return '$' + value; } } | ||
] | ||
}, | ||
} | ||
sorting: true, // if you want columns to be sortable | ||
@@ -228,4 +230,4 @@ });</code></pre> | ||
This was made within a few days for jqCon Chicago on 9/12/2014 and therefore is incomplete and not well documented. This is what I get for having to launch something whenever I give a talk. I'll refine this and add more features while retaining the philosophy of staying simple. | ||
This was made within a few days for jqCon Chicago on 9/12/2014 and therefore is incomplete and not documented as well as I'd like. This is what I get for having to launch something whenever I give a talk. I'll refine this and add more features while retaining the philosophy of staying simple. | ||
**MOST IMPORTANTLY: HAVE FUN.** |
@@ -114,3 +114,3 @@ /** | ||
// no need for ajax call if data is local array | ||
methods.generateRowsFromData.call($this, data.dataConfig.data, $this) | ||
methods.generateRowsFromData.call($this, data.dataConfig.data, data.dataConfig.columns, $this) | ||
} | ||
@@ -120,3 +120,2 @@ else { | ||
$.getJSON( data.dataConfig.data, function(data) { | ||
console.log('ok'); | ||
methods.generateRowsFromData.call($this, data, $this) | ||
@@ -128,7 +127,12 @@ }); | ||
generateRowsFromData : function(data, thisTable) { | ||
$.each(data, function(index, file){ | ||
generateRowsFromData : function(data, columnConfig,thisTable) { | ||
$.each(data, function(index, row){ | ||
var $currentRow = $('<tr>'); | ||
$.each(file, function(property, value){ | ||
$currentRow.append('<td class="' + property + '">' + value + '</td>'); | ||
$.each(columnConfig, function(property, value){ | ||
// if there is a dataFilter function given, apply it to the value to display | ||
var displayValue = ( value.dataFilter ) ? value.dataFilter(row[value.id]) : row[value.id]; | ||
// append new cell to the row | ||
$currentRow.append('<td class="' + value.id + '" data-value="' + row[value.id] + '">' + displayValue + '</td>'); | ||
}); | ||
@@ -176,4 +180,4 @@ thisTable.append($currentRow); | ||
$sortedRecords = $recordsToSort.sort( function(a, b) { | ||
alpha = $(a).find('td.' + key).text().toLowerCase(); | ||
beta = $(b).find('td.' + key).text().toLowerCase(); | ||
alpha = $(a).find('td.' + key).data('value'); | ||
beta = $(b).find('td.' + key).data('value'); | ||
if ( alpha < beta ) { | ||
@@ -195,4 +199,4 @@ return -1; | ||
$sortedRecords = $recordsToSort.sort( function(a, b) { | ||
alpha = $(a).find('td.' + key).text().toLowerCase(); | ||
beta = $(b).find('td.' + key).text().toLowerCase(); | ||
alpha = $(a).find('td.' + key).data('value'); | ||
beta = $(b).find('td.' + key).data('value'); | ||
if ( beta < alpha ) { | ||
@@ -199,0 +203,0 @@ return -1; |
Sorry, the diff of this file is not supported yet
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
181361
14
2884
229