Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "timbles", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "a p chill jQuery table plugin, made by someone who literally did not invent tables", | ||
@@ -5,0 +5,0 @@ "main": "timbles", |
127
readme.md
@@ -10,4 +10,6 @@ timbles.js | ||
<pre><code><script src="jquery.js"></script> | ||
<script src="timbles.js"></script></code></pre> | ||
```html | ||
<script src="jquery.js"></script> | ||
<script src="timbles.js"></script> | ||
``` | ||
@@ -57,34 +59,36 @@ ## Configure *timbles* | ||
<pre><code><table border="1"> | ||
<thead> | ||
<tr> | ||
<th id="name">Name</th> | ||
<th id="size">Size</th> | ||
<th id="kind">Kind</th> | ||
<th id="date-added">Date Added</th> | ||
<th id="notes" class="no-sort">Notes</th> | ||
</tr> | ||
</thead> | ||
<tr> | ||
<td>dhtmlconf.png</td> | ||
<td>77 KB</td> | ||
<td>PNG Image</td> | ||
<td>August 31, 2014, 11:16 PM</td> | ||
<td>dhtmlconf logo</td> | ||
</tr> | ||
<tr> | ||
<td>icla.pdf</td> | ||
<td>26 KB</td> | ||
<td>Adobe PDF document</td> | ||
<td>August 27, 2014, 12:51 PM</td> | ||
<td>Individual Contributor License Agreement</td> | ||
</tr> | ||
<tr> | ||
<td>Slime Girls - Vacation Wasteland EP.zip</td> | ||
<td>72.9 MB</td> | ||
<td>ZIP archive</td> | ||
<td>August 25, 2014, 9:40 PM</td> | ||
<td>cool chiptunes from lwlvl</td> | ||
</tr> | ||
</table></code></pre> | ||
```html | ||
<table border="1"> | ||
<thead> | ||
<tr> | ||
<th id="name">Name</th> | ||
<th id="size">Size</th> | ||
<th id="kind">Kind</th> | ||
<th id="date-added">Date Added</th> | ||
<th id="notes" class="no-sort">Notes</th> | ||
</tr> | ||
</thead> | ||
<tr> | ||
<td>dhtmlconf.png</td> | ||
<td>77 KB</td> | ||
<td>PNG Image</td> | ||
<td>August 31, 2014, 11:16 PM</td> | ||
<td>dhtmlconf logo</td> | ||
</tr> | ||
<tr> | ||
<td>icla.pdf</td> | ||
<td>26 KB</td> | ||
<td>Adobe PDF document</td> | ||
<td>August 27, 2014, 12:51 PM</td> | ||
<td>Individual Contributor License Agreement</td> | ||
</tr> | ||
<tr> | ||
<td>Slime Girls - Vacation Wasteland EP.zip</td> | ||
<td>72.9 MB</td> | ||
<td>ZIP archive</td> | ||
<td>August 25, 2014, 9:40 PM</td> | ||
<td>cool chiptunes from lwlvl</td> | ||
</tr> | ||
</table>< | ||
``` | ||
@@ -103,3 +107,4 @@ You don't need to generate a new table with JSON because your table is there already. And you just want to be able to make it sortable. Then just call this after you enqueued *timbles.js* as per the above install directions: | ||
<pre><code>// get your table | ||
```js | ||
// get your table | ||
var $table = $('table'); | ||
@@ -113,5 +118,6 @@ | ||
} | ||
});</code></pre> | ||
}); | ||
``` | ||
If you don't want all of the columns to be sortable, add the class `no-sort` to the <th> element of the column you do not want to be sortable. | ||
If you don't want all of the columns to be sortable, add the class `no-sort` to the <th> element of the column you do not want to be sortable. | ||
@@ -122,5 +128,8 @@ ### Generating a table from a JSON file or an array of row objects | ||
<pre><code><table id="example"></table></code></pre> | ||
```html | ||
<table id="example"></table> | ||
``` | ||
<pre><code>// get your table | ||
```js | ||
// get your table | ||
var $table = $('#example'); | ||
@@ -149,3 +158,3 @@ | ||
* you have to set the column headers with the following required properties: | ||
* - label (string), the text between <th> and </th> | ||
* - label (string), the text between <th> and </th> | ||
* - id (string), the json object property attributed to the column | ||
@@ -170,7 +179,9 @@ * | ||
});</code></pre> | ||
}); | ||
``` | ||
Here is an example of an array of row objects: | ||
<pre><code>var localData = [ | ||
```js | ||
var localData = [ | ||
{ | ||
@@ -189,3 +200,4 @@ name: "dhtmlconf.png", | ||
notes: "Individual Contributor License Agreement" | ||
},{ | ||
}, | ||
{ | ||
name: "Slime Girls - Vacation Wasteland EP.zip", | ||
@@ -196,3 +208,4 @@ size: "72.9 MB", | ||
notes: "cool chiptunes from lwlvl" | ||
},{ | ||
}, | ||
{ | ||
name: ".DS_Store", | ||
@@ -203,3 +216,4 @@ size: "25 KB", | ||
notes: "lol" | ||
},{ | ||
}, | ||
{ | ||
name: "No_Diggity.mid", | ||
@@ -210,3 +224,4 @@ size: "17 KB", | ||
notes: "very important karaoke file" | ||
},{ | ||
}, | ||
{ | ||
name: "jorts.svg", | ||
@@ -217,3 +232,4 @@ size: "52 KB", | ||
notes: "logo for jort.technology" | ||
},{ | ||
}, | ||
{ | ||
name: "wordpress.sql", | ||
@@ -224,3 +240,4 @@ size: "418 KB", | ||
notes: "blog dump" | ||
},{ | ||
}, | ||
{ | ||
name: "foundation-compass-template-master.zip", | ||
@@ -232,3 +249,4 @@ size: "6 KB", | ||
} | ||
];</code></pre> | ||
]; | ||
``` | ||
@@ -239,3 +257,4 @@ ## Pagination | ||
<pre><code>// get your table | ||
```js | ||
// get your table | ||
var $table = $('table'); | ||
@@ -254,3 +273,4 @@ | ||
} | ||
});</code></pre> | ||
}); | ||
``` | ||
@@ -264,2 +284,3 @@ It will add a very simple first/prev/next/last pagination navigation on the bottom of the table. In the very near future I'll have more options for this. | ||
## Changelog | ||
* 1.1.1 critical array data bug fix | ||
* 1.1.0 another sorting refactor to speed things up even more | ||
@@ -279,4 +300,2 @@ * 1.0.9 column sorting refactor that [makes it *so* much faster](https://github.com/jennschiffer/timbles.js/pull/4), thanks @edelooff | ||
This was made within a few days for jqCon Chicago on 9/12/2014 and is currently being worked on as I use it for another soon-to-be open source project. I'm not taking feature requests on it unless they pertain to just sorting and pagination at the moment! | ||
**MOST IMPORTANTLY: HAVE FUN.** | ||
**HAVE FUN.** |
@@ -6,3 +6,3 @@ /** | ||
* | ||
* @version 1.0.9 | ||
* @version 1.1.0 | ||
* @author jenn schiffer http://jennmoney.biz | ||
@@ -161,2 +161,5 @@ */ | ||
$this.data(pluginName, data); | ||
// start enabling any given features | ||
methods.enableFeaturesSetup.call($this); | ||
}, | ||
@@ -192,4 +195,3 @@ | ||
// bind sorting to header cells | ||
$this.find('th').not('.no-sort').on( | ||
'click', methods.sortColumnEvent.bind($this)); | ||
$this.find('th').not('.no-sort').on('click', methods.sortColumnEvent.bind($this)); | ||
}, | ||
@@ -224,4 +226,4 @@ | ||
data.$headerRow.find('th') | ||
.removeClass(classes.sortASC) | ||
.removeClass(classes.sortDESC); | ||
.removeClass(classes.sortASC) | ||
.removeClass(classes.sortDESC); | ||
$sortHeader.addClass((order === 'asc') ? classes.sortASC : classes.sortDESC); | ||
@@ -232,9 +234,9 @@ | ||
var cell = this.children[sortColumn], | ||
dataValue = cell.getAttribute('data-value'); | ||
if (parseFloat(dataValue).toString() == dataValue) { | ||
dataValue = cell.getAttribute('data-value'); | ||
if (parseFloat(dataValue).toString() === dataValue) { | ||
dataValue = parseFloat(dataValue); | ||
} | ||
return { | ||
node: this, | ||
value: dataValue || cell.textContent || cell.innerText | ||
node: this, | ||
value: dataValue || cell.textContent || cell.innerText | ||
}; | ||
@@ -241,0 +243,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
3192
284
209453