WordPress/wp-includes/js/jquery/ui/droppable.min.js

11 lines
6.1 KiB
JavaScript
Raw Normal View History

/*!
* jQuery UI Droppable 1.11.4
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* http://api.jqueryui.com/droppable/
*/
!function(e){"function"==typeof define&&define.amd?define(["jquery","./core","./widget","./mouse","./draggable"],e):e(jQuery)}(function(a){function d(e,t,i){return t<=e&&e<t+i}return a.widget("ui.droppable",{version:"1.11.4",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var e,t=this.options,i=t.accept;this.isover=!1,this.isout=!0,this.accept=a.isFunction(i)?i:function(e){return e.is(i)},this.proportions=function(){if(!arguments.length)return e=e||{width:this.element[0].offsetWidth,height:this.element[0].offsetHeight};e=arguments[0]},this._addToManager(t.scope),t.addClasses&&this.element.addClass("ui-droppable")},_addToManager:function(e){a.ui.ddmanager.droppables[e]=a.ui.ddmanager.droppables[e]||[],a.ui.ddmanager.droppables[e].push(this)},_splice:function(e){for(var t=0;t<e.length;t++)e[t]===this&&e.splice(t,1)},_destroy:function(){var e=a.ui.ddmanager.droppables[this.options.scope];this._splice(e),this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(e,t){var i;"accept"===e?this.accept=a.isFunction(t)?t:function(e){return e.is(t)}:"scope"===e&&(i=a.ui.ddmanager.droppables[this.options.scope],this._splice(i),this._addToManager(t)),this._super(e,t)},_activate:function(e){var t=a.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),t&&this._trigger("activate",e,this.ui(t))},_deactivate:function(e){var t=a.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),t&&this._trigger("deactivate",e,this.ui(t))},_over:function(e){var t=a.ui.ddmanager.current;t&&(t.currentItem||t.element)[0]!==this.element[0]&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",e,this.ui(t)))},_out:function(e){var t=a.ui.ddmanager.current;t&&(t.currentItem||t.element)[0]!==this.element[0]&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",e,this.ui(t)))},_drop:function(t,e){var i=e||a.ui.ddmanager.current,s=!1;return!(!i||(i.currentItem||i.element)[0]===this.element[0])&&(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var e=a(this).droppable("instance");if(e.options.greedy&&!e.options.disabled&&e.options.scope===i.options.scope&&e.accept.call(e.element[0],i.currentItem||i.element)&&a.ui.intersect(i,a.extend(e,{offset:e.element.offset()}),e.options.tolerance,t))return!(s=!0)}),!s&&(!!this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",t,this.ui(i)),this.element)))},ui:function(e){return{draggable:e.currentItem||e.element,helper:e.helper,position:e.position,offset:e.positionAbs}}}),a.ui.intersect=function(e,t,i,s){if(!t.offset)return!1;var o=(e.positionAbs||e.position.absolute).left+e.margins.left,n=(e.positionAbs||e.position.absolute).top+e.margins.top,r=o+e.helperProportions.width,a=n+e.helperProportions.height,l=t.offset.left,p=t.offset.top,h=l+t.proportions().width,c=p+t.proportions().height;switch(i){case"fit":return l<=o&&r<=h&&p<=n&&a<=c;case"intersect":return l<o+e.helperProportions.width/2&&r-e.helperProportions.width/2<h&&p<n+e.helperProportions.height/2&&a-e.helperProportions.height/2<c;case"pointer":return d(s.pageY,p,t.proportions().height)&&d(s.pageX,l,t.proportions().width);case"touch":return(p<=n&&n<=c||p<=a&&a<=c||n<p&&c<a)&&(l<=o&&o<=h||l<=r&&r<=h||o<l&&h<r);default:return!1}},a.ui.ddmanager={current:null,droppables:{default:[]},prepareOffsets:function(e,t){var i,s,o=a.ui.ddmanager.droppables[e.options.scope]||[],n=t?t.type:null,r=(e.currentItem||e.element).find(":data(ui-droppable)").addBack();e:for(i=0;i<o.length;i++)if(!(o[i].opt