aboutsummaryrefslogtreecommitdiffstats
path: root/themes/default/js/ui/jquery.ui.draggable.js
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/js/ui/jquery.ui.draggable.js')
-rw-r--r--themes/default/js/ui/jquery.ui.draggable.js167
1 files changed, 91 insertions, 76 deletions
diff --git a/themes/default/js/ui/jquery.ui.draggable.js b/themes/default/js/ui/jquery.ui.draggable.js
index 7cac0cafd..d3281dc4f 100644
--- a/themes/default/js/ui/jquery.ui.draggable.js
+++ b/themes/default/js/ui/jquery.ui.draggable.js
@@ -1,8 +1,8 @@
/*!
- * jQuery UI Draggable 1.10.1
+ * jQuery UI Draggable 1.10.4
* http://jqueryui.com
*
- * Copyright 2013 jQuery Foundation and other contributors
+ * Copyright 2014 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
@@ -16,7 +16,7 @@
(function( $, undefined ) {
$.widget("ui.draggable", $.ui.mouse, {
- version: "1.10.1",
+ version: "1.10.4",
widgetEventPrefix: "drag",
options: {
addClasses: true,
@@ -125,8 +125,10 @@ $.widget("ui.draggable", $.ui.mouse, {
this._cacheMargins();
//Store the helper's css position
- this.cssPosition = this.helper.css("position");
+ this.cssPosition = this.helper.css( "position" );
this.scrollParent = this.helper.scrollParent();
+ this.offsetParent = this.helper.offsetParent();
+ this.offsetParentCssPosition = this.offsetParent.css( "position" );
//The element's absolute position on the page minus margins
this.offset = this.positionAbs = this.element.offset();
@@ -135,6 +137,9 @@ $.widget("ui.draggable", $.ui.mouse, {
left: this.offset.left - this.margins.left
};
+ //Reset scroll cache
+ this.offset.scroll = false;
+
$.extend(this.offset, {
click: { //Where the click happened, relative to the element
left: event.pageX - this.offset.left,
@@ -153,9 +158,7 @@ $.widget("ui.draggable", $.ui.mouse, {
(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
//Set a containment if given in the options
- if(o.containment) {
- this._setContainment();
- }
+ this._setContainment();
//Trigger event + callbacks
if(this._trigger("start", event) === false) {
@@ -183,6 +186,10 @@ $.widget("ui.draggable", $.ui.mouse, {
},
_mouseDrag: function(event, noPropagation) {
+ // reset any necessary cached properties (see #5009)
+ if ( this.offsetParentCssPosition === "fixed" ) {
+ this.offset.parent = this._getParentOffset();
+ }
//Compute the helpers position
this.position = this._generatePosition(event);
@@ -214,9 +221,7 @@ $.widget("ui.draggable", $.ui.mouse, {
_mouseStop: function(event) {
//If we are using droppables, inform the manager about the drop
- var element,
- that = this,
- elementInDom = false,
+ var that = this,
dropped = false;
if ($.ui.ddmanager && !this.options.dropBehaviour) {
dropped = $.ui.ddmanager.drop(this, event);
@@ -229,13 +234,7 @@ $.widget("ui.draggable", $.ui.mouse, {
}
//if the original element is no longer in the DOM don't bother to continue (see #8269)
- element = this.element[0];
- while ( element && (element = element.parentNode) ) {
- if (element === document ) {
- elementInDom = true;
- }
- }
- if ( !elementInDom && this.options.helper === "original" ) {
+ if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
return false;
}
@@ -281,19 +280,9 @@ $.widget("ui.draggable", $.ui.mouse, {
},
_getHandle: function(event) {
-
- var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
- $(this.options.handle, this.element)
- .find("*")
- .addBack()
- .each(function() {
- if(this === event.target) {
- handle = true;
- }
- });
-
- return handle;
-
+ return this.options.handle ?
+ !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
+ true;
},
_createHelper: function(event) {
@@ -337,7 +326,6 @@ $.widget("ui.draggable", $.ui.mouse, {
_getParentOffset: function() {
//Get the offsetParent and cache its position
- this.offsetParent = this.helper.offsetParent();
var po = this.offsetParent.offset();
// This is a special case where we need to modify a offset calculated on start, since the following happened:
@@ -398,40 +386,56 @@ $.widget("ui.draggable", $.ui.mouse, {
var over, c, ce,
o = this.options;
- if(o.containment === "parent") {
- o.containment = this.helper[0].parentNode;
+ if ( !o.containment ) {
+ this.containment = null;
+ return;
}
- if(o.containment === "document" || o.containment === "window") {
+
+ if ( o.containment === "window" ) {
this.containment = [
- o.containment === "document" ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
- o.containment === "document" ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
- (o.containment === "document" ? 0 : $(window).scrollLeft()) + $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
- (o.containment === "document" ? 0 : $(window).scrollTop()) + ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
+ $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
+ $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
+ $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
+ $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
];
+ return;
}
- if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor !== Array) {
- c = $(o.containment);
- ce = c[0];
-
- if(!ce) {
- return;
- }
-
- over = ($(ce).css("overflow") !== "hidden");
-
+ if ( o.containment === "document") {
this.containment = [
- (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
- (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
- (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
- (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom
+ 0,
+ 0,
+ $( document ).width() - this.helperProportions.width - this.margins.left,
+ ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
];
- this.relative_container = c;
+ return;
+ }
- } else if(o.containment.constructor === Array) {
+ if ( o.containment.constructor === Array ) {
this.containment = o.containment;
+ return;
+ }
+
+ if ( o.containment === "parent" ) {
+ o.containment = this.helper[ 0 ].parentNode;
}
+ c = $( o.containment );
+ ce = c[ 0 ];
+
+ if( !ce ) {
+ return;
+ }
+
+ over = c.css( "overflow" ) !== "hidden";
+
+ this.containment = [
+ ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
+ ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
+ ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
+ ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom
+ ];
+ this.relative_container = c;
},
_convertPositionTo: function(d, pos) {
@@ -441,20 +445,25 @@ $.widget("ui.draggable", $.ui.mouse, {
}
var mod = d === "absolute" ? 1 : -1,
- scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
+
+ //Cache the scroll
+ if (!this.offset.scroll) {
+ this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
+ }
return {
top: (
pos.top + // The absolute mouse position
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
),
left: (
pos.left + // The absolute mouse position
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
)
};
@@ -464,28 +473,35 @@ $.widget("ui.draggable", $.ui.mouse, {
var containment, co, top, left,
o = this.options,
- scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
- scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName),
+ scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
pageX = event.pageX,
pageY = event.pageY;
+ //Cache the scroll
+ if (!this.offset.scroll) {
+ this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
+ }
+
/*
* - Position constraining -
* Constrain the position to a mix of grid, containment.
*/
- if(this.originalPosition) { //If we are not dragging yet, we won't check for options
- if(this.containment) {
- if (this.relative_container){
- co = this.relative_container.offset();
- containment = [ this.containment[0] + co.left,
- this.containment[1] + co.top,
- this.containment[2] + co.left,
- this.containment[3] + co.top ];
- }
- else {
- containment = this.containment;
- }
+ // If we are not dragging yet, we won't check for options
+ if ( this.originalPosition ) {
+ if ( this.containment ) {
+ if ( this.relative_container ){
+ co = this.relative_container.offset();
+ containment = [
+ this.containment[ 0 ] + co.left,
+ this.containment[ 1 ] + co.top,
+ this.containment[ 2 ] + co.left,
+ this.containment[ 3 ] + co.top
+ ];
+ }
+ else {
+ containment = this.containment;
+ }
if(event.pageX - this.offset.click.left < containment[0]) {
pageX = containment[0] + this.offset.click.left;
@@ -518,14 +534,14 @@ $.widget("ui.draggable", $.ui.mouse, {
this.offset.click.top - // Click offset (relative to the element)
this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
+ ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
),
left: (
pageX - // The absolute mouse position
this.offset.click.left - // Click offset (relative to the element)
this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
+ ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
)
};
@@ -600,7 +616,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
//The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
if(this.shouldRevert) {
- this.instance.options.revert = true;
+ this.instance.options.revert = this.shouldRevert;
}
//Trigger the stop of the sortable
@@ -847,8 +863,7 @@ $.ui.plugin.add("draggable", "snap", {
t = inst.snapElements[i].top;
b = t + inst.snapElements[i].height;
- //Yes, I know, this is insane ;)
- if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
+ if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
if(inst.snapElements[i].snapping) {
(inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
}