Skip to content

Commit

Permalink
3.1.3 work
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Kunka committed Dec 19, 2016
1 parent 83bf6d9 commit 5d7af21
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 106 deletions.
135 changes: 81 additions & 54 deletions dist/mixitup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**!
* MixItUp v3.1.2
* MixItUp v3.1.3
* A high-performance, dependency-free library for animated filtering, sorting and more
* Build 8db25e3d-698e-4c92-9857-72cb05b80ed1
* Build 77da8fe0-b52d-4313-bdfc-2b5eb8b683b8
*
* @copyright Copyright 2014-2016 KunkaLabs Limited.
* @author KunkaLabs Limited.
Expand All @@ -17,9 +17,9 @@
(function(window) {
'use strict';

var mixitup = null,
h = null,
jq = null;
var mixitup = null,
h = null,
jq = null;

(function() {
var VENDORS = ['webkit', 'moz', 'o', 'ms'],
Expand Down Expand Up @@ -430,6 +430,8 @@
*/

mixitup.use = function(extension) {
mixitup.Base.prototype.callActions.call(mixitup, 'beforeUse', arguments);

// Call the extension's factory function, passing
// the mixitup factory as a paramater

Expand All @@ -450,6 +452,8 @@

mixitup.registerJqPlugin(extension);
}

mixitup.Base.prototype.callActions.call(mixitup, 'afterUse', arguments);
};

/**
Expand Down Expand Up @@ -3582,9 +3586,11 @@
* var mixer = mixitup(containerEl, {
* render: {
* target: function(item) {
* return '<div class="mix">' +
* '<h2>' + item.title + '</h2>' +
* '</div>';
* return (
* '<div class="mix">' +
* '<h2>' + item.title + '</h2>' +
* '</div>'
* );
* }
* }
* });
Expand All @@ -3594,9 +3600,11 @@
* var mixer = mixitup(containerEl, {
* render: {
* target: function(item) {
* return `<div class="mix">
* <h2>${item.title}</h2>
* </div>`;
* return (
* `<div class="mix">
* <h2>${item.title}</h2>
* </div>`
* );
* }
* }
* });
Expand Down Expand Up @@ -7554,28 +7562,30 @@
if (self.config.data.dirtyCheck && !h.deepEquals(data, target.data)) {
// change detected

el = self.renderTarget(data);
el = target.render(data);

target.data = data;

target.unbindEvents();
if (el !== target.dom.el) {
target.unbindEvents();

self.dom.parent.replaceChild(el, target.dom.el);
self.dom.parent.replaceChild(el, target.dom.el);

target.dom.el = el;
target.dom.el = el;

target.bindEvents();
target.bindEvents();
}
}

el = target.dom.el;
} else {
// New target

el = el = self.renderTarget(data);

target = new mixitup.Target();

target.init(el, self, data);
target.init(null, self, data);

target.hide();
}

if (!target.isInDom) {
Expand All @@ -7591,7 +7601,7 @@
frag.appendChild(self.dom.document.createTextNode(' '));
}

frag.appendChild(el);
frag.appendChild(target.dom.el);

target.isInDom = true;

Expand Down Expand Up @@ -7654,36 +7664,6 @@
self.callActions('afterDiffDatasets', arguments);
},

/**
* @private
* @instance
* @since 3.0.0
* @param {object} data
* @return {void}
*/

renderTarget: function(data) {
var self = this,
render = null,
el = null,
temp = document.createElement('div'),
html = '';

self.callActions('beforeRenderTarget', arguments);

if (typeof (render = self.config.render.target) !== 'function') {
throw new TypeError(mixitup.messages.errorDatasetRendererNotSet());
}

html = render(data);

temp.innerHTML = html;

el = temp.firstElementChild;

return self.callFilters('elRenderTarget', el, arguments);
},

/**
* @private
* @instance
Expand Down Expand Up @@ -9138,9 +9118,9 @@
* @private
* @instance
* @since 3.0.0
* @param {Element} el
* @param {object} mixer
* @param {object} [data]
* @param {(Element|null)} el
* @param {object} mixer
* @param {object} [data]
* @return {void}
*/

Expand All @@ -9152,6 +9132,12 @@

self.mixer = mixer;

if (!el) {
// If no element is provided, render it

el = self.render(data);
}

self.cacheDom(el);

self.bindEvents();
Expand All @@ -9176,6 +9162,45 @@
self.callActions('afterInit', arguments);
},

/**
* Renders the target element using a user-defined renderer function.
*
* @private
* @instance
* @since 3.1.3
* @param {object} data
* @return {void}
*/

render: function(data) {
var self = this,
render = null,
el = null,
temp = null,
output = '';

self.callActions('beforeRender', arguments);

render = self.callFilters('renderRender', self.mixer.config.render.target, arguments);

if (typeof render !== 'function') {
throw new TypeError(mixitup.messages.errorDatasetRendererNotSet());
}

output = render(data);

if (output && typeof output === 'object' && h.isElement(output)) {
el = output;
} else if (typeof output === 'string') {
temp = document.createElement('div');
temp.innerHTML = output;

el = temp.firstElementChild;
}

return self.callFilters('elRender', el, arguments);
},

/**
* Caches references of DOM elements neccessary for the target's functionality.
*
Expand Down Expand Up @@ -10375,6 +10400,8 @@
if ((jq = window.$ || window.jQuery) && jq.fn.jquery) {
mixitup.registerJqPlugin(jq);
}
mixitup.BaseStatic.call(mixitup.constructor);

mixitup.NAME = 'mixitup';
mixitup.CORE_VERSION = '3.1.2';
mixitup.CORE_VERSION = '3.1.3';
})(window);
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.1.2",
"version": "3.1.3",
"description": "A high-performance, dependency-free library for animated filtering, sorting and more",
"author": "KunkaLabs Limited",
"homepage": "https://www.kunkalabs.com/mixitup/",
Expand Down
16 changes: 10 additions & 6 deletions src/config-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ mixitup.ConfigRender = function() {
* var mixer = mixitup(containerEl, {
* render: {
* target: function(item) {
* return '<div class="mix">' +
* '<h2>' + item.title + '</h2>' +
* '</div>';
* return (
* '<div class="mix">' +
* '<h2>' + item.title + '</h2>' +
* '</div>'
* );
* }
* }
* });
Expand All @@ -43,9 +45,11 @@ mixitup.ConfigRender = function() {
* var mixer = mixitup(containerEl, {
* render: {
* target: function(item) {
* return `<div class="mix">
* <h2>${item.title}</h2>
* </div>`;
* return (
* `<div class="mix">
* <h2>${item.title}</h2>
* </div>`
* );
* }
* }
* });
Expand Down
4 changes: 4 additions & 0 deletions src/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ mixitup = function(container, config, foreignDoc) {
*/

mixitup.use = function(extension) {
mixitup.Base.prototype.callActions.call(mixitup, 'beforeUse', arguments);

// Call the extension's factory function, passing
// the mixitup factory as a paramater

Expand All @@ -191,6 +193,8 @@ mixitup.use = function(extension) {

mixitup.registerJqPlugin(extension);
}

mixitup.Base.prototype.callActions.call(mixitup, 'afterUse', arguments);
};

/**
Expand Down
50 changes: 11 additions & 39 deletions src/mixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2694,28 +2694,30 @@ h.extend(mixitup.Mixer.prototype,
if (self.config.data.dirtyCheck && !h.deepEquals(data, target.data)) {
// change detected

el = self.renderTarget(data);
el = target.render(data);

target.data = data;

target.unbindEvents();
if (el !== target.dom.el) {
target.unbindEvents();

self.dom.parent.replaceChild(el, target.dom.el);
self.dom.parent.replaceChild(el, target.dom.el);

target.dom.el = el;
target.dom.el = el;

target.bindEvents();
target.bindEvents();
}
}

el = target.dom.el;
} else {
// New target

el = el = self.renderTarget(data);

target = new mixitup.Target();

target.init(el, self, data);
target.init(null, self, data);

target.hide();
}

if (!target.isInDom) {
Expand All @@ -2731,7 +2733,7 @@ h.extend(mixitup.Mixer.prototype,
frag.appendChild(self.dom.document.createTextNode(' '));
}

frag.appendChild(el);
frag.appendChild(target.dom.el);

target.isInDom = true;

Expand Down Expand Up @@ -2794,36 +2796,6 @@ h.extend(mixitup.Mixer.prototype,
self.callActions('afterDiffDatasets', arguments);
},

/**
* @private
* @instance
* @since 3.0.0
* @param {object} data
* @return {void}
*/

renderTarget: function(data) {
var self = this,
render = null,
el = null,
temp = document.createElement('div'),
html = '';

self.callActions('beforeRenderTarget', arguments);

if (typeof (render = self.config.render.target) !== 'function') {
throw new TypeError(mixitup.messages.errorDatasetRendererNotSet());
}

html = render(data);

temp.innerHTML = html;

el = temp.firstElementChild;

return self.callFilters('elRenderTarget', el, arguments);
},

/**
* @private
* @instance
Expand Down

0 comments on commit 5d7af21

Please sign in to comment.