Sha256: 3b0558a36d2c122f1341d85f97cd9816a15e6047854483d407272f4e296b741c

Contents?: true

Size: 1.13 KB

Versions: 128

Compression:

Stored size: 1.13 KB

Contents

$(document).ready(function() {
  var switched = false;
  $("table").not(".syntaxhighlighter").addClass("responsive");
  var updateTables = function() {
    if (($(window).width() < 767) && !switched ){
      switched = true;
      $("table.responsive").each(function(i, element) {
        splitTable($(element));
      });
      return true;
    }
    else if (switched && ($(window).width() > 767)) {
      switched = false;
      $("table.responsive").each(function(i, element) {
        unsplitTable($(element));
      });
    }
  };
   
  $(window).load(updateTables);
  $(window).bind("resize", updateTables);
   
	
	function splitTable(original)
	{
		original.wrap("<div class='table-wrapper' />");
		
		var copy = original.clone();
		copy.find("td:not(:first-child), th:not(:first-child)").css("display", "none");
		copy.removeClass("responsive");
		
		original.closest(".table-wrapper").append(copy);
		copy.wrap("<div class='pinned' />");
		original.wrap("<div class='scrollable' />");
	}
	
	function unsplitTable(original) {
    original.closest(".table-wrapper").find(".pinned").remove();
    original.unwrap();
    original.unwrap();
	}

});

Version data entries

128 entries across 123 versions & 11 rubygems

Version Path
rails-4.2.11.3 guides/assets/javascripts/responsive-tables.js
rails-4.2.11.2 guides/assets/javascripts/responsive-tables.js
rails-4.2.11.1 guides/assets/javascripts/responsive-tables.js
rails-4.2.11 guides/assets/javascripts/responsive-tables.js
rails-4.2.10 guides/assets/javascripts/responsive-tables.js
rails-4.2.10.rc1 guides/assets/javascripts/responsive-tables.js
ruby-on-quails-0.1.0 guides/assets/javascripts/responsive-tables.js
rails-4.2.9 guides/assets/javascripts/responsive-tables.js
rails-4.2.9.rc2 guides/assets/javascripts/responsive-tables.js
rails-4.2.9.rc1 guides/assets/javascripts/responsive-tables.js
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/rails-4.2.8/guides/assets/javascripts/responsive-tables.js
rails-4.2.8 guides/assets/javascripts/responsive-tables.js
rails-4.2.8.rc1 guides/assets/javascripts/responsive-tables.js
rails-4.2.7.1 guides/assets/javascripts/responsive-tables.js
rails-4.2.7 guides/assets/javascripts/responsive-tables.js
rails-4.1.16 guides/assets/javascripts/responsive-tables.js
rails-4.1.16.rc1 guides/assets/javascripts/responsive-tables.js
rails-4.2.7.rc1 guides/assets/javascripts/responsive-tables.js
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rails-4.2.6/guides/assets/javascripts/responsive-tables.js
rails-4.1.15 guides/assets/javascripts/responsive-tables.js