clientY: Math.round( y )
};
- this.simulateEvent( document, "mousemove", coord );
+ this.simulateEvent( target.ownerDocument, "mousemove", coord );
}
if ( $.contains( document, target ) ) {
});
});
+test( "#5727: draggable from iframe" , function() {
+ expect( 2 );
+
+ var iframe = $( "<iframe id='iframe-draggable-container' src='about:blank'></iframe>" ).appendTo( "#qunit-fixture" ),
+ iframeBody = iframe.contents().find( "body" ).append(
+ "<div id='iframe-draggable-1' style='background: green; width: 200px; height: 100px;'>Relative</div>"
+ ),
+ draggable1 = iframeBody.find( "#iframe-draggable-1" );
+
+ draggable1.draggable();
+
+ equal( draggable1.closest( iframeBody ).length, 1 );
+
+ TestHelpers.draggable.shouldMove( draggable1 );
+});
+
})( jQuery );
}).eq(0);
}
- return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
+ return ( /fixed/ ).test( this.css( "position") ) || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
},
uniqueId: function() {
_getParentOffset: function() {
//Get the offsetParent and cache its position
- var po = this.offsetParent.offset();
+ var po = this.offsetParent.offset(),
+ document = this.document[ 0 ];
// This is a special case where we need to modify a offset calculated on start, since the following happened:
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
_setContainment: function() {
var over, c, ce,
- o = this.options;
+ o = this.options,
+ document = this.document[ 0 ];
if ( !o.containment ) {
this.containment = null;
}
var mod = d === "absolute" ? 1 : -1,
+ document = this.document[ 0 ],
scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
//Cache the scroll
var containment, co, top, left,
o = this.options,
+ document = this.document[ 0 ],
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;
$.ui.plugin.add("draggable", "scroll", {
start: function( event, ui, i ) {
- if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
+ if( i.scrollParent[ 0 ] !== i.document[ 0 ] && i.scrollParent[ 0 ].tagName !== "HTML" ) {
i.overflowOffset = i.scrollParent.offset();
}
},
drag: function( event, ui, i ) {
var o = i.options,
- scrolled = false;
-
- if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
+ scrolled = false,
+ document = i.document[ 0 ];
+ if( i.scrollParent[ 0 ] !== document && i.scrollParent[ 0 ].tagName !== "HTML" ) {
if(!o.axis || o.axis !== "x") {
if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
_mouseDestroy: function() {
this.element.unbind("."+this.widgetName);
if ( this._mouseMoveDelegate ) {
- $(document)
+ this.document
.unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
.unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
}
this._mouseUpDelegate = function(event) {
return that._mouseUp(event);
};
- $(document)
- .bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
- .bind("mouseup."+this.widgetName, this._mouseUpDelegate);
+
+ this.document
+ .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
+ .bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
event.preventDefault();
if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
return this._mouseUp(event);
}
+ // Iframe mouseup check - mouseup occurred in another document
+ else if ( !event.which ) {
+ return this._mouseUp( event );
+ }
if (this._mouseStarted) {
this._mouseDrag(event);
},
_mouseUp: function(event) {
- $(document)
- .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
- .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
+ this.document
+ .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
+ .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
if (this._mouseStarted) {
this._mouseStarted = false;
this._mouseStop(event);
}
+ mouseHandled = false;
return false;
},