Permalink
Browse files

v3.3.1

  • Loading branch information...
patrickkunka committed Oct 1, 2018
1 parent a4c474e commit 61dac0554ab2b69fca3c927a173b0a000e4f6896
Showing with 93 additions and 22 deletions.
  1. +5 −0 CHANGELOG.md
  2. +1 −1 demos/filtering-by-url/index.html
  3. +4 −4 demos/mixitup.min.js
  4. +29 −6 dist/mixitup.js
  5. +4 −4 dist/mixitup.min.js
  6. +1 −1 package.json
  7. +3 −0 src/messages.js
  8. +23 −3 src/mixer.js
  9. +23 −3 tests/unit/mixer-sort.js
@@ -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.
@@ -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

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -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.
@@ -5766,7 +5766,11 @@
*/
sortOperation: function(operation) {
var self = this;
var self = this,
newOrder = [],
target = null,
el = null,
i = -1;
self.callActions('beforeSortOperation', arguments);
@@ -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
@@ -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);
@@ -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
----------------------------------------------------------------------------- */
@@ -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);

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -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/",
@@ -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
----------------------------------------------------------------------------- */
@@ -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);
@@ -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
@@ -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);
@@ -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')
@@ -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')
@@ -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')
@@ -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));

0 comments on commit 61dac05

Please sign in to comment.