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

Commit

Permalink
v3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkunka committed Oct 1, 2018
1 parent a4c474e commit 61dac05
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change Log
==========

## 3.3.1
- Insures dataset uses polyfilled `Array.from` for old IE support.
- Fixes support for sorting via element collection. This was not correctly implemented before although documented.
- Fixes the "filter-by-url" demo to ensure that only leading `'.'` characters are stripped off rather than any character.

## 3.3.0
- Introduces new internal filter hook `testResultEvaluateHideShown` allowing plugins to manipulate the result of every filter test upon a target. Provides an convenient entry point for non-selector based filtering such as range slider inputs.
- Adds range slider demo.
Expand Down
2 changes: 1 addition & 1 deletion demos/filtering-by-url/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

function setHash(state) {
var selector = state.activeFilter.selector;
var newHash = '#' + selector.replace(/^./g, '');
var newHash = '#' + selector.replace(/^\./g, '');

if (selector === targetSelector && window.location.hash) {
// Equivalent to filter "all", remove the hash
Expand Down
8 changes: 4 additions & 4 deletions demos/mixitup.min.js

Large diffs are not rendered by default.

35 changes: 29 additions & 6 deletions dist/mixitup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**!
* MixItUp v3.3.0
* MixItUp v3.3.1
* A high-performance, dependency-free library for animated filtering, sorting and more
* Build 0be05511-2264-4384-8e31-c75554304cd0
* Build 94e0fbf6-cd0b-4987-b3c0-14b59b67b8a0
*
* @copyright Copyright 2014-2018 KunkaLabs Limited.
* @author KunkaLabs Limited.
Expand Down Expand Up @@ -5766,7 +5766,11 @@
*/

sortOperation: function(operation) {
var self = this;
var self = this,
newOrder = [],
target = null,
el = null,
i = -1;

self.callActions('beforeSortOperation', arguments);

Expand All @@ -5775,7 +5779,23 @@
if (operation.newSort.collection) {
// Sort by collection

operation.newOrder = operation.newSort.collection;
newOrder = [];

for (i = 0; (el = operation.newSort.collection[i]); i++) {
if (self.dom.targets.indexOf(el) < 0) {
throw new Error(mixitup.messages.errorSortNonExistentElement());
}

target = new mixitup.Target();

target.init(el, self);

target.isInDom = true;

newOrder.push(target);
}

operation.newOrder = newOrder;
} else if (operation.newSort.order === 'random') {
// Sort random

Expand Down Expand Up @@ -7824,7 +7844,7 @@

insertDatasetFrag: function(frag, nextEl, targets) {
var self = this;
var insertAt = nextEl ? Array.from(self.dom.parent.children).indexOf(nextEl) : self.targets.length;
var insertAt = nextEl ? h.arrayFromList(self.dom.parent.children).indexOf(nextEl) : self.targets.length;

self.dom.parent.insertBefore(frag, nextEl);

Expand Down Expand Up @@ -10535,6 +10555,9 @@
this.ERROR_DATASET_RENDERER_NOT_SET =
'[MixItUp] To insert an element via the dataset API, a target renderer function must be provided to `render.target`';

this.ERROR_SORT_NON_EXISTENT_ELEMENT =
'[MixItUp] An element to be sorted does not already exist in the container';

/* Warnings
----------------------------------------------------------------------------- */

Expand Down Expand Up @@ -10655,5 +10678,5 @@
mixitup.BaseStatic.call(mixitup.constructor);

mixitup.NAME = 'mixitup';
mixitup.CORE_VERSION = '3.3.0';
mixitup.CORE_VERSION = '3.3.1';
})(window);
8 changes: 4 additions & 4 deletions dist/mixitup.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mixitup",
"title": "MixItUp",
"version": "3.3.0",
"version": "3.3.1",
"description": "A high-performance, dependency-free library for animated filtering, sorting and more",
"author": "KunkaLabs Limited",
"homepage": "https://www.kunkalabs.com/mixitup/",
Expand Down
3 changes: 3 additions & 0 deletions src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ mixitup.Messages = function() {
this.ERROR_DATASET_RENDERER_NOT_SET =
'[MixItUp] To insert an element via the dataset API, a target renderer function must be provided to `render.target`';

this.ERROR_SORT_NON_EXISTENT_ELEMENT =
'[MixItUp] An element to be sorted does not already exist in the container';

/* Warnings
----------------------------------------------------------------------------- */

Expand Down
26 changes: 23 additions & 3 deletions src/mixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,11 @@ h.extend(mixitup.Mixer.prototype,
*/

sortOperation: function(operation) {
var self = this;
var self = this,
newOrder = [],
target = null,
el = null,
i = -1;

self.callActions('beforeSortOperation', arguments);

Expand All @@ -847,7 +851,23 @@ h.extend(mixitup.Mixer.prototype,
if (operation.newSort.collection) {
// Sort by collection

operation.newOrder = operation.newSort.collection;
newOrder = [];

for (i = 0; (el = operation.newSort.collection[i]); i++) {
if (self.dom.targets.indexOf(el) < 0) {
throw new Error(mixitup.messages.errorSortNonExistentElement());
}

target = new mixitup.Target();

target.init(el, self);

target.isInDom = true;

newOrder.push(target);
}

operation.newOrder = newOrder;
} else if (operation.newSort.order === 'random') {
// Sort random

Expand Down Expand Up @@ -2896,7 +2916,7 @@ h.extend(mixitup.Mixer.prototype,

insertDatasetFrag: function(frag, nextEl, targets) {
var self = this;
var insertAt = nextEl ? Array.from(self.dom.parent.children).indexOf(nextEl) : self.targets.length;
var insertAt = nextEl ? h.arrayFromList(self.dom.parent.children).indexOf(nextEl) : self.targets.length;

self.dom.parent.insertBefore(frag, nextEl);

Expand Down
26 changes: 23 additions & 3 deletions tests/unit/mixer-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('mixitup.Mixer', () => {

after(() => mixer.destroy());

it('accept `default` as a sort string, but should have no effect on the order', () => {
it('accepts `default` as a sort string, but should have no effect on the order', () => {
var startOrder = mixer.getState().show;

return mixer.sort('default')
Expand All @@ -75,7 +75,7 @@ describe('mixitup.Mixer', () => {
});
});

it('accept `default:asc` as a sort string, but should have no effect on the order', () => {
it('accepts `default:asc` as a sort string, but should have no effect on the order', () => {
var startOrder = mixer.getState().show;

return mixer.sort('default:asc')
Expand All @@ -87,7 +87,7 @@ describe('mixitup.Mixer', () => {
});
});

it('accept `default:desc` as a sort string, which should reverse the order', () => {
it('accepts `default:desc` as a sort string, which should reverse the order', () => {
var reversedOrder = mixer.getState().show.slice().reverse();

return mixer.sort('default:desc')
Expand Down Expand Up @@ -184,6 +184,26 @@ describe('mixitup.Mixer', () => {
});
});

it('should accept a collection of elements by which to sort by', () => {
const firstTarget = mixer.getState().targets[0];
const collection = mixer.getState().targets.slice().reverse();

return mixer.sort(collection)
.then(state => {
const lastTarget = state.targets[state.targets.length - 1];

chai.assert.deepEqual(lastTarget, firstTarget);
});
});

it('should error if any element in the collection provided does not exist in the container', () => {
const mixer = mixitup(container);

const collection = [document.createElement('div')];

chai.assert.throws(() => mixer.sort(collection));
});

it('should accept a callback function which is invoked after sorting', () => {
const promise = new Promise(resolve => mixer.sort('random', resolve));

Expand Down

0 comments on commit 61dac05

Please sign in to comment.