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

Version Path
flatui-rails-less-1.3 vendor/assets/javascripts/jquery.stacktable.js
flatui-rails-less-1.1 vendor/assets/javascripts/jquery.stacktable.js
flatui-rails-less-1.0 vendor/assets/javascripts/jquery.stacktable.js
flatui3-rails-0.0.1 app/assets/javascripts/jquery.stacktable.js
hushed-0.0.9 web/assets/javascripts/jquery.stacktable.js
flat_rails-0.0.2 app/assets/javascripts/jquery.stacktable.js
flat_rails-0.0.1 app/assets/javascripts/jquery.stacktable.js
hushed-0.0.8 web/assets/javascripts/jquery.stacktable.js
hushed-0.0.7 web/assets/javascripts/jquery.stacktable.js