Sha256: c02514d8998df95afb6cd3c4fd088dcaf52c54368c7e0c49d85d26c6713b8eb8
Contents?: true
Size: 1.63 KB
Versions: 9
Compression:
Stored size: 1.63 KB
Contents
/** * MODIFIED CAUSE WE NEEDED OUR OWN MARKUP * stacktable.js * Author & copyright (c) 2012: John Polacek * Dual MIT & GPL license * * Page: http://johnpolacek.github.com/stacktable.js * Repo: https://github.com/johnpolacek/stacktable.js/ * * jQuery plugin for stacking tables on small screens * */ ;(function($) { $.fn.stacktable = function(options) { var $tables = this, defaults = {id:'stacktable',hideOriginal:false}, settings = $.extend({}, defaults, options), stacktable; return $tables.each(function() { var $stacktable = $('<table class="'+settings.id+'"><tbody></tbody></table>'); if (typeof settings.myClass !== undefined) $stacktable.addClass(settings.myClass); var markup = ''; $table = $(this); $topRow = $table.find('tr').eq(0); $table.find('tr').each(function(index,value) { var zebra = ""; if (index % 2 === 0) { zebra = "even"; } else { zebra = "odd"; } markup += '<tr class="' + zebra + '">'; $(this).find('td').each(function(index,value) { if ($(this).html() !== ''){ markup += '<tr class="' + zebra + '">'; if ($topRow.find('td,th').eq(index).html()){ markup += '<td>'+$topRow.find('td,th').eq(index).html()+'</td>'; } else { markup += '<td></td>'; } markup += '<td>'+$(this).html()+'</td>'; markup += '</tr>'; } }); }); $stacktable.append($(markup)); $table.before($stacktable); if (settings.hideOriginal) $table.hide(); }); }; }(jQuery));
Version data entries
9 entries across 9 versions & 4 rubygems