Cost-Benefit-Projection/media/uikit/js/components/sortable.min.js

2 lines
8.6 KiB
JavaScript
Raw Normal View History

2016-03-18 05:02:23 +00:00
/*! UIkit 2.25.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-sortable",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";function e(e){e=t.$(e);do{if(e.data("sortable"))return e;e=t.$(e).parent()}while(e.length);return e}function o(t,e){var o=t.parentNode;if(e.parentNode!=o)return!1;for(var a=t.previousSibling;a&&9!==a.nodeType;){if(a===e)return!0;a=a.previousSibling}return!1}function a(t,e){var o=e;if(o==t)return null;for(;o;){if(o.parentNode===t)return o;if(o=o.parentNode,!o||!o.ownerDocument||11===o.nodeType)break}return null}function n(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.returnValue=!1}var s,r,i,l,d,h,u,p,c,g,f="ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch;return t.component("sortable",{defaults:{animation:150,threshold:10,childClass:"uk-sortable-item",placeholderClass:"uk-sortable-placeholder",overClass:"uk-sortable-over",draggingClass:"uk-sortable-dragged",dragMovingClass:"uk-sortable-moving",baseClass:"uk-sortable",noDragClass:"uk-sortable-nodrag",emptyClass:"uk-sortable-empty",dragCustomClass:"",handleClass:!1,group:!1,stop:function(){},start:function(){},change:function(){}},boot:function(){t.ready(function(e){t.$("[data-uk-sortable]",e).each(function(){var e=t.$(this);e.data("sortable")||t.sortable(e,t.Utils.options(e.attr("data-uk-sortable")))})}),t.$html.on("mousemove touchmove",function(e){if(u){var o=e.originalEvent.targetTouches?e.originalEvent.targetTouches[0]:e;(Math.abs(o.pageX-u.pos.x)>u.threshold||Math.abs(o.pageY-u.pos.y)>u.threshold)&&u.apply(o)}if(s){d||(d=!0,s.show(),s.$current.addClass(s.$sortable.options.placeholderClass),s.$sortable.element.children().addClass(s.$sortable.options.childClass),t.$html.addClass(s.$sortable.options.dragMovingClass));var a=s.data("mouse-offset"),n=parseInt(e.originalEvent.pageX,10)+a.left,r=parseInt(e.originalEvent.pageY,10)+a.top;if(s.css({left:n,top:r}),r+s.height()/3>document.body.offsetHeight)return;r<t.$win.scrollTop()?t.$win.scrollTop(t.$win.scrollTop()-Math.ceil(s.height()/3)):r+s.height()/3>window.innerHeight+t.$win.scrollTop()&&t.$win.scrollTop(t.$win.scrollTop()+Math.ceil(s.height()/3))}}),t.$html.on("mouseup touchend",function(t){if(u=h=!1,!r||!s)return r=s=null,void 0;var o=e(r),a=s.$sortable,n={type:t.type};o[0]&&a.dragDrop(n,a.element),a.dragEnd(n,a.element)})},init:function(){function e(){f?h.addEventListener("touchmove",b,!1):(h.addEventListener("mouseover",m,!1),h.addEventListener("mouseout",v,!1))}function o(){f?h.removeEventListener("touchmove",b,!1):(h.removeEventListener("mouseover",m,!1),h.removeEventListener("mouseout",v,!1))}function s(t){r&&d.dragMove(t,d)}function l(e){return function(o){var n,s,r;o&&(n=f&&o.touches&&o.touches[0]||{},s=n.target||o.target,f&&document.elementFromPoint&&(s=document.elementFromPoint(o.pageX-document.body.scrollLeft,o.pageY-document.body.scrollTop)),g=t.$(s)),t.$(s).hasClass(d.options.childClass)?e.apply(s,[o]):s!==h&&(r=a(h,s),r&&e.apply(r,[o]))}}var d=this,h=this.element[0];p=[],this.checkEmptyList(),this.element.data("sortable-group",this.options.group?this.options.group:t.Utils.uid("sortable-group"));var u=l(function(e){if(!e.data||!e.data.sortable){var o=t.$(e.target),a=o.is("a[href]")?o:o.parents("a[href]");if(!o.is(":input"))return e.preventDefault(),!f&&a.length&&a.one("click",function(t){t.preventDefault()}).one("mouseup",function(){c||a.trigger("click")}),e.data=e.data||{},e.data.sortable=h,d.dragStart(e,this)}}),m=l(t.Utils.debounce(function(t){return d.dragEnter(t,this)}),40),v=l(function(){var e=d.dragenterData(this);d.dragenterData(this,e-1),d.dragenterData(this)||(t.$(this).removeClass(d.options.overClass),d.dragenterData(this,!1))}),b=l(function(t){return r&&r!==this&&i!==this?(d.element.children().removeClass(d.options.overClass),i=this,d.moveElementNextTo(r,this),n(t)):!0});this.addDragHandlers=e,this.removeDragHandlers=o,window.addEventListener(f?"touchmove":"mousemove",s,!1),h.addEventListener(f?"touchstart":"mousedown",u,!1)},dragStart:function(e,o){c=!1,d=