From c7bec85cfa7711bb2612278eb980d0d14dade3b9 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 24 Aug 2014 07:19:38 -0400 Subject: Draggable: append divs to iframe parent for iframefix This allows the blocking div to move with the iframe in most situations, whereas appending to the body wouldn't. Fixes #9671 --- ui/draggable.js | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'ui') diff --git a/ui/draggable.js b/ui/draggable.js index ebafaeb83..997bba107 100644 --- a/ui/draggable.js +++ b/ui/draggable.js @@ -109,20 +109,32 @@ $.widget("ui.draggable", $.ui.mouse, { return false; } - $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() { - $("
") - .css({ - width: this.offsetWidth + "px", height: this.offsetHeight + "px", - position: "absolute", opacity: "0.001", zIndex: 1000 - }) - .css($(this).offset()) - .appendTo("body"); - }); + this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix ); return true; }, + _blockFrames: function( selector ) { + this.iframeBlocks = this.document.find( selector ).map(function() { + var iframe = $( this ); + + return $( "
" ) + .css( "position", "absolute" ) + .appendTo( iframe.parent() ) + .outerWidth( iframe.outerWidth() ) + .outerHeight( iframe.outerHeight() ) + .offset( iframe.offset() )[ 0 ]; + }); + }, + + _unblockFrames: function() { + if ( this.iframeBlocks ) { + this.iframeBlocks.remove(); + delete this.iframeBlocks; + } + }, + _blurActiveElement: function( event ) { var document = this.document[ 0 ]; @@ -297,10 +309,7 @@ $.widget("ui.draggable", $.ui.mouse, { }, _mouseUp: function( event ) { - //Remove frame helpers - $("div.ui-draggable-iframeFix").each(function() { - this.parentNode.removeChild(this); - }); + this._unblockFrames(); //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003) if ( $.ui.ddmanager ) { -- cgit v1.2.3