UNPKG

apex4x

Version:

The Comprehensive ARIA Development Suite

7 lines 14.5 kB
/*@license Dragula https://github.com/bevacqua/dragula Author: Nicolas Bevacqua License: MIT (https://opensource.org/licenses/MIT) Includes modifications by Bryan Garaventa (WhatSock.com) for use within the Apex 4X ARIA Drag module. */ !function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).dragula=e()}(function(){return function o(r,i,u){function c(n,e){if(!i[n]){if(!r[n]){var t="function"==typeof require&&require;if(!e&&t)return t(n,!0);if(a)return a(n,!0);throw(e=new Error("Cannot find module '"+n+"'")).code="MODULE_NOT_FOUND",e}t=i[n]={exports:{}},r[n][0].call(t.exports,function(e){return c(r[n][1][e]||e)},t,t.exports,o,r,i,u)}return i[n].exports}for(var a="function"==typeof require&&require,e=0;e<u.length;e++)c(u[e]);return c}({1:[function(e,n,t){var o={},r="(?:^|\\s)",i="(?:\\s|$)";function u(e){var n=o[e];return n?n.lastIndex=0:o[e]=n=new RegExp(r+e+i,"g"),n}n.exports={add:function(e,n){var t=e.className;t.length?u(n).test(t)||(e.className+=" "+n):e.className=n},rm:function(e,n){e.className=e.className.replace(u(n)," ").trim()}}},{}],2:[function(t,o,e){!function(r){var M=t("contra/emitter"),k=t("crossvent"),R=t("./classes"),j=document,q=j.documentElement,e=!1;try{var n={get passive(){return!(e=!0)}};window.addEventListener("test",null,n),window.removeEventListener("test",null,n)}catch(e){}var U=!0;function K(e,n,t,o){r.navigator.pointerEnabled?k[n](e,{mouseup:"pointerup",mousedown:"pointerdown",mousemove:"pointermove"}[t],o):r.navigator.msPointerEnabled?k[n](e,{mouseup:"MSPointerUp",mousedown:"MSPointerDown",mousemove:"MSPointerMove"}[t],o):(k[n](e,{mouseup:"touchend",mousedown:"touchstart",mousemove:"touchmove"}[t],o),k[n](e,t,o))}function $(e){return void 0!==e.touches?e.touches.length:void 0!==e.which&&0!==e.which?e.which:void 0!==e.buttons?e.buttons:void 0!==(e=e.button)?1&e?1:2&e?3:4&e?2:0:void 0}function z(e,n){return void 0!==r[n]?r[n]:(q.clientHeight?q:j.body)[e]}function H(e,n,t){var o=(e=e||{}).className||"";return e.className+=" gu-hide",n=j.elementFromPoint(n,t),e.className=o,n}function V(){return!1}function G(){return!0}function J(e){return e.width||e.right-e.left}function Q(e){return e.height||e.bottom-e.top}function W(e){return e.parentNode===j?null:e.parentNode}function Z(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName||"SELECT"===e.tagName||function e(n){if(!n)return!1;if("false"===n.contentEditable)return!1;if("true"===n.contentEditable)return!0;return e(W(n))}(e)}function ee(n){return n.nextElementSibling||function(){var e=n;for(;e=e.nextSibling,e&&1!==e.nodeType;);return e}()}function ne(e,n){var n=(n=n).targetTouches&&n.targetTouches.length?n.targetTouches[0]:n.changedTouches&&n.changedTouches.length?n.changedTouches[0]:n,t={pageX:"clientX",pageY:"clientY"};return n[e=e in t&&!(e in n)&&t[e]in n?t[e]:e]}j.addEventListener("touchmove",function(e){U||e.preventDefault()},!!e&&{passive:!1}),o.exports=function(e,n){1===arguments.length&&!1===Array.isArray(e)&&(n=e,e=[]);var l,f,s,d,m,o,r,p,v,h,t,i,g=null,y=n||{},w=(void 0===y.moves&&(y.moves=G),void 0===y.accepts&&(y.accepts=G),void 0===y.invalid&&(y.invalid=function(){return!1}),void 0===y.containers&&(y.containers=e||[]),void 0===y.isContainer&&(y.isContainer=V),void 0===y.copy&&(y.copy=!1),void 0===y.copySortSource&&(y.copySortSource=!1),void 0===y.revertOnSpill&&(y.revertOnSpill=!1),void 0===y.removeOnSpill&&(y.removeOnSpill=!1),void 0===y.direction&&(y.direction="vertical"),void 0===y.ignoreInputTextSelection&&(y.ignoreInputTextSelection=!0),void 0===y.mirrorContainer&&(y.mirrorContainer=j.body),M({containers:y.containers,start:function(e){e=E(e);e&&x(e)},end:C,cancel:_,remove:N,destroy:function(){c(!0),O({})},canMove:function(e){return!!E(e)},dragging:!1}));return!0===y.removeOnSpill&&w.on("over",function(e){R.rm(e,"gu-hide")}).on("out",function(e){w.dragging&&R.add(e,"gu-hide")}),c(),w.on("drag",function(e,n){U=!1}).on("dragend",function(e){U=!0}),w;function u(e){return-1!==w.containers.indexOf(e)||y.isContainer(e)}function c(e){e=e?"remove":"add";K(q,e,"mousedown",P),K(q,e,"mouseup",O)}function a(e){K(q,e?"remove":"add","mousemove",F)}function b(e){e=e?"remove":"add";k[e](q,"selectstart",T),k[e](q,"click",T)}function T(e){i&&e.preventDefault()}function P(e){var n,t;o=e.clientX,r=e.clientY,1!==$(e)||e.metaKey||e.ctrlKey||(t=E(n=e.target))&&(i=t,a(),"mousedown"===e.type)&&(Z(n)?n.focus():e.preventDefault())}function F(e){if(i)if(0===$(e))O({});else if(!(void 0!==e.clientX&&Math.abs(e.clientX-o)<=(y.slideFactorX||0)&&void 0!==e.clientY&&Math.abs(e.clientY-r)<=(y.slideFactorY||0))){if(y.ignoreInputTextSelection){var n=ne("clientX",e)||0,t=ne("clientY",e)||0;if(Z(j.elementFromPoint(n,t)))return}var n=i,t=(a(!0),b(),C(),x(n),function(e){e=e.getBoundingClientRect();return{left:e.left+z("scrollLeft","pageXOffset"),top:e.top+z("scrollTop","pageYOffset")}}(s));d=ne("pageX",e)-t.left,m=ne("pageY",e)-t.top,R.add(h||s,"gu-transit"),l||(n=s.getBoundingClientRect(),w.emit("beforeClone",s),(l=s.cloneNode(!0)).style.width=J(n)+"px",l.style.height=Q(n)+"px",R.rm(l,"gu-transit"),R.add(l,"gu-mirror"),y.mirrorContainer.appendChild(l),K(q,"add","mousemove",A),R.add(y.mirrorContainer,"gu-unselectable"),w.emit("cloned",l,s,"mirror")),A(e)}}function E(e){if(!(w.dragging&&l||u(e))){for(var n=e;W(e)&&!1===u(W(e));){if(y.invalid(e,n))return;if(!(e=W(e)))return}var t=W(e);if(t)if(!y.invalid(e,n))if(y.moves(e,t,n,ee(e)))return{item:e,source:t}}}function x(e){var n,t;n=e.item,t=e.source,("boolean"==typeof y.copy?y.copy:y.copy(n,t))&&(w.emit("beforeClone",e.item),h=e.item.cloneNode(!0),w.emit("cloned",h,e.item,"copy")),f=e.source,s=e.item,p=v=ee(e.item),w.dragging=!0,w.emit("drag",s,f)}function C(){var e;w.dragging&&I(e=h||s,W(e))}function S(){a(!(i=!1)),b(!0)}function O(e){var n,t;S(),w.dragging&&(n=h||s,t=ne("clientX",e)||0,e=ne("clientY",e)||0,(t=Y(H(l,t,e),t,e))&&(h&&y.copySortSource||!h||t!==f)?I(n,t):(y.removeOnSpill?N:_)())}function I(e,n){var t=W(e);h&&y.copySortSource&&n===f&&t.removeChild(s),X(n)?w.emit("cancel",e,f,f):w.emit("drop",e,n,f,v),L()}function N(){var e,n;w.dragging&&((n=W(e=h||s))&&n.removeChild(e),w.emit(h?"cancel":"remove",e,n,f),L())}function _(e){var n,t,o;w.dragging&&(e=0<arguments.length?e:y.revertOnSpill,!1===(o=X(t=W(n=h||s)))&&e&&(h?t&&t.removeChild(h):f.insertBefore(n,p)),o||e?w.emit("cancel",n,f,f):w.emit("drop",n,t,f,v),L())}function L(){var e=h||s;S(),l&&(R.rm(y.mirrorContainer,"gu-unselectable"),K(q,"remove","mousemove",A),W(l).removeChild(l),l=null),e&&R.rm(e,"gu-transit"),t&&clearTimeout(t),w.dragging=!1,g&&w.emit("out",e,g,f),w.emit("dragend",e),f=s=h=p=v=t=g=null}function X(e,n){n=void 0!==n?n:l?v:ee(h||s);return e===f&&n===p}function Y(n,t,o){for(var r=n;r&&!function(){if(!1===u(r))return;var e=B(r,n),e=D(r,e,t,o);if(X(r,e))return 1;return y.accepts(s,r,f,e)}();)r=W(r);return r}function A(e){if(l){e.preventDefault();var n=ne("clientX",e)||0,e=ne("clientY",e)||0,t=n-d,o=e-m,r=(l.style.left=t+"px",l.style.top=o+"px",l.getBoundingClientRect()),i=((r.y<o-2||r.y>2+o||r.x<t-2||r.x>2+t)&&(t+=t-r.x,o+=o-r.y,l.style.left=t+"px",l.style.top=o+"px"),h||s),r=H(l,n,e),t=Y(r,n,e),o=null!==t&&t!==g,u=((o||null===t)&&(g&&a("out"),g=t,o)&&a("over"),W(i));if(t===f&&h&&!y.copySortSource)u&&u.removeChild(i);else{var c,r=B(t,r);if(null!==r)c=D(t,r,n,e);else{if(!0!==y.revertOnSpill||h)return void(h&&u&&u.removeChild(i));c=p,t=f}(null===c&&o||c!==i&&c!==ee(i))&&(v=c,t.insertBefore(i,c),w.emit("shadow",i,t,f))}}function a(e){w.emit(e,i,g,f)}}function B(e,n){for(var t=n;t!==e&&W(t)!==e;)t=W(t);return t===q?null:t}function D(r,n,i,u){var c="horizontal"===y.direction;return(n!==r?function(){var e=n.getBoundingClientRect();if(c)return t(i>e.left+J(e)/2);return t(u>e.top+Q(e)/2)}:function(){var e,n,t,o=r.children.length;for(e=0;e<o;e++){if(n=r.children[e],t=n.getBoundingClientRect(),c&&t.left+t.width/2>i)return n;if(!c&&t.top+t.height/2>u)return n}return null})();function t(e){return e?ee(n):n}}}}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./classes":1,"contra/emitter":5,crossvent:6}],3:[function(e,n,t){n.exports=function(e,n){return Array.prototype.slice.call(e,n)}},{}],4:[function(e,n,t){var o=e("ticky");n.exports=function(e,n,t){e&&o(function(){e.apply(t||null,n||[])})}},{ticky:10}],5:[function(e,n,t){var c=e("atoa"),a=e("./debounce");n.exports=function(r,e){var i=e||{},u={};return(r=void 0===r?{}:r).on=function(e,n){return u[e]?u[e].push(n):u[e]=[n],r},r.once=function(e,n){return n._once=!0,r.on(e,n),r},r.off=function(e,n){var t=arguments.length;if(1===t)delete u[e];else if(0===t)u={};else{t=u[e];if(!t)return r;t.splice(t.indexOf(n),1)}return r},r.emit=function(){var e=c(arguments);return r.emitterSnapshot(e.shift()).apply(this,e)},r.emitterSnapshot=function(o){var e=(u[o]||[]).slice(0);return function(){var n=c(arguments),t=this||r;if("error"!==o||!1===i.throws||e.length)return e.forEach(function(e){i.async?a(e,n,t):e.apply(t,n),e._once&&r.off(o,e)}),r;throw 1===n.length?n[0]:n}},r}},{"./debounce":4,atoa:3}],6:[function(t,l,e){!function(r){var o=t("custom-event"),i=t("./eventmap"),u=r.document,e=function(e,n,t,o){return e.addEventListener(n,t,o)},n=function(e,n,t,o){return e.removeEventListener(n,t,o)},c=[];function a(e,n,t){e=function(e,n,t){var o,r;for(o=0;o<c.length;o++)if((r=c[o]).element===e&&r.type===n&&r.fn===t)return o}(e,n,t);if(e)return n=c[e].wrapper,c.splice(e,1),n}r.addEventListener||(e=function(e,n,t){return e.attachEvent("on"+n,function(e,n,t){var o=a(e,n,t)||function(t,o){return function(e){var n=e||r.event;n.target=n.target||n.srcElement,n.preventDefault=n.preventDefault||function(){n.returnValue=!1},n.stopPropagation=n.stopPropagation||function(){n.cancelBubble=!0},n.which=n.which||n.keyCode,o.call(t,n)}}(e,t);return c.push({wrapper:o,element:e,type:n,fn:t}),o}(e,n,t))},n=function(e,n,t){t=a(e,n,t);if(t)return e.detachEvent("on"+n,t)}),l.exports={add:e,remove:n,fabricate:function(e,n,t){t=-1===i.indexOf(n)?new o(n,{detail:t}):function(){var e;u.createEvent?(e=u.createEvent("Event")).initEvent(n,!0,!0):u.createEventObject&&(e=u.createEventObject());return e}();e.dispatchEvent?e.dispatchEvent(t):e.fireEvent("on"+n,t)}}}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./eventmap":7,"custom-event":8}],7:[function(e,r,n){!function(e){var n=[],t="",o=/^on/;for(t in e)o.test(t)&&n.push(t.slice(2));r.exports=n}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(e,t,n){!function(e){var n=e.CustomEvent;t.exports=function(){try{var e=new n("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}}()?n:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(e,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=Boolean(n.bubbles),t.cancelable=Boolean(n.cancelable),t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(e,n,t){var o,r,n=n.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}try{o="function"==typeof setTimeout?setTimeout:i}catch(e){o=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(e){r=u}function c(n){if(o===setTimeout)return setTimeout(n,0);if((o===i||!o)&&setTimeout)return(o=setTimeout)(n,0);try{return o(n,0)}catch(e){try{return o.call(null,n,0)}catch(e){return o.call(this,n,0)}}}var a,l=[],f=!1,s=-1;function d(){f&&a&&(f=!1,a.length?l=a.concat(l):s=-1,l.length)&&m()}function m(){if(!f){for(var e=c(d),n=(f=!0,l.length);n;){for(a=l,l=[];++s<n;)a&&a[s].run();s=-1,n=l.length}a=null,f=!1,!function(n){if(r===clearTimeout)return clearTimeout(n);if((r===u||!r)&&clearTimeout)return(r=clearTimeout)(n);try{r(n)}catch(e){try{return r.call(null,n)}catch(e){return r.call(this,n)}}}(e)}}function p(e,n){this.fun=e,this.array=n}function v(){}n.nextTick=function(e){var n=new Array(arguments.length-1);if(1<arguments.length)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];l.push(new p(e,n)),1!==l.length||f||c(m)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=v,n.addListener=v,n.once=v,n.off=v,n.removeListener=v,n.removeAllListeners=v,n.emit=v,n.prependListener=v,n.prependOnceListener=v,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},{}],10:[function(e,t,n){!function(n){var e="function"==typeof n?function(e){n(e)}:function(e){setTimeout(e,0)};t.exports=e}.call(this,e("timers").setImmediate)},{timers:11}],11:[function(a,e,l){!function(e,n){var o=a("process/browser.js").nextTick,t=Function.prototype.apply,r=Array.prototype.slice,i={},u=0;function c(e,n){this._id=e,this._clearFn=n}l.setTimeout=function(){return new c(t.call(setTimeout,window,arguments),clearTimeout)},l.setInterval=function(){return new c(t.call(setInterval,window,arguments),clearInterval)},l.clearTimeout=l.clearInterval=function(e){e.close()},c.prototype.unref=c.prototype.ref=function(){},c.prototype.close=function(){this._clearFn.call(window,this._id)},l.enroll=function(e,n){clearTimeout(e._idleTimeoutId),e._idleTimeout=n},l.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},l._unrefActive=l.active=function(e){clearTimeout(e._idleTimeoutId);var n=e._idleTimeout;0<=n&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},n))},l.setImmediate="function"==typeof e?e:function(e){var n=u++,t=!(arguments.length<2)&&r.call(arguments,1);return i[n]=!0,o(function(){i[n]&&(t?e.apply(null,t):e.call(null),l.clearImmediate(n))}),n},l.clearImmediate="function"==typeof n?n:function(e){delete i[e]}}.call(this,a("timers").setImmediate,a("timers").clearImmediate)},{"process/browser.js":9,timers:11}]},{},[2])(2)}),$A.extend({dragula:window.dragula});