Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
v3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jul 13, 2017
1 parent 21b838d commit 869e24e
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 45 deletions.
2 changes: 1 addition & 1 deletion dist/stackonly/tablesaw.stackonly.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Tablesaw - v3.0.2 - 2017-07-07
/*! Tablesaw - v3.0.3 - 2017-07-13
* https://github.com/filamentgroup/tablesaw
* Copyright (c) 2017 Filament Group; Licensed MIT */

Expand Down
10 changes: 9 additions & 1 deletion dist/stackonly/tablesaw.stackonly.jquery.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Tablesaw - v3.0.2 - 2017-07-07
/*! Tablesaw - v3.0.3 - 2017-07-13
* https://github.com/filamentgroup/tablesaw
* Copyright (c) 2017 Filament Group; Licensed MIT */
// UMD module definition
Expand Down Expand Up @@ -111,6 +111,14 @@ if (Tablesaw.mustard) {
};

Table.prototype.init = function() {
if (!this.$thead.length) {
throw new Error("tablesaw: a <thead> is required, but none was found.");
}

if (!this.$thead.find("th").length) {
throw new Error("tablesaw: no header cells found. Are you using <th> inside of <thead>?");
}

// assign an id if there is none
if (!this.$table.attr("id")) {
this.$table.attr("id", pluginName + "-" + Math.round(Math.random() * 10000));
Expand Down
10 changes: 9 additions & 1 deletion dist/stackonly/tablesaw.stackonly.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Tablesaw - v3.0.2 - 2017-07-07
/*! Tablesaw - v3.0.3 - 2017-07-13
* https://github.com/filamentgroup/tablesaw
* Copyright (c) 2017 Filament Group; Licensed MIT */
/*! Shoestring - v2.0.0 - 2017-02-14
Expand Down Expand Up @@ -1818,6 +1818,14 @@ if (Tablesaw.mustard) {
};

Table.prototype.init = function() {
if (!this.$thead.length) {
throw new Error("tablesaw: a <thead> is required, but none was found.");
}

if (!this.$thead.find("th").length) {
throw new Error("tablesaw: no header cells found. Are you using <th> inside of <thead>?");
}

// assign an id if there is none
if (!this.$table.attr("id")) {
this.$table.attr("id", pluginName + "-" + Math.round(Math.random() * 10000));
Expand Down
4 changes: 2 additions & 2 deletions dist/stackonly/tablesaw.stackonly.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! Tablesaw - v3.0.2 - 2017-07-07
/*! Tablesaw - v3.0.3 - 2017-07-13
* https://github.com/filamentgroup/tablesaw
* Copyright (c) 2017 Filament Group; Licensed MIT */
/*! Tablesaw - v3.0.2 - 2017-07-07
/*! Tablesaw - v3.0.3 - 2017-07-13
* https://github.com/filamentgroup/tablesaw
* Copyright (c) 2017 Filament Group; Licensed MIT */

Expand Down
2 changes: 1 addition & 1 deletion dist/tablesaw-init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Tablesaw - v3.0.2 - 2017-07-07
/*! Tablesaw - v3.0.3 - 2017-07-13
* https://github.com/filamentgroup/tablesaw
* Copyright (c) 2017 Filament Group; Licensed MIT */
(function(win) {
Expand Down
20 changes: 10 additions & 10 deletions dist/tablesaw.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Tablesaw - v3.0.2 - 2017-07-07
/*! Tablesaw - v3.0.3 - 2017-07-13
* https://github.com/filamentgroup/tablesaw
* Copyright (c) 2017 Filament Group; Licensed MIT */

Expand Down Expand Up @@ -340,15 +340,15 @@ a.tablesaw-btn {
margin: .59375em 0;
}

.tablesaw-swipe .tablesaw-cell-persist {
.tablesaw-swipe .tablesaw-swipe-cellpersist {
border-right: 2px solid #e4e1de;
}

.tablesaw-swipe-shadow .tablesaw-cell-persist {
.tablesaw-swipe-shadow .tablesaw-swipe-cellpersist {
border-right-width: 1px;
}

.tablesaw-swipe-shadow .tablesaw-cell-persist {
.tablesaw-swipe-shadow .tablesaw-swipe-cellpersist {
box-shadow: 3px 0 4px -1px #e4e1de;
}

Expand Down Expand Up @@ -491,8 +491,8 @@ a.tablesaw-btn {
@media only all {
/* Unchecked manually: Always hide */

.tablesaw-swipe th.tablesaw-cell-hidden,
.tablesaw-swipe td.tablesaw-cell-hidden {
.tablesaw-swipe th.tablesaw-swipe-cellhidden,
.tablesaw-swipe td.tablesaw-swipe-cellhidden {
display: none;
}
}
Expand Down Expand Up @@ -650,15 +650,15 @@ a.tablesaw-btn {
@media only all {
/* Unchecked manually: Always hide */

.tablesaw-columntoggle th.tablesaw-cell-hidden,
.tablesaw-columntoggle td.tablesaw-cell-hidden {
.tablesaw-columntoggle th.tablesaw-toggle-cellhidden,
.tablesaw-columntoggle td.tablesaw-toggle-cellhidden {
display: none;
}

/* Checked manually: Always show */

.tablesaw-columntoggle th.tablesaw-cell-visible,
.tablesaw-columntoggle td.tablesaw-cell-visible {
.tablesaw-columntoggle th.tablesaw-toggle-cellvisible,
.tablesaw-columntoggle td.tablesaw-toggle-cellvisible {
display: table-cell;
}
}
Expand Down
77 changes: 63 additions & 14 deletions dist/tablesaw.jquery.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Tablesaw - v3.0.2 - 2017-07-07
/*! Tablesaw - v3.0.3 - 2017-07-13
* https://github.com/filamentgroup/tablesaw
* Copyright (c) 2017 Filament Group; Licensed MIT */
// UMD module definition
Expand Down Expand Up @@ -111,6 +111,14 @@ if (Tablesaw.mustard) {
};

Table.prototype.init = function() {
if (!this.$thead.length) {
throw new Error("tablesaw: a <thead> is required, but none was found.");
}

if (!this.$thead.find("th").length) {
throw new Error("tablesaw: no header cells found. Are you using <th> inside of <thead>?");
}

// assign an id if there is none
if (!this.$table.attr("id")) {
this.$table.attr("id", pluginName + "-" + Math.round(Math.random() * 10000));
Expand Down Expand Up @@ -691,8 +699,8 @@ if (Tablesaw.mustard) {
var header = self.getHeaderFromCheckbox(checkbox);
var $cells = self.$getCells(header);

$cells[!checked ? "addClass" : "removeClass"]("tablesaw-cell-hidden");
$cells[checked ? "addClass" : "removeClass"]("tablesaw-cell-visible");
$cells[!checked ? "addClass" : "removeClass"]("tablesaw-toggle-cellhidden");
$cells[checked ? "addClass" : "removeClass"]("tablesaw-toggle-cellvisible");

self.updateColspanIgnoredRows(checked, $(header).add(header.cells));

Expand Down Expand Up @@ -873,7 +881,7 @@ if (Tablesaw.mustard) {
this.$table.removeClass(this.classes.columnToggleTable);
this.$table.find("th, td").each(function() {
var $cell = $(this);
$cell.removeClass("tablesaw-cell-hidden").removeClass("tablesaw-cell-visible");
$cell.removeClass("tablesaw-toggle-cellhidden").removeClass("tablesaw-toggle-cellvisible");

this.className = this.className.replace(/\bui\-table\-priority\-\d\b/g, "");
});
Expand Down Expand Up @@ -1272,10 +1280,14 @@ if (Tablesaw.mustard) {
var classes = {
hideBtn: "disabled",
persistWidths: "tablesaw-fix-persist",
hiddenCol: "tablesaw-swipe-cellhidden",
persistCol: "tablesaw-swipe-cellpersist",
allColumnsVisible: "tablesaw-all-cols-visible"
};
var attrs = {
disableTouchEvents: "data-tablesaw-no-touch"
disableTouchEvents: "data-tablesaw-no-touch",
ignorerow: "data-tablesaw-ignorerow",
subrow: "data-tablesaw-subrow"
};

function createSwipeTable(tbl, $table) {
Expand All @@ -1302,13 +1314,13 @@ if (Tablesaw.mustard) {
var tableId = $table.attr("id");

if (!$headerCells.length) {
throw new Error(
"tablesaw swipe: no header cells found. Are you using <th> inside of <thead>?"
);
throw new Error("tablesaw swipe: no header cells found.");
}

$table.addClass("tablesaw-swipe");

$table.find("." + classes.hiddenCol).removeClass(classes.hiddenCol);

// Calculate initial widths
$headerCells.each(function() {
var width = this.offsetWidth;
Expand All @@ -1323,25 +1335,53 @@ if (Tablesaw.mustard) {
}

function $getCells(headerCell) {
return $(headerCell.cells).add(headerCell);
return $(headerCell.cells).add(headerCell).filter(function() {
return !$(this).parent().is("[" + attrs.ignorerow + "],[" + attrs.subrow + "]");
});
}

function showColumn(headerCell) {
$getCells(headerCell).removeClass("tablesaw-cell-hidden");
$getCells(headerCell).removeClass(classes.hiddenCol);
}

function hideColumn(headerCell) {
$getCells(headerCell).addClass("tablesaw-cell-hidden");
$getCells(headerCell).addClass(classes.hiddenCol);
}

function persistColumn(headerCell) {
$getCells(headerCell).addClass("tablesaw-cell-persist");
$getCells(headerCell).addClass(classes.persistCol);
}

function isPersistent(headerCell) {
return $(headerCell).is('[data-tablesaw-priority="persist"]');
}

function countVisibleColspan() {
var count = 0;
$headerCells.each(function() {
var $t = $(this);
if ($t.is("." + classes.hiddenCol)) {
return;
}
count += parseInt($t.attr("colspan") || 1, 10);
});
return count;
}

function updateColspanOnIgnoredRows(newColspan) {
if (!newColspan) {
newColspan = countVisibleColspan();
}
$table
.find("[" + attrs.ignorerow + "],[" + attrs.subrow + "]")
.find("td[colspan]")
.each(function() {
var $t = $(this);
var colspan = parseInt($t.attr("colspan"), 10);
$t.attr("colspan", newColspan);
});
}

function unmaintainWidths() {
$table.removeClass(classes.persistWidths);
$("#" + tableId + "-persist").remove();
Expand All @@ -1364,7 +1404,9 @@ if (Tablesaw.mustard) {
hash.push(index + "-" + width);
styles.push(
prefix +
" .tablesaw-cell-persist:nth-child(" +
" ." +
classes.persistCol +
":nth-child(" +
(index + 1) +
") { width: " +
width +
Expand Down Expand Up @@ -1397,7 +1439,7 @@ if (Tablesaw.mustard) {

$headerCellsNoPersist.each(function(i) {
var $t = $(this),
isHidden = $t.css("display") === "none" || $t.is(".tablesaw-cell-hidden");
isHidden = $t.css("display") === "none" || $t.is("." + classes.hiddenCol);

if (!isHidden && !checkFound) {
checkFound = true;
Expand Down Expand Up @@ -1457,23 +1499,29 @@ if (Tablesaw.mustard) {

// We need at least one column to swipe.
var needsNonPersistentColumn = visibleNonPersistantCount === 0;
var visibleColumnCount = 0;

$headerCells.each(function(index) {
var colspan = parseInt($(this).attr("colspan") || 1, 10);
if (persist[index]) {
visibleColumnCount += colspan;
// for visual box-shadow
persistColumn(this);
return;
}

if (sums[index] <= containerWidth || needsNonPersistentColumn) {
visibleColumnCount += colspan;
needsNonPersistentColumn = false;
showColumn(this);
} else {
hideColumn(this);
}
});

updateColspanOnIgnoredRows(visibleColumnCount);
unmaintainWidths();

$table.trigger("tablesawcolumns");
}

Expand All @@ -1492,6 +1540,7 @@ if (Tablesaw.mustard) {

hideColumn($headerCellsNoPersist.get(pair[0]));
showColumn($headerCellsNoPersist.get(pair[1]));
updateColspanOnIgnoredRows();

$table.trigger("tablesawcolumns");
}
Expand Down
Loading

0 comments on commit 869e24e

Please sign in to comment.