Sha256: 4f997e8a9de2e68a2953b3581b9c1b7c70eb93994db16fb6a47ec1edd4042540

Contents?: true

Size: 1.07 KB

Versions: 101

Compression:

Stored size: 1.07 KB

Contents

$(document).ready(function() {
  var switched = false;
  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

101 entries across 101 versions & 4 rubygems

Version Path
solidus_backend-1.1.4 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.0.7 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.0.6 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.1.3 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.0.5 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.0.4 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.1.2 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.0.3 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.1.1 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.1.0 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.1.0.pre2 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.1.0.pre1 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.1.0.beta1 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.0.2 vendor/assets/javascripts/responsive-tables.js
spree_backend-2.4.10 vendor/assets/javascripts/responsive-tables.js
spree_backend-2.3.13 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.0.1 vendor/assets/javascripts/responsive-tables.js
spree_backend-2.2.14 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.0.0 vendor/assets/javascripts/responsive-tables.js
solidus_backend-1.0.0.rc2 vendor/assets/javascripts/responsive-tables.js