forked from bevacqua/dragula
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdragula.min.js
1 lines (1 loc) · 7.29 KB
/
dragula.min.js
1
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.dragula=e()}}(function(){return function e(n,t,r){function o(u,c){if(!t[u]){if(!n[u]){var a="function"==typeof require&&require;if(!c&&a)return a(u,!0);if(i)return i(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var l=t[u]={exports:{}};n[u][0].call(l.exports,function(e){var t=n[u][1][e];return o(t?t:e)},l,l.exports,e,n,t,r)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,n){"use strict";function t(e,n){function t(n){function t(e){s[r](e,"mousedown",m),s[r](e,"touchstart",m)}var r=n?"remove":"add";s[r](v,"mouseup",g),s[r](v,"touchend",g),e.forEach(t)}function d(){t(!0),g({})}function m(n){if(!(0!==n.which&&1!==n.which||n.metaKey||n.ctrlKey||B)){var t=n.target;if(-1===e.indexOf(t)){for(;-1===e.indexOf(t.parentElement);){if(h(t))return;t=t.parentElement}if(!h(t)){var o=t.parentElement,i=P.moves(t,o);if(i){var a=r(t);n.preventDefault(),P.copy?(A=t.cloneNode(!0),c(A,"gu-transit")):c(t,"gu-transit"),_=o,j=t,k=q=u(t),D=f("pageX",n)-a.left,R=f("pageY",n)-a.top,U.emit("drag",j,_),N(),O(n)}}}}}function h(e){return"A"===e.tagName||"BUTTON"===e.tagName}function g(e){function n(){x(c)?U.emit("cancel",t,_):U.emit("drop",t,c,_),w()}if(B){var t=A||j,r=f("clientX",e),i=f("clientY",e),u=o(L,r,i),c=b(u,r,i);!c||P.copy!==!1&&c===_?P.removeOnSpill?y():E():n()}}function y(){if(B){var e=A||j,n=e.parentElement;n&&n.removeChild(e),U.emit(P.copy?"cancel":"remove",e,n),w()}}function E(e){if(B){var n=arguments.length>0?e:P.revertOnSpill,t=A||j,r=t.parentElement;r===_&&P.copy&&r.removeChild(A);var o=x(r);o===!1&&P.copy===!1&&n&&_.insertBefore(t,k),o||n?U.emit("cancel",t,_):U.emit("drop",t,r,_),w()}}function w(){var e=A||j;T(),a(e,"gu-transit"),_=j=A=k=q=null}function x(e,n){var t=void 0!==n?n:q;return e===_&&t===k}function b(n,t,r){function o(){var o=-1!==e.indexOf(i);if(o===!1)return!1;var u=S(i,n),c=C(i,u,t,r),a=x(i,c);return a?!0:P.accepts(j,i,_)}for(var i=n;i&&!o();)i=i.parentElement;return i}function O(e){var n=f("clientX",e),t=f("clientY",e),r=n-D,i=t-R;L.style.left=r+"px",L.style.top=i+"px";var c=o(L,n,t),a=b(c,n,t);if(a!==_||!P.copy){var l=A||j,s=S(a,c);if(null!==s){var p=C(a,s,n,t);(null===p||p!==l&&p!==u(l))&&(q=p,a.insertBefore(l,p),U.emit("shadow",l,a))}}}function N(){var e=j.getBoundingClientRect();B=!0,L=j.cloneNode(!0),L.style.width=e.width+"px",L.style.height=e.height+"px",a(L,"gu-transit"),c(L," gu-mirror"),p.appendChild(L),s.add(v,"mousemove",O),s.add(v,"touchmove",O),c(p,"gu-unselectable")}function T(){L&&(a(p,"gu-unselectable"),s.remove(v,"mousemove",O),s.remove(v,"touchmove",O),L.parentElement.removeChild(L),L=null,B=!1)}function S(e,n){for(var t=n;t!==e&&t.parentElement!==e;)t=t.parentElement;return t===v?null:t}function C(e,n,t,r){function o(){var n,o,i,u=e.children.length;for(n=0;u>n;n++){if(o=e.children[n],i=o.getBoundingClientRect(),a&&i.left>t)return o;if(!a&&i.top>r)return o}return null}function i(){var e=n.getBoundingClientRect();return c(a?t>e.left+e.width/2:r>e.top+e.height/2)}function c(e){return e?u(n):n}var a="horizontal"===P.direction,f=n!==e?i():o();return f}var B,L,_,j,D,R,k,q,A,P=n||{};void 0===P.moves&&(P.moves=i),void 0===P.accepts&&(P.accepts=i),void 0===P.copy&&(P.copy=!1),void 0===P.revertOnSpill&&(P.revertOnSpill=!1),void 0===P.removeOnSpill&&(P.removeOnSpill=!1),void 0===P.direction&&(P.direction="vertical");var U=l({cancel:E,remove:y,destroy:d});return t(),U}function r(e){var n=e.getBoundingClientRect();return{left:n.left+p.scrollLeft,top:n.top+p.scrollTop}}function o(e,n,t){if(!n&&!t)return null;var r=e.className;e.className+=" gu-hide";var o=document.elementFromPoint(n,t);return e.className=r,o}function i(){return!0}function u(e){function n(){var n=e;do n=n.nextSibling;while(n&&1!==n.nodeType);return n}return e.nextElementSibling||n()}function c(e,n){-1===e.className.indexOf(" "+n)&&(e.className+=" "+n)}function a(e,n){e.className=e.className.replace(new RegExp(" "+n,"g"),"")}function f(e,n){return"undefined"==typeof n.targetTouches?n[e]:n.targetTouches&&n.targetTouches.length&&n.targetTouches[0][e]||0}var l=e("contra.emitter"),s=e("crossvent"),p=document.body,v=document.documentElement;n.exports=t},{"contra.emitter":3,crossvent:5}],2:[function(e,n){function t(){if(!u){u=!0;for(var e,n=i.length;n;){e=i,i=[];for(var t=-1;++t<n;)e[t]();n=i.length}u=!1}}function r(){}var o=n.exports={},i=[],u=!1;o.nextTick=function(e){i.push(e),u||setTimeout(t,0)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=r,o.addListener=r,o.once=r,o.off=r,o.removeListener=r,o.removeAllListeners=r,o.emit=r,o.binding=function(){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}],3:[function(e,n){n.exports=e("./src/contra.emitter.js")},{"./src/contra.emitter.js":4}],4:[function(e,n){(function(e){!function(t,r){"use strict";function o(e,n){return Array.prototype.slice.call(e,n)}function i(e,n,t){e&&c(function(){e.apply(t||null,n||[])})}function u(e,n){var t=n||{},u={};return e===r&&(e={}),e.on=function(n,t){return u[n]?u[n].push(t):u[n]=[t],e},e.once=function(n,t){return t._once=!0,e.on(n,t),e},e.off=function(n,t){var r=arguments.length;if(1===r)delete u[n];else if(0===r)u={};else{var o=u[n];if(!o)return e;o.splice(o.indexOf(t),1)}return e},e.emit=function(){var n=o(arguments);return e.emitterSnapshot(n.shift()).apply(this,n)},e.emitterSnapshot=function(n){var r=(u[n]||[]).slice(0);return function(){var c=o(arguments),a=this||e;if("error"===n&&t["throws"]!==!1&&!r.length)throw 1===c.length?c[0]:c;return u[n]=r.filter(function(e){return t.async?i(e,c,a):e.apply(a,c),!e._once}),e}},e}var c,a=""+r,f="function"==typeof setImmediate;c=f?function(e){setImmediate(e)}:typeof e!==a&&e.nextTick?e.nextTick:function(e){setTimeout(e,0)},typeof n!==a&&n.exports?n.exports=u:(t.contra=t.contra||{},t.contra.emitter=u)}(this)}).call(this,e("_process"))},{_process:2}],5:[function(e,n){(function(e){"use strict";function t(e,n,t,r){return e.addEventListener(n,t,r)}function r(e,n,t){return e.attachEvent("on"+n,a(e,n,t))}function o(e,n,t,r){return e.removeEventListener(n,t,r)}function i(e,n,t){return e.detachEvent("on"+n,f(e,n,t))}function u(e,n){var t;s.createEvent?(t=s.createEvent("Event"),t.initEvent(n,!0,!0),e.dispatchEvent(t)):s.createEventObject&&(t=s.createEventObject(),e.fireEvent("on"+n,t))}function c(n,t,r){return function(t){var o=t||e.event;o.target=o.target||o.srcElement,o.preventDefault=o.preventDefault||function(){o.returnValue=!1},o.stopPropagation=o.stopPropagation||function(){o.cancelBubble=!0},r.call(n,o)}}function a(e,n,t){var r=f(e,n,t)||c(e,n,t);return d.push({wrapper:r,element:e,type:n,fn:t}),r}function f(e,n,t){var r=l(e,n,t);if(r){var o=d[r].wrapper;return d.splice(r,1),o}}function l(e,n,t){var r,o;for(r=0;r<d.length;r++)if(o=d[r],o.element===e&&o.type===n&&o.fn===t)return r}var s=document,p=t,v=o,d=[];e.addEventListener||(p=r,v=i),n.exports={add:p,remove:v,fabricate:u}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)});