(function(d){d.widget("ui.droppable",{widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect"},_create:function(){var a=this.options,b=a.accept;this.isover=0;this.isout=1;this.accept=d.isFunction(b)?b:function(a){return a.is(b)};this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight};d.ui.ddmanager.droppables[a.scope]=d.ui.ddmanager.droppables[a.scope]||[];d.ui.ddmanager.droppables[a.scope].push(this);
a.addClasses&&this.element.addClass("ui-droppable")},destroy:function(){for(var a=d.ui.ddmanager.droppables[this.options.scope],b=0;b<a.length;b++)a[b]==this&&a.splice(b,1);return this.element.removeClass("ui-droppable ui-droppable-disabled").removeData("droppable").unbind(".droppable"),this},_setOption:function(a,b){"accept"==a&&(this.accept=d.isFunction(b)?b:function(a){return a.is(b)});d.Widget.prototype._setOption.apply(this,arguments)},_activate:function(a){var b=d.ui.ddmanager.current;this.options.activeClass&&
this.element.addClass(this.options.activeClass);b&&this._trigger("activate",a,this.ui(b))},_deactivate:function(a){var b=d.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass);b&&this._trigger("deactivate",a,this.ui(b))},_over:function(a){var b=d.ui.ddmanager.current;if(b&&(b.currentItem||b.element)[0]!=this.element[0])this.accept.call(this.element[0],b.currentItem||b.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",
a,this.ui(b)))},_out:function(a){var b=d.ui.ddmanager.current;if(b&&(b.currentItem||b.element)[0]!=this.element[0])this.accept.call(this.element[0],b.currentItem||b.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",a,this.ui(b)))},_drop:function(a,b){var c=b||d.ui.ddmanager.current;if(!c||(c.currentItem||c.element)[0]==this.element[0])return!1;var e=!1;return this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var a=
d.data(this,"droppable");if(a.options.greedy&&!a.options.disabled&&a.options.scope==c.options.scope&&a.accept.call(a.element[0],c.currentItem||c.element)&&d.ui.intersect(c,d.extend(a,{offset:a.element.offset()}),a.options.tolerance))return e=!0,!1}),e?!1:this.accept.call(this.element[0],c.currentItem||c.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",a,this.ui(c)),
this.element):!1},ui:function(a){return{draggable:a.currentItem||a.element,helper:a.helper,position:a.position,offset:a.positionAbs}}});d.extend(d.ui.droppable,{version:"1.8.23"});d.ui.intersect=function(a,b,c){if(!b.offset)return!1;var e=(a.positionAbs||a.position.absolute).left,g=e+a.helperProportions.width,f=(a.positionAbs||a.position.absolute).top,h=f+a.helperProportions.height,i=b.offset.left,k=i+b.proportions.width,j=b.offset.top,l=j+b.proportions.height;switch(c){case "fit":return i<=e&&g<=
k&&j<=f&&h<=l;case "intersect":return i<e+a.helperProportions.width/2&&g-a.helperProportions.width/2<k&&j<f+a.helperProportions.height/2&&h-a.helperProportions.height/2<l;case "pointer":return d.ui.isOver((a.positionAbs||a.position.absolute).top+(a.clickOffset||a.offset.click).top,(a.positionAbs||a.position.absolute).left+(a.clickOffset||a.offset.click).left,j,i,b.proportions.height,b.proportions.width);case "touch":return(f>=j&&f<=l||h>=j&&h<=l||f<j&&h>l)&&(e>=i&&e<=k||g>=i&&g<=k||e<i&&g>k);default:return!1}};
d.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,b){var c=d.ui.ddmanager.droppables[a.options.scope]||[],e=b?b.type:null,g=(a.currentItem||a.element).find(":data(droppable)").andSelf(),f=0;a:for(;f<c.length;f++)if(!(c[f].options.disabled||a&&!c[f].accept.call(c[f].element[0],a.currentItem||a.element))){for(var h=0;h<g.length;h++)if(g[h]==c[f].element[0]){c[f].proportions.height=0;continue a}c[f].visible="none"!=c[f].element.css("display");c[f].visible&&("mousedown"==
e&&c[f]._activate.call(c[f],b),c[f].offset=c[f].element.offset(),c[f].proportions={width:c[f].element[0].offsetWidth,height:c[f].element[0].offsetHeight})}},drop:function(a,b){var c=!1;return d.each(d.ui.ddmanager.droppables[a.options.scope]||[],function(){this.options&&(!this.options.disabled&&this.visible&&d.ui.intersect(a,this,this.options.tolerance)&&(c=this._drop.call(this,b)||c),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],a.currentItem||a.element)&&(this.isout=1,this.isover=
0,this._deactivate.call(this,b)))}),c},dragStart:function(a,b){a.element.parents(":not(body,html)").bind("scroll.droppable",function(){a.options.refreshPositions||d.ui.ddmanager.prepareOffsets(a,b)})},drag:function(a,b){a.options.refreshPositions&&d.ui.ddmanager.prepareOffsets(a,b);d.each(d.ui.ddmanager.droppables[a.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var c=d.ui.intersect(a,this,this.options.tolerance);if(c=!c&&1==this.isover?"isout":c&&0==this.isover?
"isover":null){var e;if(this.options.greedy){var g=this.element.parents(":data(droppable):eq(0)");g.length&&(e=d.data(g[0],"droppable"),e.greedyChild="isover"==c?1:0)}e&&"isover"==c&&(e.isover=0,e.isout=1,e._out.call(e,b));this[c]=1;this["isout"==c?"isover":"isout"]=0;this["isover"==c?"_over":"_out"].call(this,b);e&&"isout"==c&&(e.isout=0,e.isover=1,e._over.call(e,b))}}})},dragStop:function(a,b){a.element.parents(":not(body,html)").unbind("scroll.droppable");a.options.refreshPositions||d.ui.ddmanager.prepareOffsets(a,
b)}}})(jQuery);