All Downloads are FREE. Search and download functionalities are using the official Maven repository.

open_admin_style.js.admin.lib.responsive-tables.js Maven / Gradle / Ivy

There is a newer version: 3.1.15-GA
Show newest version
$(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("
"); 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("
"); original.wrap("
"); setCellHeights(original, copy); } function unsplitTable(original) { original.closest(".table-wrapper").find(".pinned").remove(); original.unwrap(); original.unwrap(); } function setCellHeights(original, copy) { var tr = original.find('tr'), tr_copy = copy.find('tr'), heights = []; tr.each(function (index) { var self = $(this), tx = self.find('th, td'); tx.each(function () { var height = $(this).outerHeight(true); heights[index] = heights[index] || 0; if (height > heights[index]) heights[index] = height; }); }); tr_copy.each(function (index) { $(this).height(heights[index]); }); } });




© 2015 - 2024 Weber Informatics LLC | Privacy Policy