/*! ReStable v0.1.1 by Alessandro Benoit */ (function ($, window, i) { 'use strict'; $.fn.ReStable = function (options) { // Settings var s = $.extend({ rowHeaders: true, maxWidth: 480 }, options); // Build the responsive menu container and fill it with build_menu() function create_responsive_table(element, i) { var $cols = [], $result = {}, $cols_header = $(element).find('tr').first().children('td,th'), $row_number = 0, $list; if (s.rowHeaders) { $cols_header = $cols_header.slice(1); } // Prende le intestazioni $cols_header.each(function () { $cols.push($(this).text()); }); // Costruisce un array con il contenuto: $result $(element).find('tr').slice(1).each(function () { var $row = $(this); $row_number += 1; $.each($cols, function (index, value) { index += 1; if (s.rowHeaders) { if (!$result[value]) { $result[value] = {}; } $result[value][$row.children('td:nth-child(1)').html()] = $row.children('td:nth-child(' + (index + 1) + ')').html(); } else { if (!$result[$row_number]) { $result[$row_number] = {}; } $result[$row_number][value] = $row.children('td:nth-child(' + index + ')').html(); } }); }); // Crea la lista $list = $('