Skip to content

Commit 17c7f69

Browse files
marcuswarrencascottgonzalez
authored andcommitted
Sortable: Add support for iframes
Fixes #9604 Closes gh-1443
1 parent 912eb62 commit 17c7f69

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

ui/sortable.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
276276
}
277277

278278
//Prepare scrolling
279-
if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
279+
if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
280280
this.overflowOffset = this.scrollParent.offset();
281281
}
282282

@@ -328,7 +328,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
328328

329329
//Do scrolling
330330
if(this.options.scroll) {
331-
if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
331+
if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
332332

333333
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
334334
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
@@ -344,16 +344,16 @@ return $.widget("ui.sortable", $.ui.mouse, {
344344

345345
} else {
346346

347-
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
348-
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
349-
} else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
350-
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
347+
if(event.pageY - this.document.scrollTop() < o.scrollSensitivity) {
348+
scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed);
349+
} else if(this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) {
350+
scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed);
351351
}
352352

353-
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
354-
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
355-
} else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
356-
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
353+
if(event.pageX - this.document.scrollLeft() < o.scrollSensitivity) {
354+
scrolled = this.document.scrollLeft(this.document.scrollLeft() - o.scrollSpeed);
355+
} else if(this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) {
356+
scrolled = this.document.scrollLeft(this.document.scrollLeft() + o.scrollSpeed);
357357
}
358358

359359
}
@@ -452,10 +452,10 @@ return $.widget("ui.sortable", $.ui.mouse, {
452452
animation = {};
453453

454454
if ( !axis || axis === "x" ) {
455-
animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
455+
animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft);
456456
}
457457
if ( !axis || axis === "y" ) {
458-
animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
458+
animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop);
459459
}
460460
this.reverting = true;
461461
$(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
@@ -648,7 +648,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
648648

649649
if(connectWith && connected) {
650650
for (i = connectWith.length - 1; i >= 0; i--){
651-
cur = $(connectWith[i]);
651+
cur = $(connectWith[i], this.document[0]);
652652
for ( j = cur.length - 1; j >= 0; j--){
653653
inst = $.data(cur[j], this.widgetFullName);
654654
if(inst && inst !== this && !inst.options.disabled) {
@@ -698,7 +698,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
698698

699699
if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
700700
for (i = connectWith.length - 1; i >= 0; i--){
701-
cur = $(connectWith[i]);
701+
cur = $(connectWith[i], this.document[0]);
702702
for (j = cur.length - 1; j >= 0; j--){
703703
inst = $.data(cur[j], this.widgetFullName);
704704
if(inst && inst !== this && !inst.options.disabled) {
@@ -995,14 +995,14 @@ return $.widget("ui.sortable", $.ui.mouse, {
995995
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
996996
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
997997
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
998-
if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
998+
if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
999999
po.left += this.scrollParent.scrollLeft();
10001000
po.top += this.scrollParent.scrollTop();
10011001
}
10021002

10031003
// This needs to be actually done for all browsers, since pageX/pageY includes this information
10041004
// with an ugly IE fix
1005-
if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
1005+
if( this.offsetParent[0] === this.document[0].body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
10061006
po = { top: 0, left: 0 };
10071007
}
10081008

@@ -1052,8 +1052,8 @@ return $.widget("ui.sortable", $.ui.mouse, {
10521052
this.containment = [
10531053
0 - this.offset.relative.left - this.offset.parent.left,
10541054
0 - this.offset.relative.top - this.offset.parent.top,
1055-
$(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
1056-
($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
1055+
o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left,
1056+
(o.containment === "document" ? this.document.width() : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
10571057
];
10581058
}
10591059

@@ -1078,7 +1078,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
10781078
pos = this.position;
10791079
}
10801080
var mod = d === "absolute" ? 1 : -1,
1081-
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
1081+
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
10821082
scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
10831083

10841084
return {
@@ -1104,13 +1104,13 @@ return $.widget("ui.sortable", $.ui.mouse, {
11041104
o = this.options,
11051105
pageX = event.pageX,
11061106
pageY = event.pageY,
1107-
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);
1107+
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);
11081108

11091109
// This is another very weird special case that only happens for relative elements:
11101110
// 1. If the css position is relative
11111111
// 2. and the scroll parent is the document or similar to the offset parent
11121112
// we have to refresh the relative offset during the scroll so there are no jumps
1113-
if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
1113+
if(this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) {
11141114
this.offset.relative = this._getRelativeOffset();
11151115
}
11161116

0 commit comments

Comments
 (0)