From 07ea4b76a60ebe402df97ff414185263d375a586 Mon Sep 17 00:00:00 2001 From: Jack Date: Tue, 5 Apr 2016 12:00:33 +0200 Subject: [PATCH 1/2] Added data-attribute no-expander to to disable the .expander TH being added. --- lib/makeColumn.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/makeColumn.js b/lib/makeColumn.js index 25ce424..09a37e9 100644 --- a/lib/makeColumn.js +++ b/lib/makeColumn.js @@ -25,6 +25,7 @@ module.exports = function(col) { // Check for sizes. If no attribute is provided, default to small-12. Divide evenly for large columns var smallSize = $(col).attr('small') || this.columnCount; var largeSize = $(col).attr('large') || $(col).attr('small') || Math.floor(this.columnCount / colCount); + var noExpander = $(col).attr('no-expander'); classes.push(format('small-%s', smallSize)); classes.push(format('large-%s', largeSize)); @@ -38,7 +39,7 @@ module.exports = function(col) { // If the column contains a nested row, the .expander class should not be used // The == on the first check is because we're comparing a string pulled from $.attr() to a number - if (largeSize == this.columnCount && col.find('.row, row').length === 0) { + if (largeSize == this.columnCount && col.find('.row, row').length === 0 && noExpander == undefined ) { expander = '\n'; } From 7c44b44dae6727b88e269f0b529b299af2167cfa Mon Sep 17 00:00:00 2001 From: Jack Date: Tue, 5 Apr 2016 12:11:14 +0200 Subject: [PATCH 2/2] Data-attribute no-expander to also accepts false / true 3 new test with no-expander on columns (case only empty Data-attribute no-expander, Data-attribute no-expander = false & Data-attribute no-expander = true) --- lib/makeColumn.js | 2 +- test/grid.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/lib/makeColumn.js b/lib/makeColumn.js index 09a37e9..51c540f 100644 --- a/lib/makeColumn.js +++ b/lib/makeColumn.js @@ -39,7 +39,7 @@ module.exports = function(col) { // If the column contains a nested row, the .expander class should not be used // The == on the first check is because we're comparing a string pulled from $.attr() to a number - if (largeSize == this.columnCount && col.find('.row, row').length === 0 && noExpander == undefined ) { + if (largeSize == this.columnCount && col.find('.row, row').length === 0 && (noExpander == undefined || noExpander == "false") ) { expander = '\n'; } diff --git a/test/grid.js b/test/grid.js index af1f831..8b49810 100644 --- a/test/grid.js +++ b/test/grid.js @@ -75,6 +75,52 @@ describe('Grid', () => { compare(input, expected); }); + it('creates a single column with first and last classes with no-expander', function () { + var input = 'One'; + var expected = ` + + + + + +
One
+ + `; + + compare(input, expected); + }); + + it('creates a single column with first and last classes with no-expander="false"', function () { + var input = 'One'; + var expected = ` + + + + + + +
One
+ + `; + + compare(input, expected); + }); + + it('creates a single column with first and last classes with no-expander="true"', function () { + var input = 'One'; + var expected = ` + + + + + +
One
+ + `; + + compare(input, expected); + }); + it('creates two columns, one first, one last', function () { var input = ` One