File indexing completed on 2024-05-19 06:00:28
0001 /** 0002 * MODIFIED CAUSE WE NEEDED OUR OWN MARKUP 0003 * stacktable.js 0004 * Author & copyright (c) 2012: John Polacek 0005 * Dual MIT & GPL license 0006 * 0007 * Page: http://johnpolacek.github.com/stacktable.js 0008 * Repo: https://github.com/johnpolacek/stacktable.js/ 0009 * 0010 * jQuery plugin for stacking tables on small screens 0011 * 0012 */ 0013 ;(function($) { 0014 0015 $.fn.stacktable = function(options) { 0016 var $tables = this, 0017 defaults = {id:'stacktable',hideOriginal:false}, 0018 settings = $.extend({}, defaults, options), 0019 stacktable; 0020 0021 return $tables.each(function() { 0022 var $stacktable = $('<table class="'+settings.id+'"><tbody></tbody></table>'); 0023 if (typeof settings.myClass !== undefined) $stacktable.addClass(settings.myClass); 0024 var markup = ''; 0025 $table = $(this); 0026 $topRow = $table.find('tr').eq(0); 0027 $table.find('tr').each(function(index,value) { 0028 var zebra = ""; 0029 if (index % 2 === 0) { 0030 zebra = "even"; 0031 } else { 0032 zebra = "odd"; 0033 } 0034 markup += '<tr class="' + zebra + '">'; 0035 $(this).find('td').each(function(index,value) { 0036 if ($(this).html() !== ''){ 0037 markup += '<tr class="' + zebra + '">'; 0038 if ($topRow.find('td,th').eq(index).html()){ 0039 markup += '<td>'+$topRow.find('td,th').eq(index).html()+'</td>'; 0040 } else { 0041 markup += '<td></td>'; 0042 } 0043 markup += '<td>'+$(this).html()+'</td>'; 0044 markup += '</tr>'; 0045 } 0046 }); 0047 }); 0048 $stacktable.append($(markup)); 0049 $table.before($stacktable); 0050 if (settings.hideOriginal) $table.hide(); 0051 }); 0052 }; 0053 0054 }(jQuery));