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

9 lines
6.8 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.draganddrop.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){return e.clone()}function o(e){return e.clone().removeAttr("id").css("visibility","hidden")}var r=window.kendo,a=r.ui.Widget,s="start",l="beforeMove",c="move",u="end",d="change",h="cancel",f="sort",p="remove",g="receive",m=">*",v=-1,_=a.extend({init:function(e,t){var n=this;a.fn.init.call(n,e,t),n.options.placeholder||(n.options.placeholder=o),n.options.hint||(n.options.hint=i),n.draggable=n._createDraggable()},events:[s,l,c,u,d,h],options:{name:"Sortable",hint:null,placeholder:null,filter:m,holdToDrag:!1,disabled:null,container:null,connectWith:null,handler:null,cursorOffset:null,axis:null,ignore:null,autoScroll:!1,cursor:"auto",moveOnDragEnter:!1},destroy:function(){this.draggable.destroy(),a.fn.destroy.call(this)},_createDraggable:function(){var t=this,n=t.element,i=t.options;return new r.ui.Draggable(n,{filter:i.filter,hint:r.isFunction(i.hint)?i.hint:e(i.hint),holdToDrag:i.holdToDrag,container:i.container?e(i.container):null,cursorOffset:i.cursorOffset,axis:i.axis,ignore:i.ignore,autoScroll:i.autoScroll,dragstart:e.proxy(t._dragstart,t),dragcancel:e.proxy(t._dragcancel,t),drag:e.proxy(t._drag,t),dragend:e.proxy(t._dragend,t)})},_dragstart:function(t){var n=this.draggedElement=t.currentTarget,i=this.options.disabled,o=this.options.handler,a=this.options.placeholder,l=this.placeholder=e(r.isFunction(a)?a.call(this,n):a);i&&n.is(i)?t.preventDefault():o&&!e(t.initialTarget).is(o)?t.preventDefault():this.trigger(s,{item:n,draggableEvent:t})?t.preventDefault():(n.css("display","none"),n.before(l),this._setCursor())},_dragcancel:function(){this._cancel(),this.trigger(h,{item:this.draggedElement}),this._resetCursor()},_drag:function(n){var i,o,r,a,s,l=this.draggedElement,c=this._findTarget(n),u={left:n.x.location,top:n.y.location},d={x:n.x.delta,y:n.y.delta},h=this.options.axis,f=this.options.moveOnDragEnter,p={item:l,list:this,draggableEvent:n};if("x"===h||"y"===h)return this._movementByAxis(h,u,d[h],p),t;if(c){if(i=this._getElementCenter(c.element),o={left:Math.round(u.left-i.left),top:Math.round(u.top-i.top)},e.extend(p,{target:c.element}),c.appendToBottom)return this._movePlaceholder(c,null,p),t;if(c.appendAfterHidden&&this._movePlaceholder(c,"next",p),this._isFloating(c.element)?0>d.x&&(f||0>o.left)?r="prev":d.x>0&&(f||o.left>0)&&(r="next"):0>d.y&&(f||0>o.top)?r="prev":d.y>0&&(f||o.top>0)&&(r="next"),r){for(s="prev"===r?jQuery.fn.prev:jQuery.fn.next,a=s.call(c.element);a.length&&!a.is(":visible");)a=s.call(a);a[0]!=this.placeholder[0]&&this._movePlaceholder(c,r,p)}}},_dragend:function(n){var i,o,r,a,s=this.placeholder,l=this.draggedElement,c=this.indexOf(l),h=this.indexOf(s),m=this.options.connectWith;return this._resetCursor(),r={action:f,item:l,oldIndex:c,newIndex:h,draggableEvent:n},h>=0?o=this.trigger(u,r):(i=s.parents(m).getKendoSortable(),r.action=p,a=e.extend({},r,{action:g,oldIndex:v,newIndex:i.indexOf(s)}),o=!(!this.trigger(u,r)&&!i.trigger(u,a))),o||h===c?(this._cancel(),t):(s.replaceWith(l),l.show(),this.draggable.dropped=!0,r={action:this.indexOf(l)!=v?f:p,item:l,oldIndex:c,newIndex:this.indexOf(l),draggableEvent:n},this.trigger(d,r),i&&(a=e.extend({},r,{action:g,oldIndex:v,newIndex:i.indexOf(l)}),i.trigger(d,a)),t)},_findTarget:function(n){var i,o,r=this._findElementUnderCursor(n),a=this.options.connectWith;return e.contains(this.element[0],r)?(i=this.items(),o=i.filter(r)[0]||i.has(r)[0],o?{element:e(o),sortable:this}:null):this.element[0]==r&&this._isEmpty()?{element:this.element,sortable:this,appendToBottom:!0}:this.element[0]==r&&this._isLastHidden()?(o=this.items().eq(0),{element:o,sortable:this,appendAfterHidden:!0}):a?this._searchConnectedTargets(r,n):t},_findElementUnderCursor:function(e){var t=r.elementUnderCursor(e),i=e.sender;return n(i.hint[0],t)&&(i.hint.hide(),t=r.elementUnderCursor(e),t||(t=r.elementUnderCursor(e)),i.hint.show()),t},_searchConnectedTargets:function(t,n){var i,o,r,a,s=e(this.options.connectWith);for(a=0;s.length>a;a++)if(i=s.eq(a).getKendoSortable(),e.contains(s[a],t)){if(i)return o=i.items(),r=o.filter(t)[0]||o.has(t)[0],r?(i.placeholder=this.placeholder,{element:e(r),sortable:i}):null}else if(s[a]==t){if(i&&i._isEmpty())return{element:s.eq(a),sortable:i,appendToBottom:!0};if(this._isCursorAfterLast(i,n))return r=i.items().last(),{element:r,sortable:i}}},_isCursorAfterLast:function(e,t){var n,i,o=e.items().last(),a={left:t.x.location,top:t.y.location};return n=r.getOffset(o),n.top+=o.outerHeight(),n.left+=o.outerWidth(),i=this._isFloating(o)?n.left-a.left:n.top-a.top,0>i?!0:!1},_movementByAxis:function(t,n,i,o){var r,a="x"===t?n.left:n.top,s=0>i?this.placeholder.prev():this.placeholder.next();s.length&&!s.is(":visible")&&(s=0>i?s.prev():s.next()),e.extend(o,{target:s}),r=this._getElementCenter(s),r&&(r="x"===t?r.left:r.top),s.length&&0>i&&0>a-r?this._movePlaceholder({element:s,sortable:this},"prev",o):s.length&&i>0&&a-r>0&&this._movePlaceholder({element:s,sortable:this},"next",o)},_movePlaceholder:function(e,t,n){var i=this.placeholder;e.sortable.trigger(l,n)||(t?"prev"===t?e.element.before(i):"next"===t&&e.element.after(i):e.element.append(i),e.sortable.trigger(c,n))},_setCursor:function(){var t,n=this.options.cursor;n&&"auto"!==n&&(t=e(document.body),this._originalCursorType=t.css("cursor"),t.css({cursor:n}),this._cursorStylesheet||(this._cursorStylesheet=e("<style>* { cursor: "+n+" !important; }</style>")),this._cursorStylesheet.appendTo(t))},_resetCursor:function(){this._originalCursorType&&(e(document.body).css("cursor",this._originalCursorType),this._originalCursorType=null,this._cursorStylesheet.remove())},_getElementCenter:function(e){var t=e.length?r.getOffset(e):null;return t&&(t.top+=e.outerHeight()/2,t.left+=e.outerWidth()/2),t},_isFloating:function(e){return/left|right/.test(e.css("float"))||/inline|table-cell/.test(e.css("display"))},_cancel:function(){this.draggedElement.show(),this.placeholder.remove()},_items:function(){var e,t=this.options.filter;return e=t?this.element.find(t):this.element.children()},indexOf:function(e){var t=this._items(),n=this.placeholder,i=this.draggedElement;return n&&e[0]==n[0]?t.not(i).index(e):t.not(n).index(e)},items:function(){var e=this.placeholder,t=this._items();return e&&(t=t.not(e)),t},_isEmpty:function(){return!this.items().length},_isLastHidden:function(){return 1===this.items().length&&this.items().is(":hidden")}});r.ui.plugin(_)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});