kendo.sortable.min.js 10.7 KB
/** 
 * Kendo UI v2016.1.112 (http://www.telerik.com/kendo-ui)                                                                                                                                               
 * Copyright 2016 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.sortable.min",["kendo.draganddrop.min"],e)}(function(){return function(e,t){function n(t,n){try{return e.contains(t,n)||t==n}catch(r){return!1}}function r(e){return e.clone()}function i(e){return e.clone().removeAttr("id").css("visibility","hidden")}var o=window.kendo,s=o.ui.Widget,l="start",a="beforeMove",h="move",d="end",c="change",u="cancel",g="sort",f="remove",p="receive",m=">*",_=-1,v=s.extend({init:function(e,t){var n=this;s.fn.init.call(n,e,t),n.options.placeholder||(n.options.placeholder=i),n.options.hint||(n.options.hint=r),n.draggable=n._createDraggable()},events:[l,a,h,d,c,u],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(),s.fn.destroy.call(this)},_createDraggable:function(){var t=this,n=t.element,r=t.options;return new o.ui.Draggable(n,{filter:r.filter,hint:o.isFunction(r.hint)?r.hint:e(r.hint),holdToDrag:r.holdToDrag,container:r.container?e(r.container):null,cursorOffset:r.cursorOffset,axis:r.axis,ignore:r.ignore,autoScroll:r.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,r=this.options.disabled,i=this.options.handler,s=this.options.placeholder,a=this.placeholder=e(o.isFunction(s)?s.call(this,n):s);r&&n.is(r)?t.preventDefault():i&&!e(t.initialTarget).is(i)?t.preventDefault():this.trigger(l,{item:n,draggableEvent:t})?t.preventDefault():(n.css("display","none"),n.before(a),this._setCursor())},_dragcancel:function(){this._cancel(),this.trigger(u,{item:this.draggedElement}),this._resetCursor()},_drag:function(n){var r,i,o,s,l,a=this.draggedElement,h=this._findTarget(n),d={left:n.x.location,top:n.y.location},c={x:n.x.delta,y:n.y.delta},u=this.options.axis,g=this.options.moveOnDragEnter,f={item:a,list:this,draggableEvent:n};if("x"===u||"y"===u)return this._movementByAxis(u,d,c[u],f),t;if(h){if(r=this._getElementCenter(h.element),i={left:Math.round(d.left-r.left),top:Math.round(d.top-r.top)},e.extend(f,{target:h.element}),h.appendToBottom)return this._movePlaceholder(h,null,f),t;if(h.appendAfterHidden&&this._movePlaceholder(h,"next",f),this._isFloating(h.element)?0>c.x&&(g||0>i.left)?o="prev":c.x>0&&(g||i.left>0)&&(o="next"):0>c.y&&(g||0>i.top)?o="prev":c.y>0&&(g||i.top>0)&&(o="next"),o){for(l="prev"===o?jQuery.fn.prev:jQuery.fn.next,s=l.call(h.element);s.length&&!s.is(":visible");)s=l.call(s);s[0]!=this.placeholder[0]&&this._movePlaceholder(h,o,f)}}},_dragend:function(n){var r,i,o,s,l=this.placeholder,a=this.draggedElement,h=this.indexOf(a),u=this.indexOf(l),m=this.options.connectWith;return this._resetCursor(),o={action:g,item:a,oldIndex:h,newIndex:u,draggableEvent:n},u>=0?i=this.trigger(d,o):(r=l.parents(m).getKendoSortable(),o.action=f,s=e.extend({},o,{action:p,oldIndex:_,newIndex:r.indexOf(l)}),i=!(!this.trigger(d,o)&&!r.trigger(d,s))),i||u===h?(this._cancel(),t):(l.replaceWith(a),a.show(),this.draggable.dropped=!0,o={action:this.indexOf(a)!=_?g:f,item:a,oldIndex:h,newIndex:this.indexOf(a),draggableEvent:n},this.trigger(c,o),r&&(s=e.extend({},o,{action:p,oldIndex:_,newIndex:r.indexOf(a)}),r.trigger(c,s)),t)},_findTarget:function(n){var r,i,o=this._findElementUnderCursor(n),s=this.options.connectWith;return e.contains(this.element[0],o)?(r=this.items(),i=r.filter(o)[0]||r.has(o)[0],i?{element:e(i),sortable:this}:null):this.element[0]==o&&this._isEmpty()?{element:this.element,sortable:this,appendToBottom:!0}:this.element[0]==o&&this._isLastHidden()?(i=this.items().eq(0),{element:i,sortable:this,appendAfterHidden:!0}):s?this._searchConnectedTargets(o,n):t},_findElementUnderCursor:function(e){var t=o.elementUnderCursor(e),r=e.sender;return n(r.hint[0],t)&&(r.hint.hide(),t=o.elementUnderCursor(e),t||(t=o.elementUnderCursor(e)),r.hint.show()),t},_searchConnectedTargets:function(t,n){var r,i,o,s,l=e(this.options.connectWith);for(s=0;l.length>s;s++)if(r=l.eq(s).getKendoSortable(),e.contains(l[s],t)){if(r)return i=r.items(),o=i.filter(t)[0]||i.has(t)[0],o?(r.placeholder=this.placeholder,{element:e(o),sortable:r}):null}else if(l[s]==t){if(r&&r._isEmpty())return{element:l.eq(s),sortable:r,appendToBottom:!0};if(this._isCursorAfterLast(r,n))return o=r.items().last(),{element:o,sortable:r}}},_isCursorAfterLast:function(e,t){var n,r,i=e.items().last(),s={left:t.x.location,top:t.y.location};return n=o.getOffset(i),n.top+=i.outerHeight(),n.left+=i.outerWidth(),r=this._isFloating(i)?n.left-s.left:n.top-s.top,0>r?!0:!1},_movementByAxis:function(t,n,r,i){var o,s="x"===t?n.left:n.top,l=0>r?this.placeholder.prev():this.placeholder.next();l.length&&!l.is(":visible")&&(l=0>r?l.prev():l.next()),e.extend(i,{target:l}),o=this._getElementCenter(l),o&&(o="x"===t?o.left:o.top),l.length&&0>r&&0>s-o?this._movePlaceholder({element:l,sortable:this},"prev",i):l.length&&r>0&&s-o>0&&this._movePlaceholder({element:l,sortable:this},"next",i)},_movePlaceholder:function(e,t,n){var r=this.placeholder;e.sortable.trigger(a,n)||(t?"prev"===t?e.element.before(r):"next"===t&&e.element.after(r):e.element.append(r),e.sortable.trigger(h,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?o.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,r=this.draggedElement;return n&&e[0]==n[0]?t.not(r).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")}});o.ui.plugin(v)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t,n){(n||t)()});
//# sourceMappingURL=kendo.sortable.min.js.map