Skip to content

Commit

Permalink
Fix misspelled delimiter option #215
Browse files Browse the repository at this point in the history
  • Loading branch information
glen-cheney committed Mar 26, 2018
1 parent fdb6205 commit f72f57d
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 25 deletions.
12 changes: 9 additions & 3 deletions dist/shuffle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/shuffle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/shuffle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/shuffle.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/_includes/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h2>Changelog<a href="#changelog"></a></h2>
<li><code>v4.1.1</code> 3/21/17 - the <code>before</code> styles for a <code>ShuffleItem</code> were not applied if the item didn&rsquo;t move.</li>
<li><code>v4.1.0</code> 1/30/17 - Use webpack-2 to bundle Shuffle.</li>
<li><code>v4.0.2</code> 9/15/16 - Update <code>custom-event-polyfill</code> dependency.</li>
<li><code>v4.0.1</code> 7/30/16 - Fix <code>delimeter</code> option.</li>
<li><code>v4.0.1</code> 7/30/16 - Fix <code>delimiter</code> option.</li>
<li><code>v4.0.0</code> 4/20/16 - Rewrite in ES6 with babel. Remove jQuery and Modernizr dependencies. Remove support for IE&lt;11. Docs improvements. Switch to gulp build system with webpack.</li>
<li><code>v3.1.0</code> 3/23/15 - Allow zero speed option (<a href="https://github.com/Vestride/Shuffle/issues/64">#64</a>) and cancel previous animations instead of ignoring new ones (<a href="https://github.com/Vestride/Shuffle/issues/69">#69</a>). Handle non-integer columns better (<a href="https://github.com/Vestride/Shuffle/issues/46">#46</a>)</li>
<li><code>v3.0.4</code> 2/16/15 - Publish to NPM.</li>
Expand Down
2 changes: 1 addition & 1 deletion docs/_includes/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h2>Options<a href="#options"></a></h2>
buffer: 0, // Useful for percentage based heights when they might not always be exactly the same (in pixels).
columnThreshold: 0.01, // Reading the width of elements isn't precise enough and can cause columns to jump between values.
columnWidth: 0, // A static number or function that returns a number which tells the plugin how wide the columns are (in pixels).
delimeter: null, // If your group is not json, and is comma delimeted, you could set delimeter to ','.
delimiter: null, // If your group is not json, and is comma delimeted, you could set delimiter to ','.
easing: 'cubic-bezier(0.4, 0.0, 0.2, 1)', // CSS easing function to use.
filterMode: Shuffle.FilterMode.ANY, // When using an array with filter(), the element passes the test if any of its groups are in the array. With "all", the element only passes if all groups are in the array.
group: Shuffle.ALL_ITEMS, // Initial filter group.
Expand Down
2 changes: 1 addition & 1 deletion docs/_includes/usage.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h2>Usage<a href="#usage"></a></h2>

<h3>The HTML Structure</h3>
<p>The only real important thing here is the <code class="language-markup token attr-name">data-groups</code> attribute. It has to be a <a href="http://jsonlint.com/">valid JSON</a> array of strings. It can also be a string delimeted by a value you provide with the <code>delimeter</code> option.</p>
<p>The only real important thing here is the <code class="language-markup token attr-name">data-groups</code> attribute. It has to be a <a href="http://jsonlint.com/">valid JSON</a> array of strings. It can also be a string delimeted by a value you provide with the <code>delimiter</code> option.</p>

<p>This example is using this site's grid. Each item would be 4 columns at the "sm" breakpoint (768px).</p>

Expand Down
12 changes: 9 additions & 3 deletions docs/dist/shuffle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/dist/shuffle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/dist/shuffle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/dist/shuffle.min.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ declare namespace Shuffle {
columnWidth?: number;

/**
* If your group is not json, and is comma delimeted, you could set delimeter to ','.
* If your group is not json, and is comma delimeted, you could set delimiter to ','.
*/
delimiter?: string;
delimeter?: string;

/**
Expand Down
14 changes: 10 additions & 4 deletions src/shuffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class Shuffle extends TinyEmitter {
super();
this.options = Object.assign({}, Shuffle.options, options);

// Allow misspelling of delimiter since that's how it used to be.
// Remove in v6.
if (this.options.delimeter) {
this.options.delimiter = this.options.delimeter;
}

this.lastSort = {};
this.group = Shuffle.ALL_ITEMS;
this.lastFilter = Shuffle.ALL_ITEMS;
Expand Down Expand Up @@ -239,8 +245,8 @@ class Shuffle extends TinyEmitter {

// Check each element's data-groups attribute against the given category.
const attr = element.getAttribute('data-' + Shuffle.FILTER_ATTRIBUTE_KEY);
const keys = this.options.delimeter ?
attr.split(this.options.delimeter) :
const keys = this.options.delimiter ?
attr.split(this.options.delimiter) :
JSON.parse(attr);

function testCategory(category) {
Expand Down Expand Up @@ -1150,9 +1156,9 @@ Shuffle.options = {
// how wide the columns are (in pixels).
columnWidth: 0,

// If your group is not json, and is comma delimeted, you could set delimeter
// If your group is not json, and is comma delimeted, you could set delimiter
// to ','.
delimeter: null,
delimiter: null,

// Useful for percentage based heights when they might not always be exactly
// the same (in pixels).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="delimeter">
<div id="delimiter">
<div class="item" id="item1" data-groups='design,red'>Person 1</div>
<div class="item" id="item2" data-groups='design,blue'>Person 2</div>
<div class="item" id="item3" data-groups='strategy,green'>Person 3</div>
Expand Down
17 changes: 13 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('shuffle', function () {
expect(instance.options.sizer).to.equal(null);
expect(instance.options.columnWidth).to.equal(0);
expect(instance.options.gutterWidth).to.equal(0);
expect(instance.options.delimeter).to.equal(null);
expect(instance.options.delimiter).to.equal(null);
expect(instance.options.initialSort).to.equal(null);
expect(instance.options.throttleTime).to.equal(300);
expect(instance.id).to.equal('shuffle_0');
Expand Down Expand Up @@ -606,20 +606,29 @@ describe('shuffle', function () {
});
});

describe('delimeter fixture', function () {
describe('delimiter fixture', function () {
beforeEach(function (done) {
// Mock the transition end event wrapper.
sinon.stub(Shuffle.prototype, '_whenTransitionDone').callsFake(whenTransitionDoneStub);

appendFixture('delimeter').then(done);
appendFixture('delimiter').then(done);
});

afterEach(function () {
Shuffle.prototype._whenTransitionDone.restore();
removeFixture();
});

it('can have a custom delimeter', function () {
it('can have a custom delimiter', function () {
instance = new Shuffle(fixture, {
delimiter: ',',
group: 'design',
});

expect(instance.visibleItems).to.equal(3);
});

it('can use the old misspelled delimiter option', function () {
instance = new Shuffle(fixture, {
delimeter: ',',
group: 'design',
Expand Down

0 comments on commit f72f57d

Please sign in to comment.