diff --git a/jquery.restable.css b/jquery.restable.css
index 6300954..3bc18de 100644
--- a/jquery.restable.css
+++ b/jquery.restable.css
@@ -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 {
diff --git a/jquery.restable.js b/jquery.restable.js
index ad7e694..e4dacfc 100644
--- a/jquery.restable.js
+++ b/jquery.restable.js
@@ -37,18 +37,19 @@
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 = $('
', {
@@ -56,17 +57,17 @@
id: 'tabletolist' + i
}).insertBefore($(element));
$.each($result, function (index, value) {
-
+
var $myrow = $('', {
- html: '' + index + ''
+ html: (s.rowHeaders)? '' + index + '' : ''
}).appendTo($list);
var $myrowul = $('').appendTo($myrow);
$.each(value, function (index, value) {
-
+
$('', {
- html: (s.rowHeaders) ? ' ' + value + '' : value
+ html: ' ' + value + ''
}).appendTo($myrowul);
});
diff --git a/jquery.restable.min.css b/jquery.restable.min.css
index 0469ddf..62e415b 100644
--- a/jquery.restable.min.css
+++ b/jquery.restable.min.css
@@ -1 +1 @@
-ul.tabletolist{border-bottom:2px solid #eee;font-size:14px}ul.tabletolist.nrh{text-align:center}ul.tabletolist,ul.tabletolist ul{list-style:none!important;margin:0!important;padding:0!important}ul.tabletolist > li .titles{background-color:#bbb;color:#fff;display:block;font-weight:800;padding:10px}ul.tabletolist ul > li{border-bottom:1px solid #eee;font-weight:200;padding:10px}ul.tabletolist ul > li:hover{background-color:#efefef}ul.tabletolist ul > li:last-child{border-bottom:none}ul.tabletolist ul > li .row_headers{font-size:12px}ul.tabletolist ul > li .row_data{float:right;font-weight:800}
\ No newline at end of file
+ul.tabletolist{border-bottom:2px solid #eee;font-size:14px}ul.tabletolist.nrh{border-bottom:2px solid #ddd}ul.tabletolist.nrh > li{border-top:2px solid #ddd}ul.tabletolist,ul.tabletolist ul{list-style:none!important;margin:0!important;padding:0!important}ul.tabletolist > li .titles{background-color:#bbb;color:#fff;display:block;font-weight:800;padding:10px}ul.tabletolist ul > li{border-bottom:1px solid #eee;font-weight:200;padding:10px}ul.tabletolist ul > li:hover{background-color:#efefef}ul.tabletolist ul > li:last-child{border-bottom:none}ul.tabletolist ul > li .row_headers{font-size:12px}ul.tabletolist ul > li .row_data{float:right;font-weight:800}
\ No newline at end of file
diff --git a/jquery.restable.min.js b/jquery.restable.min.js
index 8a62ede..e55d622 100644
--- a/jquery.restable.min.js
+++ b/jquery.restable.min.js
@@ -1,2 +1,2 @@
/*! ReStable v0.1 by Alessandro Benoit */
-(function(e,t,n){e.fn.ReStable=function(r){function o(t,n){var r=[],i={},o=e(t).find("tr").first().children("td"),u=0,a;if(s.rowHeaders){o=o.slice(1)}o.each(function(){r.push(e(this).text())});e(t).find("tr").slice(1).each(function(){var t=e(this);u++;e.each(r,function(e,n){e++;if(!i[n]){i[n]={}}if(s.rowHeaders){i[n][t.children("td:nth-child(1)").text()]=t.children("td:nth-child("+(e+1)+")").text()}else{i[n][u]=t.children("td:nth-child("+e+")").text()}})});a=e("",{"class":"tabletolist "+(s.rowHeaders?"rh":"nrh"),id:"tabletolist"+n}).insertBefore(e(t));e.each(i,function(t,n){var r=e("",{html:''+t+""}).appendTo(a);var i=e("").appendTo(r);e.each(n,function(t,n){e("",{html:s.rowHeaders?' '+n+"":n}).appendTo(i)})});return a}var s=e.extend({rowHeaders:true,maxWidth:480},r);this.each(function(){function a(){if(e(t).width()>parseInt(s.maxWidth)){e(r).show();if(u){e(u).hide()}}else{e(r).hide();if(u){e(u).show()}else{u=o(r,n)}}}var r=e(this),u;n++;a();e(t).resize(function(){a()})})};e.ReStable=function(t){e("table").ReStable(t)}})(jQuery,this,0)
\ No newline at end of file
+(function(e,t,n){e.fn.ReStable=function(r){function o(t,n){var r=[],i={},o=e(t).find("tr").first().children("td"),u=0,a;if(s.rowHeaders){o=o.slice(1)}o.each(function(){r.push(e(this).text())});e(t).find("tr").slice(1).each(function(){var t=e(this);u++;e.each(r,function(e,n){e++;if(s.rowHeaders){if(!i[n]){i[n]={}}i[n][t.children("td:nth-child(1)").text()]=t.children("td:nth-child("+(e+1)+")").text()}else{if(!i[u]){i[u]={}}i[u][n]=t.children("td:nth-child("+e+")").text()}})});console.log(i);a=e("",{"class":"tabletolist "+(s.rowHeaders?"rh":"nrh"),id:"tabletolist"+n}).insertBefore(e(t));e.each(i,function(t,n){var r=e("",{html:s.rowHeaders?''+t+"":""}).appendTo(a);var i=e("").appendTo(r);e.each(n,function(t,n){e("",{html:' '+n+""}).appendTo(i)})});return a}var s=e.extend({rowHeaders:true,maxWidth:480},r);this.each(function(){function a(){if(e(t).width()>parseInt(s.maxWidth)){e(r).show();if(u){e(u).hide()}}else{e(r).hide();if(u){e(u).show()}else{u=o(r,n)}}}var r=e(this),u;n++;a();e(t).resize(function(){a()})})};e.ReStable=function(t){e("table").ReStable(t)}})(jQuery,this,0)
\ No newline at end of file