/* * Kendo UI v2011.3.1129 (http://kendoui.com) * Copyright 2011 Telerik AD. All rights reserved. * * Kendo UI commercial licenses may be obtained at http://kendoui.com/license. * If you do not own a commercial license, this file shall be governed by the * GNU General Public License (GPL) version 3. For GPL requirements, please * review: http://www.gnu.org/copyleft/gpl.html */ (function(a,b){function C(a,b,c,d){b?a.delegate(b,c,d):a.bind(c,d)}function B(b,c){try{return a.contains(b,c)||b==c}catch(d){return!1}}function A(b,c){var d={element:[null]};a.each(c,function(){var a=this,c=a.element[0];if(B(c,b)){d=a;return!1}});return d}var c=window.kendo,d=window.document,e=c.ui.Widget,f=a.proxy,g=a.extend,h=c.support.touch,i=c.getOffset,j={},k={},l={element:[null]},m=".kendo-dnd",n="mouseenter",o=h?"touchend":"mouseup",p=h?"touchstart":"mousedown",q=h?"touchmove":"mousemove",r="keydown",s="mouseleave",t="selectstart",u="dragstart",v="dragend",w="drag",x="dragenter",y="dragleave",z="drop",D=e.extend({init:function(a,b){var c=this;e.fn.init.call(c,a,b),c.element.bind(n,f(c._over,c)).bind(o,f(c._drop,c)).bind(s,f(c._out,c)),c.bind([x,y,z],c.options);var d=c.options.group;d in k?k[d].push(c):k[d]=[c]},options:{name:"DropTarget",group:"default"},_trigger:function(a,b){var c=this,d=j[c.options.group];if(d)return c.trigger(a,g({},b,{draggable:d}))},_over:function(a){this._trigger(x,a)},_out:function(a){this._trigger(y,a)},_drop:function(a){var b=this,c=j[b.options.group];c&&(c.dropped=!b._trigger(z,a))}});c.ui.plugin(D);var E=e.extend({init:function(a,b){var c=this;e.fn.init.call(c,a,b),C(c.element,c.options.filter,p+m,f(c._wait,c)),c.bind([u,w,v],c.options),C(c.element,c.options.filter,u+m,!1)},options:{name:"Draggable",distance:5,group:"default",cursorOffset:{left:10,top:h?-40/c.support.zoomLevel():10},dropped:!1},_startDrag:function(b){var e=this,g=e.options.filter;e._offset=c.touchLocation(b),g?e.currentTarget=a(b.target).is(g)?a(b.target):a(b.target).closest(g):e.currentTarget=a(b.currentTarget),a(d).bind(q+m,f(e._start,e)).bind(o+m,f(e._destroy,e))},_wait:function(a){var b=this;a.stopImmediatePropagation(),b._startDrag(a),h||a.preventDefault()},_start:function(b){var e=this,g=c.touchLocation(b),i=g.x,k=g.y,l=e._offset.x-i,n=e._offset.y-k,p=Math.sqrt(l*l+n*n),s=e.options,v=s.cursorOffset,w=s.hint;p>=s.distance&&(h&&b.preventDefault(),w&&(e.hint=a.isFunction(w)?a(w(e.currentTarget)):w,e.hint.css({position:"absolute",zIndex:10010,left:i+v.left,top:k+v.top}).appendTo(d.body)),j[s.group]=e,a(d).unbind(m).bind(o+m+" "+r+m,f(e._stop,e)).bind(q+m,f(e._drag,e)).bind(t+m,!1),e.dropped=!1,e._trigger(u,b)&&e._destroy(b))},_drag:function(a){var b=this,d=b.options.cursorOffset,e=c.touchLocation(a);if(h&&c.size(k)){var f=b.options,g=c.eventTarget(a);if(g){var i=A(g,k[f.group]),j=i.element[0],m=l.element[0],n=m!=j;n&&(m!=null&&l._trigger(y,a),B(j,g)&&i._trigger(x,a),l=i)}}b._trigger(w,a),b.hint&&b.hint.css({left:e.x+d.left,top:e.y+d.top})},_stop:function(a){var b=this,d=f(b._destroy,b),e=i(b.currentTarget);if(a.type==o||a.keyCode==27){if(h&&c.size(k)){var g=b.options,j=c.eventTarget(a);if(j){var m=A(j,k[g.group]);m.element[0]&&(l={element:[null]},m._drop(a))}}b._trigger(v,a),b.hint&&!b.dropped?b.hint.animate(e,"fast",d):d()}},_trigger:function(a,b){var d=this,e=c.touchLocation(b);return d.trigger(a,g({},b,{currentTarget:d.currentTarget,pageX:e.x,pageY:e.y}))},_destroy:function(b){var c=this;c.hint&&c.hint.remove(),delete j[c.options.group],a(d).unbind(m)}});c.ui.plugin(E)})(jQuery)