All Downloads are FREE. Search and download functionalities are using the official Maven repository.

template.js.base.draggable.min.js Maven / Gradle / Ivy

There is a newer version: 5.0.5
Show newest version
'use strict';(function(d){"function"===typeof define&&define.amd?define("jquery ./mouse ../data ../plugin ../safe-active-element ../safe-blur ../scroll-parent ../version ../widget".split(" "),d):d(jQuery)})(function(d){d.widget("ui.draggable",d.ui.mouse,{version:"1.12.1",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,
scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"===this.options.helper&&this._setPositionRelative();this.options.addClasses&&this._addClass("ui-draggable");this._setHandleClassName();this._mouseInit()},_setOption:function(a,c){this._super(a,c);"handle"===a&&(this._removeHandleClassName(),this._setHandleClassName())},_destroy:function(){(this.helper||this.element).is(".ui-draggable-dragging")?
this.destroyOnClear=!0:(this._removeHandleClassName(),this._mouseDestroy())},_mouseCapture:function(a){var c=this.options;if(this.helper||c.disabled||0
b[2]&&(e=b[2]+this.offset.click.left),a.pageY-this.offset.click.top>b[3]&&(d=b[3]+this.offset.click.top)),f.grid&&(d=f.grid[1]?this.originalPageY+Math.round((d-this.originalPageY)/f.grid[1])*f.grid[1]:this.originalPageY,d=b?d-this.offset.click.top>=b[1]||d-this.offset.click.top>b[3]?d:d-this.offset.click.top>=b[1]?d-f.grid[1]:d+f.grid[1]:d,e=f.grid[0]?this.originalPageX+Math.round((e-this.originalPageX)/f.grid[0])*f.grid[0]:this.originalPageX,e=b?e-this.offset.click.left>=b[0]||e-this.offset.click.left>
b[2]?e:e-this.offset.click.left>=b[0]?e-f.grid[0]:e+f.grid[0]:e),"y"===f.axis&&(e=this.originalPageX),"x"===f.axis&&(d=this.originalPageY));return{top:d-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:l?0:this.offset.scroll.top),left:e-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:l?0:this.offset.scroll.left)}},_clear:function(){this._removeClass(this.helper,
"ui-draggable-dragging");this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove();this.helper=null;this.cancelHelperRemoval=!1;this.destroyOnClear&&this.destroy()},_trigger:function(a,c,b){b=b||this._uiHash();d.ui.plugin.call(this,a,[c,b,this],!0);/^(drag|start|stop)/.test(a)&&(this.positionAbs=this._convertPositionTo("absolute"),b.offset=this.positionAbs);return d.Widget.prototype._trigger.call(this,a,c,b)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,
originalPosition:this.originalPosition,offset:this.positionAbs}}});d.ui.plugin.add("draggable","connectToSortable",{start:function(a,c,b){var g=d.extend({},c,{item:b.element});b.sortables=[];d(b.options.connectToSortable).each(function(){var c=d(this).sortable("instance");c&&!c.options.disabled&&(b.sortables.push(c),c.refreshPositions(),c._trigger("activate",a,g))})},stop:function(a,c,b){var g=d.extend({},c,{item:b.element});b.cancelHelperRemoval=!1;d.each(b.sortables,function(){this.isOver?(this.isOver=
0,b.cancelHelperRemoval=!0,this.cancelHelperRemoval=!1,this._storedCSS={position:this.placeholder.css("position"),top:this.placeholder.css("top"),left:this.placeholder.css("left")},this._mouseStop(a),this.options.helper=this.options._helper):(this.cancelHelperRemoval=!0,this._trigger("deactivate",a,g))})},drag:function(a,c,b){d.each(b.sortables,function(){var g=!1,e=this;e.positionAbs=b.positionAbs;e.helperProportions=b.helperProportions;e.offset.click=b.offset.click;e._intersectsWith(e.containerCache)&&
(g=!0,d.each(b.sortables,function(){this.positionAbs=b.positionAbs;this.helperProportions=b.helperProportions;this.offset.click=b.offset.click;this!==e&&this._intersectsWith(this.containerCache)&&d.contains(e.element[0],this.element[0])&&(g=!1);return g}));g?(e.isOver||(e.isOver=1,b._parent=c.helper.parent(),e.currentItem=c.helper.appendTo(e.element).data("ui-sortable-item",!0),e.options._helper=e.options.helper,e.options.helper=function(){return c.helper[0]},a.target=e.currentItem[0],e._mouseCapture(a,
!0),e._mouseStart(a,!0,!0),e.offset.click.top=b.offset.click.top,e.offset.click.left=b.offset.click.left,e.offset.parent.left-=b.offset.parent.left-e.offset.parent.left,e.offset.parent.top-=b.offset.parent.top-e.offset.parent.top,b._trigger("toSortable",a),b.dropped=e.element,d.each(b.sortables,function(){this.refreshPositions()}),b.currentItem=b.element,e.fromOutside=b),e.currentItem&&(e._mouseDrag(a),c.position=e.position)):e.isOver&&(e.isOver=0,e.cancelHelperRemoval=!0,e.options._revert=e.options.revert,
e.options.revert=!1,e._trigger("out",a,e._uiHash(e)),e._mouseStop(a,!0),e.options.revert=e.options._revert,e.options.helper=e.options._helper,e.placeholder&&e.placeholder.remove(),c.helper.appendTo(b._parent),b._refreshOffsets(a),c.position=b._generatePosition(a,!0),b._trigger("fromSortable",a),b.dropped=!1,d.each(b.sortables,function(){this.refreshPositions()}))})}});d.ui.plugin.add("draggable","cursor",{start:function(a,c,b){a=d("body");b=b.options;a.css("cursor")&&(b._cursor=a.css("cursor"));a.css("cursor",
b.cursor)},stop:function(a,c,b){a=b.options;a._cursor&&d("body").css("cursor",a._cursor)}});d.ui.plugin.add("draggable","opacity",{start:function(a,c,b){a=d(c.helper);b=b.options;a.css("opacity")&&(b._opacity=a.css("opacity"));a.css("opacity",b.opacity)},stop:function(a,c,b){a=b.options;a._opacity&&d(c.helper).css("opacity",a._opacity)}});d.ui.plugin.add("draggable","scroll",{start:function(a,c,b){b.scrollParentNotHidden||(b.scrollParentNotHidden=b.helper.scrollParent(!1));b.scrollParentNotHidden[0]!==
b.document[0]&&"HTML"!==b.scrollParentNotHidden[0].tagName&&(b.overflowOffset=b.scrollParentNotHidden.offset())},drag:function(a,c,b){c=b.options;var g=!1,e=b.scrollParentNotHidden[0],f=b.document[0];e!==f&&"HTML"!==e.tagName?(c.axis&&"x"===c.axis||(b.overflowOffset.top+e.offsetHeight-a.pageYp+k||wq+k||!d.contains(b.snapElements[h].item.ownerDocument,b.snapElements[h].item)?(b.snapElements[h].snapping&&b.options.snap.release&&
b.options.snap.release.call(b.element,a,d.extend(b._uiHash(),{snapItem:b.snapElements[h].item})),b.snapElements[h].snapping=!1):("inner"!==u.snapMode&&(g=Math.abs(n-w)<=k,e=Math.abs(q-s)<=k,f=Math.abs(m-v)<=k,l=Math.abs(p-r)<=k,g&&(c.position.top=b._convertPositionTo("relative",{top:n-b.helperProportions.height,left:0}).top),e&&(c.position.top=b._convertPositionTo("relative",{top:q,left:0}).top),f&&(c.position.left=b._convertPositionTo("relative",{top:0,left:m-b.helperProportions.width}).left),l&&
(c.position.left=b._convertPositionTo("relative",{top:0,left:p}).left)),t=g||e||f||l,"outer"!==u.snapMode&&(g=Math.abs(n-s)<=k,e=Math.abs(q-w)<=k,f=Math.abs(m-r)<=k,l=Math.abs(p-v)<=k,g&&(c.position.top=b._convertPositionTo("relative",{top:n,left:0}).top),e&&(c.position.top=b._convertPositionTo("relative",{top:q-b.helperProportions.height,left:0}).top),f&&(c.position.left=b._convertPositionTo("relative",{top:0,left:m}).left),l&&(c.position.left=b._convertPositionTo("relative",{top:0,left:p-b.helperProportions.width}).left)),
!b.snapElements[h].snapping&&(g||e||f||l||t)&&b.options.snap.snap&&b.options.snap.snap.call(b.element,a,d.extend(b._uiHash(),{snapItem:b.snapElements[h].item})),b.snapElements[h].snapping=g||e||f||l||t)}});d.ui.plugin.add("draggable","stack",{start:function(a,c,b){var g;a=d.makeArray(d(b.options.stack)).sort(function(a,b){return(parseInt(d(a).css("zIndex"),10)||0)-(parseInt(d(b).css("zIndex"),10)||0)});a.length&&(g=parseInt(d(a[0]).css("zIndex"),10)||0,d(a).each(function(a){d(this).css("zIndex",g+
a)}),this.css("zIndex",g+a.length))}});d.ui.plugin.add("draggable","zIndex",{start:function(a,c,b){a=d(c.helper);b=b.options;a.css("zIndex")&&(b._zIndex=a.css("zIndex"));a.css("zIndex",b.zIndex)},stop:function(a,c,b){a=b.options;a._zIndex&&d(c.helper).css("zIndex",a._zIndex)}});return d.ui.draggable});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy