mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Sortable: Add support for iframes
Fixes #9604
Closes gh-1443
(cherry picked from commit 17c7f698a2
)
This commit is contained in:
parent
0a0db09378
commit
fa460f36dc
@ -276,7 +276,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Prepare scrolling
|
//Prepare scrolling
|
||||||
if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
|
if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
|
||||||
this.overflowOffset = this.scrollParent.offset();
|
this.overflowOffset = this.scrollParent.offset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
|
|||||||
|
|
||||||
//Do scrolling
|
//Do scrolling
|
||||||
if(this.options.scroll) {
|
if(this.options.scroll) {
|
||||||
if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
|
if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
|
||||||
|
|
||||||
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
|
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
|
||||||
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
|
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
|
||||||
@ -344,16 +344,16 @@ return $.widget("ui.sortable", $.ui.mouse, {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
|
if(event.pageY - this.document.scrollTop() < o.scrollSensitivity) {
|
||||||
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
|
scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed);
|
||||||
} else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
|
} else if(this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) {
|
||||||
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
|
scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
|
if(event.pageX - this.document.scrollLeft() < o.scrollSensitivity) {
|
||||||
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
|
scrolled = this.document.scrollLeft(this.document.scrollLeft() - o.scrollSpeed);
|
||||||
} else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
|
} else if(this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) {
|
||||||
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
|
scrolled = this.document.scrollLeft(this.document.scrollLeft() + o.scrollSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -452,10 +452,10 @@ return $.widget("ui.sortable", $.ui.mouse, {
|
|||||||
animation = {};
|
animation = {};
|
||||||
|
|
||||||
if ( !axis || axis === "x" ) {
|
if ( !axis || axis === "x" ) {
|
||||||
animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
|
animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft);
|
||||||
}
|
}
|
||||||
if ( !axis || axis === "y" ) {
|
if ( !axis || axis === "y" ) {
|
||||||
animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
|
animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop);
|
||||||
}
|
}
|
||||||
this.reverting = true;
|
this.reverting = true;
|
||||||
$(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
|
$(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
|
||||||
@ -648,7 +648,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
|
|||||||
|
|
||||||
if(connectWith && connected) {
|
if(connectWith && connected) {
|
||||||
for (i = connectWith.length - 1; i >= 0; i--){
|
for (i = connectWith.length - 1; i >= 0; i--){
|
||||||
cur = $(connectWith[i]);
|
cur = $(connectWith[i], this.document[0]);
|
||||||
for ( j = cur.length - 1; j >= 0; j--){
|
for ( j = cur.length - 1; j >= 0; j--){
|
||||||
inst = $.data(cur[j], this.widgetFullName);
|
inst = $.data(cur[j], this.widgetFullName);
|
||||||
if(inst && inst !== this && !inst.options.disabled) {
|
if(inst && inst !== this && !inst.options.disabled) {
|
||||||
@ -698,7 +698,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
|
|||||||
|
|
||||||
if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
|
if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
|
||||||
for (i = connectWith.length - 1; i >= 0; i--){
|
for (i = connectWith.length - 1; i >= 0; i--){
|
||||||
cur = $(connectWith[i]);
|
cur = $(connectWith[i], this.document[0]);
|
||||||
for (j = cur.length - 1; j >= 0; j--){
|
for (j = cur.length - 1; j >= 0; j--){
|
||||||
inst = $.data(cur[j], this.widgetFullName);
|
inst = $.data(cur[j], this.widgetFullName);
|
||||||
if(inst && inst !== this && !inst.options.disabled) {
|
if(inst && inst !== this && !inst.options.disabled) {
|
||||||
@ -990,14 +990,14 @@ return $.widget("ui.sortable", $.ui.mouse, {
|
|||||||
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
|
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
|
||||||
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
|
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
|
||||||
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
|
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
|
||||||
if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
|
if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
|
||||||
po.left += this.scrollParent.scrollLeft();
|
po.left += this.scrollParent.scrollLeft();
|
||||||
po.top += this.scrollParent.scrollTop();
|
po.top += this.scrollParent.scrollTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This needs to be actually done for all browsers, since pageX/pageY includes this information
|
// This needs to be actually done for all browsers, since pageX/pageY includes this information
|
||||||
// with an ugly IE fix
|
// with an ugly IE fix
|
||||||
if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
|
if( this.offsetParent[0] === this.document[0].body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
|
||||||
po = { top: 0, left: 0 };
|
po = { top: 0, left: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1047,8 +1047,8 @@ return $.widget("ui.sortable", $.ui.mouse, {
|
|||||||
this.containment = [
|
this.containment = [
|
||||||
0 - this.offset.relative.left - this.offset.parent.left,
|
0 - this.offset.relative.left - this.offset.parent.left,
|
||||||
0 - this.offset.relative.top - this.offset.parent.top,
|
0 - this.offset.relative.top - this.offset.parent.top,
|
||||||
$(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
|
o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left,
|
||||||
($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
|
(o.containment === "document" ? this.document.width() : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1073,7 +1073,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
|
|||||||
pos = this.position;
|
pos = this.position;
|
||||||
}
|
}
|
||||||
var mod = d === "absolute" ? 1 : -1,
|
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,
|
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
|
||||||
scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -1099,13 +1099,13 @@ return $.widget("ui.sortable", $.ui.mouse, {
|
|||||||
o = this.options,
|
o = this.options,
|
||||||
pageX = event.pageX,
|
pageX = event.pageX,
|
||||||
pageY = event.pageY,
|
pageY = event.pageY,
|
||||||
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] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
||||||
|
|
||||||
// This is another very weird special case that only happens for relative elements:
|
// This is another very weird special case that only happens for relative elements:
|
||||||
// 1. If the css position is relative
|
// 1. If the css position is relative
|
||||||
// 2. and the scroll parent is the document or similar to the offset parent
|
// 2. and the scroll parent is the document or similar to the offset parent
|
||||||
// we have to refresh the relative offset during the scroll so there are no jumps
|
// we have to refresh the relative offset during the scroll so there are no jumps
|
||||||
if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
|
if(this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) {
|
||||||
this.offset.relative = this._getRelativeOffset();
|
this.offset.relative = this._getRelativeOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user