vtenext/themes/softed/js/arrive.min.js
2021-04-28 20:10:26 +02:00

19 lines
4.8 KiB
JavaScript

/*
* arrive.js
* v2.3.0
* https://github.com/uzairfarooq/arrive
* MIT licensed
*
* Copyright (c) 2014-2015 Uzair Farooq
*/
var Arrive=function(r,n,q){function t(e,a,c){f.addMethod(a,c,e.unbindEvent);f.addMethod(a,c,e.unbindEventWithSelectorOrCallback);f.addMethod(a,c,e.unbindEventWithSelectorAndCallback)}function p(e){e.arrive=k.bindEvent;t(k,e,"unbindArrive");e.leave=h.bindEvent;t(h,e,"unbindLeave")}if(r.MutationObserver&&"undefined"!==typeof HTMLElement){var w=0,f=function(){var e=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector;
return{matchesSelector:function(a,c){return a instanceof HTMLElement&&e.call(a,c)},addMethod:function(a,c,d){var b=a[c];a[c]=function(){if(d.length==arguments.length)return d.apply(this,arguments);if("function"==typeof b)return b.apply(this,arguments)}},callCallbacks:function(a){for(var c=0,d;d=a[c];c++)d.callback.call(d.elem)},checkChildNodesRecursively:function(a,c,d,b){for(var u=0,m;m=a[u];u++)d(m,c,b)&&b.push({callback:c.callback,elem:m}),0<m.childNodes.length&&f.checkChildNodesRecursively(m.childNodes,
c,d,b)},mergeArrays:function(a,c){var d={},b;for(b in a)d[b]=a[b];for(b in c)d[b]=c[b];return d},toElementsArray:function(a){"undefined"===typeof a||"number"===typeof a.length&&a!==r||(a=[a]);return a}}}(),x=function(){var e=function(){this._eventsBucket=[];this._beforeRemoving=this._beforeAdding=null};e.prototype.addEvent=function(a,c,d,b){a={target:a,selector:c,options:d,callback:b,firedElems:[]};this._beforeAdding&&this._beforeAdding(a);this._eventsBucket.push(a);return a};e.prototype.removeEvent=
function(a){for(var c=this._eventsBucket.length-1,d;d=this._eventsBucket[c];c--)a(d)&&(this._beforeRemoving&&this._beforeRemoving(d),this._eventsBucket.splice(c,1))};e.prototype.beforeAdding=function(a){this._beforeAdding=a};e.prototype.beforeRemoving=function(a){this._beforeRemoving=a};return e}(),v=function(e,a){var c=new x,d=this,b={fireOnAttributesModification:!1};c.beforeAdding(function(b){var c=b.target,l;if(c===r.document||c===r)c=document.getElementsByTagName("html")[0];l=new MutationObserver(function(d){a.call(this,
d,b)});var g=e(b.options);l.observe(c,g);b.observer=l;b.me=d});c.beforeRemoving(function(b){b.observer.disconnect()});this.bindEvent=function(d,a,l){a=f.mergeArrays(b,a);for(var g=f.toElementsArray(this),e=0;e<g.length;e++)c.addEvent(g[e],d,a,l)};this.unbindEvent=function(){var b=f.toElementsArray(this);c.removeEvent(function(a){for(var d=0;d<b.length;d++)if(this===q||a.target===b[d])return!0;return!1})};this.unbindEventWithSelectorOrCallback=function(b){var d=f.toElementsArray(this);c.removeEvent("function"===
typeof b?function(a){for(var c=0;c<d.length;c++)if((this===q||a.target===d[c])&&a.callback===b)return!0;return!1}:function(a){for(var c=0;c<d.length;c++)if((this===q||a.target===d[c])&&a.selector===b)return!0;return!1})};this.unbindEventWithSelectorAndCallback=function(b,a){var d=f.toElementsArray(this);c.removeEvent(function(c){for(var e=0;e<d.length;e++)if((this===q||c.target===d[e])&&c.selector===b&&c.callback===a)return!0;return!1})};return this},k=new function(){function e(d,b,a){if(f.matchesSelector(d,
b.selector)&&(d._id===q&&(d._id=w++),-1==b.firedElems.indexOf(d._id))){if(b.options.onceOnly)if(0===b.firedElems.length)b.me.unbindEventWithSelectorAndCallback.call(b.target,b.selector,b.callback);else return;b.firedElems.push(d._id);a.push({callback:b.callback,elem:d})}}var a={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};k=new v(function(a){var b={attributes:!1,childList:!0,subtree:!0};a.fireOnAttributesModification&&(b.attributes=!0);return b},function(a,b){a.forEach(function(a){var d=
a.addedNodes,c=a.target,g=[];null!==d&&0<d.length?f.checkChildNodesRecursively(d,b,e,g):"attributes"===a.type&&e(c,b,g)&&g.push({callback:b.callback,elem:node});f.callCallbacks(g)})});var c=k.bindEvent;k.bindEvent=function(d,b,e){"undefined"===typeof e?(e=b,b=a):b=f.mergeArrays(a,b);var m=f.toElementsArray(this);if(b.existing){for(var l=[],g=0;g<m.length;g++)for(var k=m[g].querySelectorAll(d),h=0;h<k.length;h++)l.push({callback:e,elem:k[h]});if(b.onceOnly&&l.length)return e.call(l[0].elem);f.callCallbacks(l)}c.call(this,
d,b,e)};return k},h=new function(){function e(a,b){return f.matchesSelector(a,b.selector)}var a={};h=new v(function(a){return{childList:!0,subtree:!0}},function(a,b){a.forEach(function(a){a=a.removedNodes;var c=[];null!==a&&0<a.length&&f.checkChildNodesRecursively(a,b,e,c);f.callCallbacks(c)})});var c=h.bindEvent;h.bindEvent=function(d,b,e){"undefined"===typeof e?(e=b,b=a):b=f.mergeArrays(a,b);c.call(this,d,b,e)};return h};n&&p(n.fn);p(HTMLElement.prototype);p(NodeList.prototype);p(HTMLCollection.prototype);
p(HTMLDocument.prototype);p(Window.prototype);n={};t(k,n,"unbindAllArrive");t(h,n,"unbindAllLeave");return n}}(this,"undefined"===typeof jQuery?null:jQuery,void 0);