diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..960b533 --- /dev/null +++ b/bower.json @@ -0,0 +1,20 @@ +{ + "name": "ReStable", + "version": "0.1.1", + "description": "jQuery plugin that make tables responsive", + "keywords": [ + "table", + "responsive" + ], + "main": [ + "jquery.restable.min.js", + "jquery.restable.min.css" + ], + "ignore": [ + "demo" + ], + "dependencies": { + "jquery": ">=1.6.4" + }, + "license": "MIT" +} \ No newline at end of file diff --git a/demo/index.html b/demo/index.html index 9b8796a..3233608 100644 --- a/demo/index.html +++ b/demo/index.html @@ -22,7 +22,7 @@
-

jQuery ReStable v0.1.0

+

jQuery ReStable v0.1.1

jQuery ReStable is a very simple and lightweight (~1Kb) jQuery plugin that make tables responsive making them collapse into ul lists.

@@ -90,10 +90,10 @@

Some examples

- - - - + + + + diff --git a/demo/main.css b/demo/main.css index 88ff043..a966d2a 100644 --- a/demo/main.css +++ b/demo/main.css @@ -13,7 +13,7 @@ pre {background-color: #fafafa;padding: 20px;overflow: auto;border: 1px solid #f .download_button:hover {background-color: #eaeaea;} table {width: 100%;text-align: center;border: 0;border-collapse: collapse;border-spacing: 0;font-size: 14px;} -table td {padding: 10px;margin: 0;} +table td, table th {padding: 10px;margin: 0;} table thead {background-color: #bbb;color: #fff;font-weight: 800;} table tbody tr td{border-bottom: 1px solid #eee;} table tbody tr:hover td{background-color: #eee;} \ No newline at end of file diff --git a/jquery.restable.js b/jquery.restable.js index e4dacfc..083e154 100644 --- a/jquery.restable.js +++ b/jquery.restable.js @@ -1,6 +1,8 @@ -/*! ReStable v0.1 by Alessandro Benoit */ +/*! ReStable v0.1.1 by Alessandro Benoit */ (function ($, window, i) { + 'use strict'; + $.fn.ReStable = function (options) { // Settings @@ -14,7 +16,7 @@ var $cols = [], $result = {}, - $cols_header = $(element).find('tr').first().children('td'), + $cols_header = $(element).find('tr').first().children('td,th'), $row_number = 0, $list; @@ -31,25 +33,23 @@ $(element).find('tr').slice(1).each(function () { var $row = $(this); - $row_number++; + $row_number += 1; $.each($cols, function (index, value) { - index++; + index += 1; if (s.rowHeaders) { - if (!$result[value]) { $result[value] = {}; } + if (!$result[value]) { $result[value] = {}; } $result[value][$row.children('td:nth-child(1)').text()] = $row.children('td:nth-child(' + (index + 1) + ')').text(); } else { - if (!$result[$row_number]) { $result[$row_number] = {}; } + if (!$result[$row_number]) { $result[$row_number] = {}; } $result[$row_number][value] = $row.children('td:nth-child(' + index + ')').text(); } }); }); - - console.log($result); // Crea la lista $list = $('
PeriodFull BoardHalf BoardBed and BreakfastPeriodFull BoardHalf BoardBed and Breakfast