EOS/Scripts/kendo/2015.3.1111/kendo.draganddrop.min.js
Nidhi Bhargava f0c1ab20e1 code push
2025-09-04 16:25:07 +05:30

9 lines
13 KiB
JavaScript

/*
* Kendo UI v2015.3.1111 (http://www.telerik.com/kendo-ui)
* Copyright 2015 Telerik AD. All rights reserved.
*
* Kendo UI commercial licenses may be obtained at
* http://www.telerik.com/purchase/license-agreement/kendo-ui-complete
* If you do not own a commercial license, this file shall be governed by the trial license terms.
*/
!function(e,define){define(["./kendo.core.min","./kendo.userevents.min"],e)}(function(){return function(e,t){function n(t,n){try{return e.contains(t,n)||t==n}catch(i){return!1}}function i(e,t){return parseInt(e.css(t),10)||0}function o(e,t){return Math.min(Math.max(e,t.min),t.max)}function r(e,t){var n=D(e),o=n.left+i(e,"borderLeftWidth")+i(e,"paddingLeft"),r=n.top+i(e,"borderTopWidth")+i(e,"paddingTop"),s=o+e.width()-t.outerWidth(!0),a=r+e.height()-t.outerHeight(!0);return{x:{min:o,max:s},y:{min:r,max:a}}}function s(n,i,o){for(var r,s,a=0,l=i&&i.length,c=o&&o.length;n&&n.parentNode;){for(a=0;l>a;a++)if(r=i[a],r.element[0]===n)return{target:r,targetElement:n};for(a=0;c>a;a++)if(s=o[a],e.contains(s.element[0],n)&&w.matchesSelector.call(n,s.options.filter))return{target:s,targetElement:n};n=n.parentNode}return t}function a(e,t){var n,i=t.options.group,o=e[i];if(k.fn.destroy.call(t),o.length>1){for(n=0;o.length>n;n++)if(o[n]==t){o.splice(n,1);break}}else o.length=0,delete e[i]}function l(e){var t,n,i,o=c()[0];return e[0]===o?(n=o.scrollTop,i=o.scrollLeft,{top:n,left:i,bottom:n+b.height(),right:i+b.width()}):(t=e.offset(),t.bottom=t.top+e.height(),t.right=t.left+e.width(),t)}function c(){return e(_.support.browser.chrome?y.body:y.documentElement)}function h(t){var n,i=c();if(!t||t===y.body||t===y.documentElement)return i;for(n=e(t)[0];!_.isScrollable(n)&&n!==y.body;)n=n.parentNode;return n===y.body?i:e(n)}function u(e,t,n){var i={x:0,y:0},o=50;return o>e-n.left?i.x=-(o-(e-n.left)):o>n.right-e&&(i.x=o-(n.right-e)),o>t-n.top?i.y=-(o-(t-n.top)):o>n.bottom-t&&(i.y=o-(n.bottom-t)),i}var d,f,p,g,m,v,_=window.kendo,w=_.support,y=window.document,b=e(window),x=_.Class,k=_.ui.Widget,C=_.Observable,S=_.UserEvents,T=e.proxy,A=e.extend,D=_.getOffset,M={},P={},E={},I=_.elementUnderCursor,B="keyup",R="change",z="dragstart",L="hold",F="drag",O="dragend",N="dragcancel",V="hintDestroyed",H="dragenter",U="dragleave",j="drop",W=C.extend({init:function(t,n){var i=this,o=t[0];i.capture=!1,o.addEventListener?(e.each(_.eventMap.down.split(" "),function(){o.addEventListener(this,T(i._press,i),!0)}),e.each(_.eventMap.up.split(" "),function(){o.addEventListener(this,T(i._release,i),!0)})):(e.each(_.eventMap.down.split(" "),function(){o.attachEvent(this,T(i._press,i))}),e.each(_.eventMap.up.split(" "),function(){o.attachEvent(this,T(i._release,i))})),C.fn.init.call(i),i.bind(["press","release"],n||{})},captureNext:function(){this.capture=!0},cancelCapture:function(){this.capture=!1},_press:function(e){var t=this;t.trigger("press"),t.capture&&e.preventDefault()},_release:function(e){var t=this;t.trigger("release"),t.capture&&(e.preventDefault(),t.cancelCapture())}}),G=C.extend({init:function(t){var n=this;C.fn.init.call(n),n.forcedEnabled=!1,e.extend(n,t),n.scale=1,n.horizontal?(n.measure="offsetWidth",n.scrollSize="scrollWidth",n.axis="x"):(n.measure="offsetHeight",n.scrollSize="scrollHeight",n.axis="y")},makeVirtual:function(){e.extend(this,{virtual:!0,forcedEnabled:!0,_virtualMin:0,_virtualMax:0})},virtualSize:function(e,t){(this._virtualMin!==e||this._virtualMax!==t)&&(this._virtualMin=e,this._virtualMax=t,this.update())},outOfBounds:function(e){return e>this.max||this.min>e},forceEnabled:function(){this.forcedEnabled=!0},getSize:function(){return this.container[0][this.measure]},getTotal:function(){return this.element[0][this.scrollSize]},rescale:function(e){this.scale=e},update:function(e){var t=this,n=t.virtual?t._virtualMax:t.getTotal(),i=n*t.scale,o=t.getSize();(0!==n||t.forcedEnabled)&&(t.max=t.virtual?-t._virtualMin:0,t.size=o,t.total=i,t.min=Math.min(t.max,o-i),t.minScale=o/n,t.centerOffset=(i-o)/2,t.enabled=t.forcedEnabled||i>o,e||t.trigger(R,t))}}),q=C.extend({init:function(e){var t=this;C.fn.init.call(t),t.x=new G(A({horizontal:!0},e)),t.y=new G(A({horizontal:!1},e)),t.container=e.container,t.forcedMinScale=e.minScale,t.maxScale=e.maxScale||100,t.bind(R,e)},rescale:function(e){this.x.rescale(e),this.y.rescale(e),this.refresh()},centerCoordinates:function(){return{x:Math.min(0,-this.x.centerOffset),y:Math.min(0,-this.y.centerOffset)}},refresh:function(){var e=this;e.x.update(),e.y.update(),e.enabled=e.x.enabled||e.y.enabled,e.minScale=e.forcedMinScale||Math.min(e.x.minScale,e.y.minScale),e.fitScale=Math.max(e.x.minScale,e.y.minScale),e.trigger(R)}}),$=C.extend({init:function(e){var t=this;A(t,e),C.fn.init.call(t)},outOfBounds:function(){return this.dimension.outOfBounds(this.movable[this.axis])},dragMove:function(e){var t=this,n=t.dimension,i=t.axis,o=t.movable,r=o[i]+e;n.enabled&&((n.min>r&&0>e||r>n.max&&e>0)&&(e*=t.resistance),o.translateAxis(i,e),t.trigger(R,t))}}),Y=x.extend({init:function(t){var n,i,o,r,s=this;A(s,{elastic:!0},t),o=s.elastic?.5:0,r=s.movable,s.x=n=new $({axis:"x",dimension:s.dimensions.x,resistance:o,movable:r}),s.y=i=new $({axis:"y",dimension:s.dimensions.y,resistance:o,movable:r}),s.userEvents.bind(["press","move","end","gesturestart","gesturechange"],{gesturestart:function(e){s.gesture=e,s.offset=s.dimensions.container.offset()},press:function(t){e(t.event.target).closest("a").is("[data-navigate-on-press=true]")&&t.sender.cancel()},gesturechange:function(e){var t,o,a,l=s.gesture,c=l.center,h=e.center,u=e.distance/l.distance,d=s.dimensions.minScale,f=s.dimensions.maxScale;d>=r.scale&&1>u&&(u+=.8*(1-u)),r.scale*u>=f&&(u=f/r.scale),o=r.x+s.offset.left,a=r.y+s.offset.top,t={x:(o-c.x)*u+h.x-o,y:(a-c.y)*u+h.y-a},r.scaleWith(u),n.dragMove(t.x),i.dragMove(t.y),s.dimensions.rescale(r.scale),s.gesture=e,e.preventDefault()},move:function(e){e.event.target.tagName.match(/textarea|input/i)||(n.dimension.enabled||i.dimension.enabled?(n.dragMove(e.x.delta),i.dragMove(e.y.delta),e.preventDefault()):e.touch.skip())},end:function(e){e.preventDefault()}})}}),Q=w.transitions.prefix+"Transform";f=w.hasHW3D?function(e,t,n){return"translate3d("+e+"px,"+t+"px,0) scale("+n+")"}:function(e,t,n){return"translate("+e+"px,"+t+"px) scale("+n+")"},p=C.extend({init:function(t){var n=this;C.fn.init.call(n),n.element=e(t),n.element[0].style.webkitTransformOrigin="left top",n.x=0,n.y=0,n.scale=1,n._saveCoordinates(f(n.x,n.y,n.scale))},translateAxis:function(e,t){this[e]+=t,this.refresh()},scaleTo:function(e){this.scale=e,this.refresh()},scaleWith:function(e){this.scale*=e,this.refresh()},translate:function(e){this.x+=e.x,this.y+=e.y,this.refresh()},moveAxis:function(e,t){this[e]=t,this.refresh()},moveTo:function(e){A(this,e),this.refresh()},refresh:function(){var e,t=this,n=t.x,i=t.y;t.round&&(n=Math.round(n),i=Math.round(i)),e=f(n,i,t.scale),e!=t.coordinates&&(_.support.browser.msie&&10>_.support.browser.version?(t.element[0].style.position="absolute",t.element[0].style.left=t.x+"px",t.element[0].style.top=t.y+"px"):t.element[0].style[Q]=e,t._saveCoordinates(e),t.trigger(R))},_saveCoordinates:function(e){this.coordinates=e}}),g=k.extend({init:function(e,t){var n,i=this;k.fn.init.call(i,e,t),n=i.options.group,n in P?P[n].push(i):P[n]=[i]},events:[H,U,j],options:{name:"DropTarget",group:"default"},destroy:function(){a(P,this)},_trigger:function(e,n){var i=this,o=M[i.options.group];return o?i.trigger(e,A({},n.event,{draggable:o,dropTarget:n.dropTarget})):t},_over:function(e){this._trigger(H,e)},_out:function(e){this._trigger(U,e)},_drop:function(e){var t=this,n=M[t.options.group];n&&(n.dropped=!t._trigger(j,e))}}),g.destroyGroup=function(e){var t,n=P[e]||E[e];if(n){for(t=0;n.length>t;t++)k.fn.destroy.call(n[t]);n.length=0,delete P[e],delete E[e]}},g._cache=P,m=g.extend({init:function(e,t){var n,i=this;k.fn.init.call(i,e,t),n=i.options.group,n in E?E[n].push(i):E[n]=[i]},destroy:function(){a(E,this)},options:{name:"DropTargetArea",group:"default",filter:null}}),v=k.extend({init:function(e,t){var n=this;k.fn.init.call(n,e,t),n._activated=!1,n.userEvents=new S(n.element,{global:!0,allowSelection:!0,filter:n.options.filter,threshold:n.options.distance,start:T(n._start,n),hold:T(n._hold,n),move:T(n._drag,n),end:T(n._end,n),cancel:T(n._cancel,n),select:T(n._select,n)}),n._afterEndHandler=T(n._afterEnd,n),n._captureEscape=T(n._captureEscape,n)},events:[L,z,F,O,N,V],options:{name:"Draggable",distance:_.support.touch?0:5,group:"default",cursorOffset:null,axis:null,container:null,filter:null,ignore:null,holdToDrag:!1,autoScroll:!1,dropped:!1},cancelHold:function(){this._activated=!1},_captureEscape:function(e){var t=this;e.keyCode===_.keys.ESC&&(t._trigger(N,{event:e}),t.userEvents.cancel())},_updateHint:function(t){var n,i=this,r=i.options,s=i.boundaries,a=r.axis,l=i.options.cursorOffset;l?n={left:t.x.location+l.left,top:t.y.location+l.top}:(i.hintOffset.left+=t.x.delta,i.hintOffset.top+=t.y.delta,n=e.extend({},i.hintOffset)),s&&(n.top=o(n.top,s.y),n.left=o(n.left,s.x)),"x"===a?delete n.top:"y"===a&&delete n.left,i.hint.css(n)},_shouldIgnoreTarget:function(t){var n=this.options.ignore;return n&&e(t).is(n)},_select:function(e){this._shouldIgnoreTarget(e.event.target)||e.preventDefault()},_start:function(n){var i,o=this,s=o.options,a=s.container,l=s.hint;return this._shouldIgnoreTarget(n.touch.initialTouch)||s.holdToDrag&&!o._activated?(o.userEvents.cancel(),t):(o.currentTarget=n.target,o.currentTargetOffset=D(o.currentTarget),l&&(o.hint&&o.hint.stop(!0,!0).remove(),o.hint=_.isFunction(l)?e(l.call(o,o.currentTarget)):l,i=D(o.currentTarget),o.hintOffset=i,o.hint.css({position:"absolute",zIndex:2e4,left:i.left,top:i.top}).appendTo(y.body),o.angular("compile",function(){o.hint.removeAttr("ng-repeat");for(var t=e(n.target);!t.data("$$kendoScope")&&t.length;)t=t.parent();return{elements:o.hint.get(),scopeFrom:t.data("$$kendoScope")}})),M[s.group]=o,o.dropped=!1,a&&(o.boundaries=r(a,o.hint)),e(y).on(B,o._captureEscape),o._trigger(z,n)&&(o.userEvents.cancel(),o._afterEnd()),o.userEvents.capture(),t)},_hold:function(e){this.currentTarget=e.target,this._trigger(L,e)?this.userEvents.cancel():this._activated=!0},_drag:function(n){var i,o,r=this;n.preventDefault(),i=this._elementUnderCursor(n),r._withDropTarget(i,function(i,o){if(!i)return d&&(d._trigger(U,A(n,{dropTarget:e(d.targetElement)})),d=null),t;if(d){if(o===d.targetElement)return;d._trigger(U,A(n,{dropTarget:e(d.targetElement)}))}i._trigger(H,A(n,{dropTarget:e(o)})),d=A(i,{targetElement:o})}),r._trigger(F,A(n,{dropTarget:d,elementUnderCursor:i})),this.options.autoScroll&&(this._cursorElement!==i&&(this._scrollableParent=h(i),this._cursorElement=i),this._scrollableParent[0]&&(o=u(n.x.location,n.y.location,l(this._scrollableParent)),this._scrollCompenstation=e.extend({},this.hintOffset),this._scrollVelocity=o,0===o.y&&0===o.x?(clearInterval(this._scrollInterval),this._scrollInterval=null):this._scrollInterval||(this._scrollInterval=setInterval(e.proxy(this,"_autoScroll"),50)))),r.hint&&r._updateHint(n)},_autoScroll:function(){var e,t,n,i,o,r,s,a=this._scrollableParent[0],l=this._scrollVelocity,h=this._scrollCompenstation;a&&(n=a===c()[0],n?(e=y.body.scrollHeight>b.height(),t=y.body.scrollWidth>b.width()):(e=a.scrollHeight>=a.offsetHeight,t=a.scrollWidth>=a.offsetWidth),i=a.scrollTop+l.y,o=e&&i>0&&a.scrollHeight>i,r=a.scrollLeft+l.x,s=t&&r>0&&a.scrollWidth>r,o&&(a.scrollTop+=l.y),s&&(a.scrollLeft+=l.x),n&&(s||o)&&(o&&(h.top+=l.y),s&&(h.left+=l.x),this.hint.css(h)))},_end:function(t){this._withDropTarget(this._elementUnderCursor(t),function(n,i){n&&(n._drop(A({},t,{dropTarget:e(i)})),d=null)}),this._cancel(this._trigger(O,t))},_cancel:function(e){var t=this;t._scrollableParent=null,this._cursorElement=null,clearInterval(this._scrollInterval),t._activated=!1,t.hint&&!t.dropped?setTimeout(function(){t.hint.stop(!0,!0),e?t._afterEndHandler():t.hint.animate(t.currentTargetOffset,"fast",t._afterEndHandler)},0):t._afterEnd()},_trigger:function(e,t){var n=this;return n.trigger(e,A({},t.event,{x:t.x,y:t.y,currentTarget:n.currentTarget,initialTarget:t.touch?t.touch.initialTouch:null,dropTarget:t.dropTarget,elementUnderCursor:t.elementUnderCursor}))},_elementUnderCursor:function(e){var t=I(e),i=this.hint;return i&&n(i[0],t)&&(i.hide(),t=I(e),t||(t=I(e)),i.show()),t},_withDropTarget:function(e,t){var n,i=this.options.group,o=P[i],r=E[i];(o&&o.length||r&&r.length)&&(n=s(e,o,r),n?t(n.target,n.targetElement):t())},destroy:function(){var e=this;k.fn.destroy.call(e),e._afterEnd(),e.userEvents.destroy(),this._scrollableParent=null,this._cursorElement=null,clearInterval(this._scrollInterval),e.currentTarget=null},_afterEnd:function(){var t=this;t.hint&&t.hint.remove(),delete M[t.options.group],t.trigger("destroy"),t.trigger(V),e(y).off(B,t._captureEscape)}}),_.ui.plugin(g),_.ui.plugin(m),_.ui.plugin(v),_.TapCapture=W,_.containerBoundaries=r,A(_.ui,{Pane:Y,PaneDimensions:q,Movable:p}),_.ui.Draggable.utils={autoScrollVelocity:u,scrollableViewPort:l,findScrollableParent:h}}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});