Skip to content

Commit

Permalink
Improved no rowHeaders responsive table layout
Browse files Browse the repository at this point in the history
  • Loading branch information
micc83 committed Nov 21, 2013
1 parent f93b21d commit dd9acec
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
6 changes: 5 additions & 1 deletion jquery.restable.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ ul.tabletolist {
}
/* Table with no row headers */
ul.tabletolist.nrh {
text-align: center;
border-bottom: 2px solid #ddd;resize
}
/* Table with no row headers columns */
ul.tabletolist.nrh > li {
border-top: 2px solid #ddd;
}
/* Table defaults */
ul.tabletolist, ul.tabletolist ul {
Expand Down
17 changes: 9 additions & 8 deletions jquery.restable.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,37 @@

index++;

if (!$result[value]) {
$result[value] = {};
}
if (s.rowHeaders) {
if (!$result[value]) { $result[value] = {}; }
$result[value][$row.children('td:nth-child(1)').text()] = $row.children('td:nth-child(' + (index + 1) + ')').text();
} else {
$result[value][$row_number] = $row.children('td:nth-child(' + index + ')').text();
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 = $('<ul/>', {
class: 'tabletolist ' + ((s.rowHeaders) ? 'rh' : 'nrh'),
id: 'tabletolist' + i
}).insertBefore($(element));
$.each($result, function (index, value) {

var $myrow = $('<li/>', {
html: '<span class="titles">' + index + '</span>'
html: (s.rowHeaders)? '<span class="titles">' + index + '</span>' : ''
}).appendTo($list);

var $myrowul = $('<ul/>').appendTo($myrow);

$.each(value, function (index, value) {

$('<li/>', {
html: (s.rowHeaders) ? '<span class="row_headers">' + index + '</span> <span class="row_data">' + value + '</span>' : value
html: '<span class="row_headers">' + index + '</span> <span class="row_data">' + value + '</span>'
}).appendTo($myrowul);

});
Expand Down
2 changes: 1 addition & 1 deletion jquery.restable.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jquery.restable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dd9acec

Please sign in to comment.